Skip to content

Commit

Permalink
Add two additional CD checks, fix test, add comments (#28789)
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille authored and pull[bot] committed Nov 27, 2023
1 parent d3e696a commit d6a1760
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/credentials/CertificationDeclaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ struct CertificationElementsWithoutPIDs
char certificateId[kCertificateIdLength + 1] = { 0 };
};

enum class CertificationType : uint8_t
{
kDevelopmentAndTest,
kProvisional,
kOfficial,
kReserved,
};

class CertificationElementsDecoder
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,14 @@ AttestationVerificationResult DefaultDACVerifier::ValidateCertificateDeclaration
// TODO: validate contents based on DCL
}

// Verify the cd elements are as required by the spec
// security_level, security_information are meant to be ignored. version_number is not meant to be interpreted by the
// commissioners.
if (cdContent.formatVersion != 1 || cdContent.certificationType >= chip::to_underlying(CertificationType::kReserved))
{
return AttestationVerificationResult::kAttestationElementsMalformed;
}

// The vendor_id field in the Certification Declaration SHALL match the VendorID attribute found in the Basic Information
// cluster
VerifyOrReturnError(cdContent.vendorId == deviceInfo.vendorId,
Expand Down
14 changes: 11 additions & 3 deletions src/credentials/tests/TestCommissionerDUTVectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,18 @@ static void TestCommissionerDUTVectors(nlTestSuite * inSuite, void * inContext)
example_dac_verifier->VerifyAttestationInformation(info, &attestationInformationVerificationCallback);

bool isSuccessCase = dacProvider.IsSuccessCase();
// The DefaultDACVerifier doesn't currently check validity of CD elements values.
// The following test vectors are success conditions for an SDK commissioner for the following reasons:
// struct_cd_device_type_id_mismatch - requires DCL access, which the SDK does not have and is not required
// struct_cd_security_info_wrong - while devices are required to set this to 0, commissioners are required to ignore it
// (see 6.3.1)
// hence this is marked as a failure for devices, but should be a success case for
// commissioners
// struct_cd_security_level_wrong - as with security info, commissioners are required to ignore this value (see 6.3.1)
// struct_cd_version_number_wrong - this value is not meant to be interpreted by commissioners, so errors here should be
// ignored (6.3.1)
// struct_cd_cert_id_mismatch - requires DCL access, which the SDK does not have and is not required.
if (strstr(entry->d_name, "struct_cd_device_type_id_mismatch") || strstr(entry->d_name, "struct_cd_security_info_wrong") ||
strstr(entry->d_name, "struct_cd_cert_type_wrong") || strstr(entry->d_name, "struct_cd_security_level_wrong") ||
strstr(entry->d_name, "struct_cd_version_number_wrong") || strstr(entry->d_name, "struct_cd_format_version_2") ||
strstr(entry->d_name, "struct_cd_security_level_wrong") || strstr(entry->d_name, "struct_cd_version_number_wrong") ||
strstr(entry->d_name, "struct_cd_cert_id_mismatch"))
{
isSuccessCase = true;
Expand Down

0 comments on commit d6a1760

Please sign in to comment.