diff --git a/src/crypto/tests/CHIPCryptoPALTest.cpp b/src/crypto/tests/CHIPCryptoPALTest.cpp index eb95e9d9d8a7b6..2ffc861df3762b 100644 --- a/src/crypto/tests/CHIPCryptoPALTest.cpp +++ b/src/crypto/tests/CHIPCryptoPALTest.cpp @@ -1983,80 +1983,44 @@ static void TestX509_IssuingTimestampValidation(nlTestSuite * inSuite, void * in HeapChecker heapChecker(inSuite); CHIP_ERROR err = CHIP_NO_ERROR; - /* - credentials/test/attestation/Chip-Test-DAC-FFF1-8000-000A-Cert.pem - -----BEGIN CERTIFICATE----- - MIIB6jCCAY+gAwIBAgIIBRpp5eeAND4wCgYIKoZIzj0EAwIwRjEYMBYGA1UEAwwP - TWF0dGVyIFRlc3QgUEFJMRQwEgYKKwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQB - gqJ8AgIMBDgwMDAwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEyMzU5NTlaMEsx - HTAbBgNVBAMMFE1hdHRlciBUZXN0IERBQyAwMDBBMRQwEgYKKwYBBAGConwCAQwE - RkZGMTEUMBIGCisGAQQBgqJ8AgIMBDgwMDAwWTATBgcqhkjOPQIBBggqhkjOPQMB - BwNCAAR6hFivu5vNFeGa3NJm9mycL2B8dHR6NfgPN+EYEz+A8XYBEyePkfFaoPf4 - eTIJT+aftyhoqB4ml5s2izO1VDEDo2AwXjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB - /wQEAwIHgDAdBgNVHQ4EFgQU1a2yuIOOyAc8R3LcfoeX/rsjs64wHwYDVR0jBBgw - FoAUhPUd/57M2ik1lEhSDoXxKS2j7dcwCgYIKoZIzj0EAwIDSQAwRgIhAPL+Fnlk - P0xbynYuijQV7VEwBvzQUtpQbWLYvVFeN70IAiEAvi20eqszdReOEkmgeSCgrG6q - OS8H8W2E/ctS268o19k= - -----END CERTIFICATE----- - */ - /* - Validity - Not Before: Jun 28 14:23:43 2021 GMT - Not After : Dec 31 23:59:59 9999 GMT - */ - constexpr uint8_t kDacCertificate[] = { - 0x30, 0x82, 0x01, 0xEA, 0x30, 0x82, 0x01, 0x8F, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x05, 0x1A, 0x69, 0xE5, 0xE7, - 0x80, 0x34, 0x3E, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x46, 0x31, 0x18, 0x30, - 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0F, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, - 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0xA2, 0x7C, 0x02, 0x01, 0x0C, - 0x04, 0x46, 0x46, 0x46, 0x31, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0xA2, 0x7C, 0x02, - 0x02, 0x0C, 0x04, 0x38, 0x30, 0x30, 0x30, 0x30, 0x20, 0x17, 0x0D, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, - 0x33, 0x34, 0x33, 0x5A, 0x18, 0x0F, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, - 0x5A, 0x30, 0x4B, 0x31, 0x1D, 0x30, 0x1B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, - 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x41, 0x43, 0x20, 0x30, 0x30, 0x30, 0x41, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0A, - 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0xA2, 0x7C, 0x02, 0x01, 0x0C, 0x04, 0x46, 0x46, 0x46, 0x31, 0x31, 0x14, 0x30, 0x12, - 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0xA2, 0x7C, 0x02, 0x02, 0x0C, 0x04, 0x38, 0x30, 0x30, 0x30, 0x30, 0x59, - 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, - 0x07, 0x03, 0x42, 0x00, 0x04, 0x7A, 0x84, 0x58, 0xAF, 0xBB, 0x9B, 0xCD, 0x15, 0xE1, 0x9A, 0xDC, 0xD2, 0x66, 0xF6, 0x6C, - 0x9C, 0x2F, 0x60, 0x7C, 0x74, 0x74, 0x7A, 0x35, 0xF8, 0x0F, 0x37, 0xE1, 0x18, 0x13, 0x3F, 0x80, 0xF1, 0x76, 0x01, 0x13, - 0x27, 0x8F, 0x91, 0xF1, 0x5A, 0xA0, 0xF7, 0xF8, 0x79, 0x32, 0x09, 0x4F, 0xE6, 0x9F, 0xB7, 0x28, 0x68, 0xA8, 0x1E, 0x26, - 0x97, 0x9B, 0x36, 0x8B, 0x33, 0xB5, 0x54, 0x31, 0x03, 0xA3, 0x60, 0x30, 0x5E, 0x30, 0x0C, 0x06, 0x03, 0x55, 0x1D, 0x13, - 0x01, 0x01, 0xFF, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, - 0x02, 0x07, 0x80, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xD5, 0xAD, 0xB2, 0xB8, 0x83, 0x8E, - 0xC8, 0x07, 0x3C, 0x47, 0x72, 0xDC, 0x7E, 0x87, 0x97, 0xFE, 0xBB, 0x23, 0xB3, 0xAE, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, - 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x84, 0xF5, 0x1D, 0xFF, 0x9E, 0xCC, 0xDA, 0x29, 0x35, 0x94, 0x48, 0x52, 0x0E, - 0x85, 0xF1, 0x29, 0x2D, 0xA3, 0xED, 0xD7, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x03, - 0x49, 0x00, 0x30, 0x46, 0x02, 0x21, 0x00, 0xF2, 0xFE, 0x16, 0x79, 0x64, 0x3F, 0x4C, 0x5B, 0xCA, 0x76, 0x2E, 0x8A, 0x34, - 0x15, 0xED, 0x51, 0x30, 0x06, 0xFC, 0xD0, 0x52, 0xDA, 0x50, 0x6D, 0x62, 0xD8, 0xBD, 0x51, 0x5E, 0x37, 0xBD, 0x08, 0x02, - 0x21, 0x00, 0xBE, 0x2D, 0xB4, 0x7A, 0xAB, 0x33, 0x75, 0x17, 0x8E, 0x12, 0x49, 0xA0, 0x79, 0x20, 0xA0, 0xAC, 0x6E, 0xAA, - 0x39, 0x2F, 0x07, 0xF1, 0x6D, 0x84, 0xFD, 0xCB, 0x52, 0xDB, 0xAF, 0x28, 0xD7, 0xD9 - }; - ByteSpan kDacCert(kDacCertificate); + ByteSpan rcacDer; + err = GetTestCert(TestCert::kRoot01, TestCertLoadFlags::kDERForm, rcacDer); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + ByteSpan icacDer; + err = GetTestCert(TestCert::kICA01, TestCertLoadFlags::kDERForm, icacDer); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - ByteSpan rootCert; - err = GetTestCert(TestCert::kRoot01, TestCertLoadFlags::kDERForm, rootCert); + ByteSpan nocDer; + err = GetTestCert(TestCert::kNode01_01, TestCertLoadFlags::kDERForm, nocDer); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - ByteSpan icaCert; - err = GetTestCert(TestCert::kICA01, TestCertLoadFlags::kDERForm, icaCert); + err = IsCertificateValidAtIssuance(icacDer, nocDer); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - ByteSpan leafCert; - err = GetTestCert(TestCert::kNode01_01, TestCertLoadFlags::kDERForm, leafCert); + err = IsCertificateValidAtIssuance(rcacDer, nocDer); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = IsCertificateValidAtIssuance(leafCert, icaCert); + err = IsCertificateValidAtIssuance(sTestCert_PAI_FFF1_8000_Cert, sTestCert_DAC_FFF1_8000_0004_Cert); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = IsCertificateValidAtIssuance(leafCert, rootCert); + err = IsCertificateValidAtIssuance(sTestCert_PAA_FFF1_Cert, sTestCert_DAC_FFF1_8000_0004_Cert); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = IsCertificateValidAtIssuance(kDacCert, leafCert); + err = IsCertificateValidAtIssuance(sTestCert_PAA_FFF1_Cert, sTestCert_PAI_FFF1_8000_Cert); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Certificate Expired Case + err = IsCertificateValidAtIssuance(icacDer, sTestCert_DAC_FFF1_8000_0004_Cert); + NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_CERT_EXPIRED); + + // Certificate Expired Case + err = IsCertificateValidAtIssuance(rcacDer, sTestCert_DAC_FFF1_8000_0004_Cert); + NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_CERT_EXPIRED); + #if !defined(CURRENT_TIME_NOT_IMPLEMENTED) // test certificate validity (this one contains validity until year 9999 so it will not fail soon) - err = IsCertificateValidAtCurrentTime(kDacCert); + err = IsCertificateValidAtCurrentTime(sTestCert_DAC_FFF2_8001_0008_Cert); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); #endif }