From a573952507815e5a6425147367db98e358543659 Mon Sep 17 00:00:00 2001 From: Jandy Gou Date: Tue, 21 Jun 2022 21:45:57 +0800 Subject: [PATCH] [crypto]fix build when MBEDTLS_X509_CSR_WRITE_C not configure (#19754) add MBEDTLS_X509_CSR_WRITE_C conditional build Signed-off-by: Qingsong Gou --- src/crypto/CHIPCryptoPALmbedTLS.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crypto/CHIPCryptoPALmbedTLS.cpp b/src/crypto/CHIPCryptoPALmbedTLS.cpp index c83ac6124ba78e..140794d727663e 100644 --- a/src/crypto/CHIPCryptoPALmbedTLS.cpp +++ b/src/crypto/CHIPCryptoPALmbedTLS.cpp @@ -1036,6 +1036,7 @@ P256Keypair::~P256Keypair() CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & csr_length) const { +#if defined(MBEDTLS_X509_CSR_WRITE_C) CHIP_ERROR error = CHIP_NO_ERROR; int result = 0; size_t out_length; @@ -1083,6 +1084,10 @@ CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & _log_mbedTLS_error(result); return error; +#else + ChipLogError(Crypto, "MBEDTLS_X509_CSR_WRITE_C is not enabled. CSR cannot be created"); + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +#endif } CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr_buf, size_t csr_length, P256PublicKey & pubkey)