|
33 | 33 | #include <lib/core/TLV.h>
|
34 | 34 | #include <lib/support/CHIPMem.h>
|
35 | 35 | #include <lib/support/CodeUtils.h>
|
| 36 | +#include <lib/support/UnitTestExtendedAssertions.h> |
36 | 37 | #include <lib/support/UnitTestRegistration.h>
|
37 | 38 |
|
38 | 39 | #include <nlunit-test.h>
|
@@ -2191,6 +2192,20 @@ static void TestChipCert_PDCIdentityGeneration(nlTestSuite * inSuite, void * inC
|
2191 | 2192 | NL_TEST_ASSERT(inSuite, ValidateChipNetworkIdentity(tlvCert) == CHIP_NO_ERROR);
|
2192 | 2193 | }
|
2193 | 2194 |
|
| 2195 | +static void TestChipCert_KeypairConversion(nlTestSuite * inSuite, void * inContext) |
| 2196 | +{ |
| 2197 | + P256SerializedKeypair keypair; |
| 2198 | + NL_TEST_ASSERT_SUCCESS(inSuite, GetTestCertKeypair(kPDCID01, keypair)); |
| 2199 | + |
| 2200 | + uint8_t buffer[kP256ECPrivateKeyDERLength]; |
| 2201 | + MutableByteSpan keypairDer(buffer); |
| 2202 | + NL_TEST_ASSERT_SUCCESS(inSuite, ConvertECDSAKeypairRawToDER(keypair, keypairDer)); |
| 2203 | + |
| 2204 | + // Technically the curve name and public key are optional in the DER format, |
| 2205 | + // but both our code and standard tools include them, so we can just compare. |
| 2206 | + NL_TEST_ASSERT(inSuite, keypairDer.data_equal(sTestCert_PDCID01_KeypairDER)); |
| 2207 | +} |
| 2208 | + |
2194 | 2209 | /**
|
2195 | 2210 | * Set up the test suite.
|
2196 | 2211 | */
|
@@ -2251,6 +2266,7 @@ static const nlTest sTests[] = {
|
2251 | 2266 | NL_TEST_DEF("Test extracting PublicKey and SKID from chip certificate", TestChipCert_ExtractPublicKeyAndSKID),
|
2252 | 2267 | NL_TEST_DEF("Test PDC Identity Validation", TestChipCert_PDCIdentityValidation),
|
2253 | 2268 | NL_TEST_DEF("Test PDC Identity Generation", TestChipCert_PDCIdentityGeneration),
|
| 2269 | + NL_TEST_DEF("Test keypair conversion", TestChipCert_KeypairConversion), |
2254 | 2270 | NL_TEST_SENTINEL()
|
2255 | 2271 | };
|
2256 | 2272 | // clang-format on
|
|
0 commit comments