Skip to content

Commit

Permalink
Impove CD validation (project-chip#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 Oct 10, 2023
1 parent 11c3dec commit 596741a
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 596741a

Please sign in to comment.