Skip to content

Commit

Permalink
Check Value Returned by BN_bn2binpad() (#18699)
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis authored and pull[bot] committed Nov 22, 2023
1 parent 4616287 commit 1607364
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/crypto/CHIPCryptoPALOpenSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,9 @@ CHIP_ERROR P256Keypair::ECDSA_sign_hash(const uint8_t * hash, const size_t hash_

// Concatenate r and s to output. Sizes were checked above.
VerifyOrExit(out_signature.SetLength(kP256_ECDSA_Signature_Length_Raw) == CHIP_NO_ERROR, error = CHIP_ERROR_INTERNAL);
BN_bn2binpad(r, out_signature.Bytes() + 0u, kP256_FE_Length);
BN_bn2binpad(s, out_signature.Bytes() + kP256_FE_Length, kP256_FE_Length);
VerifyOrExit(BN_bn2binpad(r, out_signature.Bytes() + 0u, kP256_FE_Length) == kP256_FE_Length, error = CHIP_ERROR_INTERNAL);
VerifyOrExit(BN_bn2binpad(s, out_signature.Bytes() + kP256_FE_Length, kP256_FE_Length) == kP256_FE_Length,
error = CHIP_ERROR_INTERNAL);

exit:
if (sig != nullptr)
Expand Down

0 comments on commit 1607364

Please sign in to comment.