Skip to content

Commit

Permalink
Simplify CertificationDeclaration EncodeSignerInfo (#31087)
Browse files Browse the repository at this point in the history
... by using ConvertECDSASignatureRawToDER which directly integrates with
the ASN.1 writer rather than EcdsaRawSignatureToAsn1 from CHIPCryptoPAL.
Also make the same change in the chip-cert gen-cd command.
  • Loading branch information
ksperling-apple authored and pull[bot] committed Apr 16, 2024
1 parent 303ce51 commit cce5761
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/credentials/CertificationDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,12 @@ CHIP_ERROR EncodeSignerInfo(const ByteSpan & signerKeyId, const P256ECDSASignatu
}
ASN1_END_SEQUENCE;

uint8_t asn1SignatureBuf[kMax_ECDSA_Signature_Length_Der];
MutableByteSpan asn1Signature(asn1SignatureBuf);
ReturnErrorOnFailure(EcdsaRawSignatureToAsn1(kP256_FE_Length, signature.Span(), asn1Signature));

// signature OCTET STRING
ReturnErrorOnFailure(writer.PutOctetString(asn1Signature.data(), static_cast<uint16_t>(asn1Signature.size())));
ASN1_START_OCTET_STRING_ENCAPSULATED
{
ReturnErrorOnFailure(ConvertECDSASignatureRawToDER(P256ECDSASignatureSpan(signature.ConstBytes()), writer));
}
ASN1_END_ENCAPSULATED;
}
ASN1_END_SEQUENCE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/chip-cert/Cmd_GenCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ CHIP_ERROR EncodeSignerInfo_Ignor_Error(const ByteSpan & signerKeyId, const P256

uint8_t asn1SignatureBuf[kMax_ECDSA_Signature_Length_Der];
MutableByteSpan asn1Signature(asn1SignatureBuf);
ReturnErrorOnFailure(EcdsaRawSignatureToAsn1(kP256_FE_Length, signature.Span(), asn1Signature));
ReturnErrorOnFailure(ConvertECDSASignatureRawToDER(P256ECDSASignatureSpan(signature.ConstBytes()), asn1Signature));

if (!cdConfig.IsCMSSignatureCorrect())
{
Expand Down

0 comments on commit cce5761

Please sign in to comment.