From 8f089a9f767a0af10a2293b944da8835ba34a6e9 Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Thu, 18 Nov 2021 12:30:36 -0500 Subject: [PATCH] Add mandatory existence of timestamp --- src/credentials/DeviceAttestationConstructor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/credentials/DeviceAttestationConstructor.cpp b/src/credentials/DeviceAttestationConstructor.cpp index 4d301dc6852f82..4d5949ffa9699a 100644 --- a/src/credentials/DeviceAttestationConstructor.cpp +++ b/src/credentials/DeviceAttestationConstructor.cpp @@ -67,6 +67,7 @@ CHIP_ERROR DeconstructAttestationElements(const ByteSpan & attestationElements, { bool certificationDeclarationExists = false; bool attestationNonceExists = false; + bool timestampExists = false; bool gotFirstContextTag = false; uint32_t lastContextTagId = 0; @@ -117,6 +118,7 @@ CHIP_ERROR DeconstructAttestationElements(const ByteSpan & attestationElements, break; case kTimestampTagId: ReturnErrorOnFailure(tlvReader.Get(timestamp)); + timestampExists = true; break; case kFirmwareInfoTagId: ReturnErrorOnFailure(tlvReader.GetByteView(firmwareInfo)); @@ -130,7 +132,7 @@ CHIP_ERROR DeconstructAttestationElements(const ByteSpan & attestationElements, VerifyOrReturnError(error == CHIP_NO_ERROR || error == CHIP_END_OF_TLV, error); - const bool allTagsNeededPresent = certificationDeclarationExists && attestationNonceExists; + const bool allTagsNeededPresent = certificationDeclarationExists && attestationNonceExists && timestampExists; VerifyOrReturnError(allTagsNeededPresent, CHIP_ERROR_MISSING_TLV_ELEMENT); size_t count = 0;