Skip to content

Commit 8d8de11

Browse files
authored
[crypto] Validate CSR subject key type on mbedTLS backend (project-chip#73112)
VerifyCertificateSigningRequest() on the pre-4.0 mbedTLS backend did not validate the subject public key type before extracting it. Add that validation so it matches the PSA / mbedTLS 4.0 path, which validates the subject key type during mbedtls_pk_import_into_psa().
1 parent 99c3ddd commit 8d8de11

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/crypto/CHIPCryptoPALmbedTLSCert.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr_buf, size_t csr_l
9999
#else
100100
{
101101
mbedtls_ecp_keypair * keypair = mbedtls_pk_ec(csr.CHIP_CRYPTO_PAL_PRIVATE_X509(pk));
102+
VerifyOrExit(keypair != nullptr, error = CHIP_ERROR_WRONG_KEY_TYPE);
102103

103104
// Copy the public key from the CSR
104105
result =

0 commit comments

Comments
 (0)