Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device Attestation: Add two additional CD checks, fix test, add comments #28789

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading