Skip to content

Commit

Permalink
Impove CD validation (#29664)
Browse files Browse the repository at this point in the history
We currently peform validation against PAA checks in encoding.  In decoding, we check for cryptographic validity,
but do not perform the same checks againts the data.  This commit brings the encoding and decoding into parity.
  • Loading branch information
robszewczyk authored and pull[bot] committed Jan 9, 2024
1 parent 628e7be commit 5ef7d3e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/credentials/CertificationDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ CHIP_ERROR DecodeCertificationElements(const ByteSpan & encodedCertElements, Cer
certElements.ProductIdsCount = 0;
while ((err = reader.Next(AnonymousTag())) == CHIP_NO_ERROR)
{
VerifyOrReturnError(certElements.ProductIdsCount < kMaxProductIdsCount, CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorOnFailure(reader.Get(certElements.ProductIds[certElements.ProductIdsCount++]));
}
VerifyOrReturnError(err == CHIP_END_OF_TLV, err);
Expand Down Expand Up @@ -194,6 +195,7 @@ CHIP_ERROR DecodeCertificationElements(const ByteSpan & encodedCertElements, Cer
while ((err = reader.Next(kTLVType_ByteString, AnonymousTag())) == CHIP_NO_ERROR)
{
VerifyOrReturnError(reader.GetLength() == kKeyIdentifierLength, CHIP_ERROR_UNEXPECTED_TLV_ELEMENT);
VerifyOrReturnError(certElements.AuthorizedPAAListCount < kMaxAuthorizedPAAListCount, CHIP_ERROR_INVALID_ARGUMENT);

ReturnErrorOnFailure(
reader.GetBytes(certElements.AuthorizedPAAList[certElements.AuthorizedPAAListCount++], kKeyIdentifierLength));
Expand Down

0 comments on commit 5ef7d3e

Please sign in to comment.