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