1a8e1175bSopenharmony_ci#include <stdint.h> 2a8e1175bSopenharmony_ci#include "mbedtls/x509_csr.h" 3a8e1175bSopenharmony_ci 4a8e1175bSopenharmony_ciint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) 5a8e1175bSopenharmony_ci{ 6a8e1175bSopenharmony_ci#ifdef MBEDTLS_X509_CSR_PARSE_C 7a8e1175bSopenharmony_ci int ret; 8a8e1175bSopenharmony_ci mbedtls_x509_csr csr; 9a8e1175bSopenharmony_ci unsigned char buf[4096]; 10a8e1175bSopenharmony_ci 11a8e1175bSopenharmony_ci mbedtls_x509_csr_init(&csr); 12a8e1175bSopenharmony_ci#if defined(MBEDTLS_USE_PSA_CRYPTO) 13a8e1175bSopenharmony_ci psa_status_t status = psa_crypto_init(); 14a8e1175bSopenharmony_ci if (status != PSA_SUCCESS) { 15a8e1175bSopenharmony_ci goto exit; 16a8e1175bSopenharmony_ci } 17a8e1175bSopenharmony_ci#endif /* MBEDTLS_USE_PSA_CRYPTO */ 18a8e1175bSopenharmony_ci ret = mbedtls_x509_csr_parse(&csr, Data, Size); 19a8e1175bSopenharmony_ci#if !defined(MBEDTLS_X509_REMOVE_INFO) 20a8e1175bSopenharmony_ci if (ret == 0) { 21a8e1175bSopenharmony_ci ret = mbedtls_x509_csr_info((char *) buf, sizeof(buf) - 1, " ", &csr); 22a8e1175bSopenharmony_ci } 23a8e1175bSopenharmony_ci#else 24a8e1175bSopenharmony_ci ((void) ret); 25a8e1175bSopenharmony_ci ((void) buf); 26a8e1175bSopenharmony_ci#endif /* !MBEDTLS_X509_REMOVE_INFO */ 27a8e1175bSopenharmony_ci 28a8e1175bSopenharmony_ci#if defined(MBEDTLS_USE_PSA_CRYPTO) 29a8e1175bSopenharmony_ciexit: 30a8e1175bSopenharmony_ci mbedtls_psa_crypto_free(); 31a8e1175bSopenharmony_ci#endif /* MBEDTLS_USE_PSA_CRYPTO */ 32a8e1175bSopenharmony_ci mbedtls_x509_csr_free(&csr); 33a8e1175bSopenharmony_ci#else 34a8e1175bSopenharmony_ci (void) Data; 35a8e1175bSopenharmony_ci (void) Size; 36a8e1175bSopenharmony_ci#endif 37a8e1175bSopenharmony_ci 38a8e1175bSopenharmony_ci return 0; 39a8e1175bSopenharmony_ci} 40