Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2519204

Browse files
tcarmelveilleuxrestyled-commits
authored andcommittedAug 23, 2022
Make PAA trust store configurable (#12277)
* Make PAA store configurable PAA store used by DefaultDeviceAttestationVerifier could not be replaced, forcing a few fixed test roots to always be used and nothing else, unless completely forking the DefaultDeviceAttestationVerifier. - This PR introduces the `PaaRootStore` interface, which the default `DeviceAttestationVerifier` expects to get configured at in constructor. - Examples were modified to use the default test PAA root store - Unit tests updated to use the testing root store - Refactored simple array-based Root store to self-extract the SKID Testing done: added new units tests which pass, ran cert tests, validated attestation succeeds the same as before with test keys. Fixed #11913 * Restyled by clang-format * Address review comments - Rename PaaRootStore to AttestationTrustStore - Add comments about ArrayAttestationtTrustStore lifecycle - Remove debug print * Fix python build * Fix tv-app scoping issue * Attempt to debug Darwin error * Restyled by clang-format * Remove debug logging used to diagnose CI Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 6c130d0 commit 2519204

16 files changed

+314
-128
lines changed
 

‎examples/chip-tool/commands/common/CHIPCommand.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ CHIP_ERROR CHIPCommand::Run()
4545
chip::Platform::ScopedMemoryBuffer<uint8_t> rcac;
4646

4747
chip::Credentials::SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider());
48-
chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier());
48+
49+
// TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available
50+
const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore();
51+
chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier(testingRootStore));
4952

5053
VerifyOrReturnError(noc.Alloc(chip::Controller::kMaxCHIPDERCertLength), CHIP_ERROR_NO_MEMORY);
5154
VerifyOrReturnError(icac.Alloc(chip::Controller::kMaxCHIPDERCertLength), CHIP_ERROR_NO_MEMORY);

‎examples/platform/linux/AppMain.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ CHIP_ERROR InitCommissioner()
234234
ReturnErrorOnFailure(gCommissioner.SetUdcListenPort(LinuxDeviceOptions::GetInstance().unsecuredCommissionerPort));
235235

236236
// Initialize device attestation verifier
237-
SetDeviceAttestationVerifier(GetDefaultDACVerifier());
237+
// TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available
238+
const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore();
239+
SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore));
238240

239241
chip::Platform::ScopedMemoryBuffer<uint8_t> noc;
240242
VerifyOrReturnError(noc.Alloc(chip::Controller::kMaxCHIPDERCertLength), CHIP_ERROR_NO_MEMORY);

‎examples/tv-casting-app/linux/main.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,12 @@ int main(int argc, char * argv[])
195195
// Initialize device attestation config
196196
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
197197

198-
// Initialize device attestation verifier
199-
SetDeviceAttestationVerifier(GetDefaultDACVerifier());
198+
// Initialize device attestation verifier from a constant version
199+
{
200+
// TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available
201+
const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore();
202+
SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore));
203+
}
200204

201205
if (!chip::ArgParser::ParseArgs(argv[0], argc, argv, allOptions))
202206
{

‎src/controller/java/AndroidDeviceControllerWrapper.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(Jav
204204
wrapper->SetJavaObjectRef(vm, deviceControllerObj);
205205

206206
// Initialize device attestation verifier
207-
SetDeviceAttestationVerifier(GetDefaultDACVerifier());
207+
// TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available
208+
const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore();
209+
SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore));
208210

209211
chip::Controller::FactoryInitParams initParams;
210212
chip::Controller::SetupParams setupParams;

‎src/controller/python/ChipDeviceController-ScriptBinding.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ ChipError::StorageType pychip_DeviceController_NewDeviceController(chip::Control
182182
}
183183

184184
// Initialize device attestation verifier
185-
SetDeviceAttestationVerifier(GetDefaultDACVerifier());
185+
// TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available
186+
const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore();
187+
SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore));
186188

187189
CHIP_ERROR err = sOperationalCredentialsIssuer.Initialize(sStorageDelegate);
188190
VerifyOrReturnError(err == CHIP_NO_ERROR, err.AsInteger());

‎src/controller/python/chip/internal/CommissionerImpl.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ extern "C" chip::Controller::DeviceCommissioner * pychip_internal_Commissioner_N
108108
chip::Platform::ScopedMemoryBuffer<uint8_t> rcac;
109109
chip::Crypto::P256Keypair ephemeralKey;
110110

111+
// Initialize device attestation verifier
112+
// TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available
113+
const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore();
114+
chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier(testingRootStore));
115+
111116
err = gFabricStorage.Initialize(&gServerStorage);
112117
SuccessOrExit(err);
113118

@@ -116,9 +121,6 @@ extern "C" chip::Controller::DeviceCommissioner * pychip_internal_Commissioner_N
116121
commissionerParams.pairingDelegate = &gPairingDelegate;
117122
commissionerParams.storageDelegate = &gServerStorage;
118123

119-
// Initialize device attestation verifier
120-
chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier());
121-
122124
err = ephemeralKey.Initialize();
123125
SuccessOrExit(err);
124126

‎src/credentials/CHIPCert.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
namespace chip {
4343
namespace Credentials {
4444

45-
static constexpr uint32_t kKeyIdentifierLength = 20;
45+
static constexpr uint32_t kKeyIdentifierLength = static_cast<uint32_t>(Crypto::kSubjectKeyIdentifierLength);
4646
static constexpr uint32_t kChip32bitAttrUTF8Length = 8;
4747
static constexpr uint32_t kChip64bitAttrUTF8Length = 16;
4848
static constexpr uint16_t kX509NoWellDefinedExpirationDateYear = 9999;

‎src/credentials/DeviceAttestationVerifier.h

+81
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,87 @@ struct DeviceInfoForAttestation
9999
uint16_t paaVendorId = VendorId::NotSpecified;
100100
};
101101

102+
/**
103+
* @brief Helper utility to model a basic trust store usable for device attestation verifiers.
104+
*
105+
* API is synchronous. Real commissioner implementations may entirely
106+
* hide Product Attestation Authority cert lookup behind the DeviceAttestationVerifier and
107+
* never use this interface at all. It is provided as a utility to help build DeviceAttestationVerifier
108+
* implementations suitable for testing or examples.
109+
*/
110+
class AttestationTrustStore
111+
{
112+
public:
113+
AttestationTrustStore() = default;
114+
virtual ~AttestationTrustStore() = default;
115+
116+
// Not copyable
117+
AttestationTrustStore(const AttestationTrustStore &) = delete;
118+
AttestationTrustStore & operator=(const AttestationTrustStore &) = delete;
119+
120+
/**
121+
* @brief Look-up a PAA cert by SKID
122+
*
123+
* The implementations of this interface must have access to a set of PAAs to trust.
124+
*
125+
* Interface is synchronous, and therefore this should not be used unless to expose a PAA
126+
* store that is both fully local and quick to access.
127+
*
128+
* @param[in] skid Buffer containing the subject key identifier (SKID) of the PAA to look-up
129+
* @param[inout] outPaaDerBuffer Buffer to receive the contents of the PAA root cert, if found.
130+
* Size will be updated to match actual size.
131+
*
132+
* @returns CHIP_NO_ERROR on success, CHIP_INVALID_ARGUMENT if `skid` or `outPaaDerBuffer` arguments
133+
* are not usable, CHIP_BUFFER_TOO_SMALL if certificate doesn't fit in `outPaaDerBuffer`
134+
* span, CHIP_ERROR_CA_CERT_NOT_FOUND if no PAA found that matches `skid.
135+
*
136+
*/
137+
virtual CHIP_ERROR GetProductAttestationAuthorityCert(const ByteSpan & skid, MutableByteSpan & outPaaDerBuffer) const = 0;
138+
};
139+
140+
/**
141+
* @brief Basic AttestationTrustStore that holds all data within caller-owned memory.
142+
*
143+
* This is useful to wrap a fixed constant array of certificates into a trust store
144+
* implementation.
145+
*/
146+
147+
class ArrayAttestationTrustStore : public AttestationTrustStore
148+
{
149+
public:
150+
ArrayAttestationTrustStore(const ByteSpan * derCerts, size_t numCerts) : mDerCerts(derCerts), mNumCerts(numCerts) {}
151+
152+
CHIP_ERROR GetProductAttestationAuthorityCert(const ByteSpan & skid, MutableByteSpan & outPaaDerBuffer) const override
153+
{
154+
VerifyOrReturnError(!skid.empty() && (skid.data() != nullptr), CHIP_ERROR_INVALID_ARGUMENT);
155+
VerifyOrReturnError(skid.size() == Crypto::kSubjectKeyIdentifierLength, CHIP_ERROR_INVALID_ARGUMENT);
156+
157+
size_t paaIdx;
158+
ByteSpan candidate;
159+
160+
for (paaIdx = 0; paaIdx < mNumCerts; ++paaIdx)
161+
{
162+
uint8_t skidBuf[Crypto::kSubjectKeyIdentifierLength] = { 0 };
163+
candidate = mDerCerts[paaIdx];
164+
MutableByteSpan candidateSkidSpan{ skidBuf };
165+
VerifyOrReturnError(CHIP_NO_ERROR == Crypto::ExtractSKIDFromX509Cert(candidate, candidateSkidSpan),
166+
CHIP_ERROR_INTERNAL);
167+
168+
if (skid.data_equal(candidateSkidSpan))
169+
{
170+
// Found a match
171+
return CopySpanToMutableSpan(candidate, outPaaDerBuffer);
172+
}
173+
}
174+
175+
return CHIP_ERROR_CA_CERT_NOT_FOUND;
176+
}
177+
178+
protected:
179+
const ByteSpan * mDerCerts;
180+
const size_t mNumCerts;
181+
};
182+
102183
class DeviceAttestationVerifier
103184
{
104185
public:

‎src/credentials/examples/DefaultDeviceAttestationVerifier.cpp

+102-106
Large diffs are not rendered by default.

‎src/credentials/examples/DefaultDeviceAttestationVerifier.h

+19-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,30 @@
2121
namespace chip {
2222
namespace Credentials {
2323

24+
/**
25+
* @brief Get implementation of a PAA root store containing a basic set of static PAA roots
26+
* sufficient for *testing* only.
27+
*
28+
* WARNING: The PAA list known to this PAA root store is a reduced subset that will likely
29+
* cause users of it to fail attestation procedure in some cases. This is provided
30+
* to support tests and examples, not to be used by real commissioners, as it
31+
* contains several test roots which are not trustworthy for certified product usage.
32+
*
33+
* @returns a singleton AttestationTrustStore that contains some well-known PAA test root certs.
34+
*/
35+
const AttestationTrustStore * GetTestAttestationTrustStore();
36+
2437
/**
2538
* @brief Get implementation of a sample DAC verifier to validate device
2639
* attestation procedure.
2740
*
28-
* @returns a singleton DeviceAttestationVerifier that relies on no
29-
* storage abstractions.
41+
* @param[in] paaRootStore Pointer to the AttestationTrustStore instance to be used by implementation
42+
* of default DeviceAttestationVerifier. Caller must ensure storage is
43+
* always available while the DeviceAttestationVerifier could be used.
44+
*
45+
* @returns a singleton DeviceAttestationVerifier that satisfies basic device attestation procedure requirements.
3046
*/
31-
DeviceAttestationVerifier * GetDefaultDACVerifier();
47+
DeviceAttestationVerifier * GetDefaultDACVerifier(const AttestationTrustStore * paaRootStore);
3248

3349
} // namespace Credentials
3450
} // namespace chip

‎src/credentials/tests/TestCertificationDeclaration.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ static void TestCD_CMSSignAndVerify(nlTestSuite * inSuite, void * inContext)
247247
{
248248
ByteSpan cdContentIn(sTestCMS_CDContent01);
249249
ByteSpan cdContentOut;
250-
uint8_t signerKeyIdBuf[kKeyIdentifierLength];
250+
uint8_t signerKeyIdBuf[Crypto::kSubjectKeyIdentifierLength];
251251
MutableByteSpan signerKeyId(signerKeyIdBuf);
252252
uint8_t signedMessageBuf[kMaxCMSSignedCDMessage];
253253
MutableByteSpan signedMessage(signedMessageBuf);
@@ -297,7 +297,7 @@ static void TestCD_CMSVerifyAndExtract(nlTestSuite * inSuite, void * inContext)
297297
NL_TEST_ASSERT(inSuite, testCase.cdContent.data_equal(cdContentOut));
298298

299299
// Test CMS_ExtractKeyId()
300-
uint8_t signerKeyIdBuf[kKeyIdentifierLength];
300+
uint8_t signerKeyIdBuf[Crypto::kSubjectKeyIdentifierLength];
301301
MutableByteSpan signerKeyId(signerKeyIdBuf);
302302
NL_TEST_ASSERT(inSuite, ExtractSKIDFromX509Cert(testCase.signerCert, signerKeyId) == CHIP_NO_ERROR);
303303

‎src/credentials/tests/TestDeviceAttestationCredentials.cpp

+77-3
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ static void TestDACVerifierExample_AttestationInfoVerification(nlTestSuite * inS
195195
default_verifier->VerifyAttestationInformation(ByteSpan(), ByteSpan(), ByteSpan(), ByteSpan(), ByteSpan(), ByteSpan());
196196
NL_TEST_ASSERT(inSuite, attestation_result == AttestationVerificationResult::kNotImplemented);
197197

198-
// Replace default verifier with example verifier
199-
DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier();
198+
DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(GetTestAttestationTrustStore());
200199
NL_TEST_ASSERT(inSuite, example_dac_verifier != nullptr);
201200
NL_TEST_ASSERT(inSuite, default_verifier != example_dac_verifier);
202201

@@ -252,7 +251,7 @@ static void TestDACVerifierExample_CertDeclarationVerification(nlTestSuite * inS
252251
CHIP_ERROR err = CHIP_NO_ERROR;
253252

254253
// Replace default verifier with example verifier
255-
DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier();
254+
DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(GetTestAttestationTrustStore());
256255
NL_TEST_ASSERT(inSuite, example_dac_verifier != nullptr);
257256

258257
SetDeviceAttestationVerifier(example_dac_verifier);
@@ -295,6 +294,80 @@ static void TestDACVerifierExample_CertDeclarationVerification(nlTestSuite * inS
295294
NL_TEST_ASSERT(inSuite, attestation_result == AttestationVerificationResult::kSuccess);
296295
}
297296

297+
static void TestAttestationTrustStore(nlTestSuite * inSuite, void * inContext)
298+
{
299+
uint8_t kPaaFff1Start[] = { 0x30, 0x82, 0x01, 0x99, 0x30, 0x82, 0x01, 0x3F, 0xA0, 0x03, 0x02, 0x01, 0x02,
300+
0x02, 0x08, 0x68, 0x38, 0x4F, 0xAB, 0xB9, 0x19, 0xFC, 0xDF, 0x30, 0x0A, 0x06,
301+
0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x1F, 0x31 };
302+
uint8_t kPaaFff1Skid[] = { 0xEF, 0x18, 0xE0, 0xEC, 0xD4, 0x66, 0x04, 0x34, 0xDF, 0x0D,
303+
0xBC, 0x91, 0x1E, 0xD4, 0x52, 0x16, 0x99, 0x66, 0x83, 0x9F };
304+
305+
uint8_t kPaaFff2Start[] = { 0x30, 0x82, 0x01, 0x9D, 0x30, 0x82, 0x01, 0x42, 0xA0, 0x03, 0x02, 0x01, 0x02,
306+
0x02, 0x08, 0x03, 0x92, 0xA7, 0x65, 0x5A, 0x3E, 0x6C, 0x77, 0x30, 0x0A, 0x06,
307+
0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x1F, 0x31 };
308+
uint8_t kPaaFff2Skid[] = { 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0x5F, 0xD0, 0xC3, 0xE6,
309+
0x34, 0x52, 0x9F, 0x16, 0x70, 0x46, 0xC4, 0xBC, 0xA5, 0x5C };
310+
311+
// SKID to trigger CHIP_ERROR_INVALID_ARGUMENT
312+
uint8_t kPaaBadSkid1[] = { 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0xD0, 0xC3, 0xE6, 0x34,
313+
0x52, 0x9F, 0x16, 0x70, 0x46, 0xC4, 0xBC, 0xA5, 0x5C };
314+
ByteSpan kPaaBadSkidSpan1{ kPaaBadSkid1 };
315+
316+
// SKID to trigger CHIP_ERROR_INVALID_ARGUMENT
317+
ByteSpan kPaaBadSkidSpan2{ nullptr, sizeof(kPaaFff2Skid) };
318+
319+
// SKID to trigger CHIP_ERROR_CA_CERT_NOT_FOUND
320+
uint8_t kPaaGoodSkidNotPresent[] = { 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0x5F, 0xD0, 0xC3, 0xE6,
321+
0x34, 0x52, 0x9F, 0x16, 0x70, 0xFF, 0xFF, 0xBC, 0xA5, 0x5C };
322+
323+
struct TestCase
324+
{
325+
ByteSpan skidSpan;
326+
ByteSpan startSpan;
327+
CHIP_ERROR expectedResult;
328+
};
329+
330+
const TestCase kTestCases[] = {
331+
{ .skidSpan = ByteSpan{ kPaaFff1Skid }, .startSpan = ByteSpan{ kPaaFff1Start }, .expectedResult = CHIP_NO_ERROR },
332+
{ .skidSpan = ByteSpan{ kPaaFff2Skid }, .startSpan = ByteSpan{ kPaaFff2Start }, .expectedResult = CHIP_NO_ERROR },
333+
{ .skidSpan = ByteSpan{ kPaaFff2Skid },
334+
.startSpan = ByteSpan{ kPaaFff2Start },
335+
.expectedResult = CHIP_ERROR_BUFFER_TOO_SMALL },
336+
{ .skidSpan = kPaaBadSkidSpan1, .startSpan = ByteSpan{}, .expectedResult = CHIP_ERROR_INVALID_ARGUMENT },
337+
{ .skidSpan = kPaaBadSkidSpan2, .startSpan = ByteSpan{}, .expectedResult = CHIP_ERROR_INVALID_ARGUMENT },
338+
{ .skidSpan = ByteSpan{ kPaaGoodSkidNotPresent }, .startSpan = ByteSpan{}, .expectedResult = CHIP_ERROR_CA_CERT_NOT_FOUND },
339+
};
340+
341+
const AttestationTrustStore * testAttestationTrustStore = GetTestAttestationTrustStore();
342+
NL_TEST_ASSERT(inSuite, testAttestationTrustStore != nullptr);
343+
344+
size_t testCaseIdx = 0;
345+
for (const auto & testCase : kTestCases)
346+
{
347+
uint8_t buf[kMaxDERCertLength];
348+
MutableByteSpan paaCertSpan{ buf };
349+
if (testCase.expectedResult == CHIP_ERROR_BUFFER_TOO_SMALL)
350+
{
351+
// Make the output much too small if checking for size handling
352+
paaCertSpan = paaCertSpan.SubSpan(0, 16);
353+
}
354+
355+
// Try to obtain cert
356+
CHIP_ERROR result = testAttestationTrustStore->GetProductAttestationAuthorityCert(testCase.skidSpan, paaCertSpan);
357+
NL_TEST_ASSERT(inSuite, result == testCase.expectedResult);
358+
359+
// In success cases, make sure the start of the cert matches expectation. Not using full certs
360+
// to avoid repeating the known constants here.
361+
if (testCase.expectedResult == CHIP_NO_ERROR)
362+
{
363+
NL_TEST_ASSERT(inSuite, paaCertSpan.size() > testCase.startSpan.size());
364+
paaCertSpan = paaCertSpan.SubSpan(0, testCase.startSpan.size());
365+
NL_TEST_ASSERT(inSuite, paaCertSpan.data_equal(testCase.startSpan) == true);
366+
}
367+
++testCaseIdx;
368+
}
369+
}
370+
298371
/**
299372
* Set up the test suite.
300373
*/
@@ -326,6 +399,7 @@ int TestDeviceAttestation_Teardown(void * inContext)
326399
static const nlTest sTests[] = {
327400
NL_TEST_DEF("Test Example Device Attestation Credentials Providers", TestDACProvidersExample_Providers),
328401
NL_TEST_DEF("Test Example Device Attestation Signature", TestDACProvidersExample_Signature),
402+
NL_TEST_DEF("Test the 'for testing' Paa Root Store", TestAttestationTrustStore),
329403
NL_TEST_DEF("Test Example Device Attestation Information Verification", TestDACVerifierExample_AttestationInfoVerification),
330404
NL_TEST_DEF("Test Example Device Attestation Certification Declaration Verification", TestDACVerifierExample_CertDeclarationVerification),
331405
NL_TEST_SENTINEL()

‎src/crypto/CHIPCryptoPAL.h

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ constexpr size_t kP256_ECDSA_Signature_Length_Raw = (2 * kP256_FE_Length);
4646
constexpr size_t kP256_Point_Length = (2 * kP256_FE_Length + 1);
4747
constexpr size_t kSHA256_Hash_Length = 32;
4848
constexpr size_t kSHA1_Hash_Length = 20;
49+
constexpr size_t kSubjectKeyIdentifierLength = kSHA1_Hash_Length;
50+
constexpr size_t kAuthorityKeyIdentifierLength = kSHA1_Hash_Length;
4951

5052
constexpr size_t CHIP_CRYPTO_GROUP_SIZE_BYTES = kP256_FE_Length;
5153
constexpr size_t CHIP_CRYPTO_PUBLIC_KEY_SIZE_BYTES = kP256_Point_Length;

‎src/crypto/tests/CHIPCryptoPALTest.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,7 @@ static void TestSKID_x509Extraction(nlTestSuite * inSuite, void * inContext)
18741874

18751875
HeapChecker heapChecker(inSuite);
18761876
CHIP_ERROR err = CHIP_NO_ERROR;
1877-
uint8_t skidBuf[Credentials::kKeyIdentifierLength];
1877+
uint8_t skidBuf[kSubjectKeyIdentifierLength];
18781878
MutableByteSpan skidOut(skidBuf);
18791879

18801880
ByteSpan cert;
@@ -1901,7 +1901,7 @@ static void TestAKID_x509Extraction(nlTestSuite * inSuite, void * inContext)
19011901

19021902
HeapChecker heapChecker(inSuite);
19031903
CHIP_ERROR err = CHIP_NO_ERROR;
1904-
uint8_t akidBuf[Credentials::kKeyIdentifierLength];
1904+
uint8_t akidBuf[kAuthorityKeyIdentifierLength];
19051905
MutableByteSpan akidOut(akidBuf);
19061906

19071907
ByteSpan cert;

‎src/darwin/Framework/CHIP/CHIPDeviceController.mm

+3-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ - (BOOL)startup:(_Nullable id<CHIPPersistentStorageDelegate>)storageDelegate
190190
}
191191

192192
// Initialize device attestation verifier
193-
chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier());
193+
// TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available
194+
const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore();
195+
chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier(testingRootStore));
194196

195197
params.fabricStorage = _fabricStorage;
196198
commissionerParams.storageDelegate = _persistentStorageDelegateBridge;

‎src/protocols/secure_channel/CASESession.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
namespace chip {
4848

4949
constexpr uint16_t kSigmaParamRandomNumberSize = 32;
50-
constexpr uint16_t kTrustedRootIdSize = Credentials::kKeyIdentifierLength;
50+
constexpr uint16_t kTrustedRootIdSize = Crypto::kSubjectKeyIdentifierLength;
5151
constexpr uint16_t kMaxTrustedRootIds = 5;
5252

5353
constexpr uint16_t kIPKSize = 16;

0 commit comments

Comments
 (0)
Please sign in to comment.