Skip to content

Commit 16ffaf7

Browse files
committed
add EC cert test
1 parent 68c3244 commit 16ffaf7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/credential.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,40 @@ TEST_CASE("X509 Credential Depth 2")
4848
CHECK(x509.der_chain == x509_original.der_chain);
4949
}
5050

51+
TEST_CASE("X509 Credential EC certificates")
52+
{
53+
// Chain is of depth 2
54+
const auto keydata =
55+
from_hex("30770201010420e32d0df2b096edadd778b3e884e84b14454d02668d3ef9f81e7"
56+
"d9425ca9acf82a00a06082a8648ce3d030107a144034200049c37d6e8722c509c"
57+
"c71bfda2389d4d3f6da6088b605c8bd6bd6dde6ccf77d3aa8c4f205cc273ac47b"
58+
"e9e353e43debf2ad9a226fe0ea7a11b5bb06eb5d932e045");
59+
const auto cert = from_hex(
60+
"308201e230820187a00302010202045a49733d300a06082a8648ce3d040302307331133011"
61+
"060a0992268993f22c6401191603636f6d31173015060a0992268993f22c64011916076d61"
62+
"696c6f757331143012060a0992268993f22c640101130474657374312d302b060355040b13"
63+
"2431313436386463622d663830342d346563362d616166362d363263623437333931333733"
64+
"301e170d3233303731353136303135305a170d3233303831353136303135305a3044311330"
65+
"11060a0992268993f22c6401191603636f6d31173015060a0992268993f22c64011916076d"
66+
"61696c6f757331143012060a0992268993f22c6401011304746573743059301306072a8648"
67+
"ce3d020106082a8648ce3d030107034200049c37d6e8722c509cc71bfda2389d4d3f6da608"
68+
"8b605c8bd6bd6dde6ccf77d3aa8c4f205cc273ac47be9e353e43debf2ad9a226fe0ea7a11b"
69+
"5bb06eb5d932e045a3383036300e0603551d0f0101ff0404030204f030160603551d250101"
70+
"ff040c300a06082b06010505070301300c0603551d130101ff04023000300a06082a8648ce"
71+
"3d0403020349003046022100d670fb29f08dd0bc5d81cd6258ade6a8e5b6a5f630b510272c"
72+
"ffa8d77f79f24e022100d166a8ae636916c84e1d854def33a57549e06b5c1d2c5e4ea7a797"
73+
"df74401531");
74+
75+
const std::vector<bytes> der_in{ cert };
76+
77+
auto key = SignaturePrivateKey::parse(
78+
mls::CipherSuite::ID::P256_AES128GCM_SHA256_P256, keydata);
79+
80+
auto cred = Credential::x509(der_in);
81+
auto x509 = cred.get<X509Credential>();
82+
CHECK(x509.public_key() == key.public_key);
83+
}
84+
5185
TEST_CASE("X509 Credential Depth 2 Marshal/Unmarshal")
5286
{
5387
// Chain is of depth 2

0 commit comments

Comments
 (0)