/src/mbedtls/programs/fuzz/fuzz_x509crt.c
Line | Count | Source |
1 | | #include <stdint.h> |
2 | | #include "mbedtls/x509_crt.h" |
3 | | #include "common.h" |
4 | | |
5 | | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) |
6 | 12.9k | { |
7 | 12.9k | #ifdef MBEDTLS_X509_CRT_PARSE_C |
8 | 12.9k | int ret; |
9 | 12.9k | mbedtls_x509_crt crt; |
10 | 12.9k | unsigned char buf[4096]; |
11 | | |
12 | 12.9k | mbedtls_x509_crt_init(&crt); |
13 | | #if defined(MBEDTLS_USE_PSA_CRYPTO) |
14 | | psa_status_t status = psa_crypto_init(); |
15 | 6 | if (status != PSA_SUCCESS) { |
16 | 6 | goto exit; |
17 | 6 | } |
18 | 0 | #endif /* MBEDTLS_USE_PSA_CRYPTO */ |
19 | 0 | ret = mbedtls_x509_crt_parse(&crt, Data, Size); |
20 | 0 | #if !defined(MBEDTLS_X509_REMOVE_INFO) |
21 | 12.9k | if (ret == 0) { |
22 | 1.07k | ret = mbedtls_x509_crt_info((char *) buf, sizeof(buf) - 1, " ", &crt); |
23 | 1.07k | } |
24 | | #else |
25 | | ((void) ret); |
26 | | ((void) buf); |
27 | | #endif /* !MBEDTLS_X509_REMOVE_INFO */ |
28 | |
|
29 | | #if defined(MBEDTLS_USE_PSA_CRYPTO) |
30 | 6 | exit: |
31 | 6 | mbedtls_psa_crypto_free(); |
32 | 6 | #endif /* MBEDTLS_USE_PSA_CRYPTO */ |
33 | 6 | mbedtls_x509_crt_free(&crt); |
34 | | #else |
35 | | (void) Data; |
36 | | (void) Size; |
37 | | #endif |
38 | | |
39 | 6 | return 0; |
40 | 0 | } Line | Count | Source | 6 | 6 | { | 7 | 6 | #ifdef MBEDTLS_X509_CRT_PARSE_C | 8 | 6 | int ret; | 9 | 6 | mbedtls_x509_crt crt; | 10 | 6 | unsigned char buf[4096]; | 11 | | | 12 | 6 | mbedtls_x509_crt_init(&crt); | 13 | 6 | #if defined(MBEDTLS_USE_PSA_CRYPTO) | 14 | 6 | psa_status_t status = psa_crypto_init(); | 15 | 6 | if (status != PSA_SUCCESS) { | 16 | 6 | goto exit; | 17 | 6 | } | 18 | 0 | #endif /* MBEDTLS_USE_PSA_CRYPTO */ | 19 | 0 | ret = mbedtls_x509_crt_parse(&crt, Data, Size); | 20 | 0 | #if !defined(MBEDTLS_X509_REMOVE_INFO) | 21 | 0 | if (ret == 0) { | 22 | 0 | ret = mbedtls_x509_crt_info((char *) buf, sizeof(buf) - 1, " ", &crt); | 23 | 0 | } | 24 | | #else | 25 | | ((void) ret); | 26 | | ((void) buf); | 27 | | #endif /* !MBEDTLS_X509_REMOVE_INFO */ | 28 | |
| 29 | 0 | #if defined(MBEDTLS_USE_PSA_CRYPTO) | 30 | 6 | exit: | 31 | 6 | mbedtls_psa_crypto_free(); | 32 | 6 | #endif /* MBEDTLS_USE_PSA_CRYPTO */ | 33 | 6 | mbedtls_x509_crt_free(&crt); | 34 | | #else | 35 | | (void) Data; | 36 | | (void) Size; | 37 | | #endif | 38 | | | 39 | 6 | return 0; | 40 | 0 | } |
Line | Count | Source | 6 | 12.9k | { | 7 | 12.9k | #ifdef MBEDTLS_X509_CRT_PARSE_C | 8 | 12.9k | int ret; | 9 | 12.9k | mbedtls_x509_crt crt; | 10 | 12.9k | unsigned char buf[4096]; | 11 | | | 12 | 12.9k | mbedtls_x509_crt_init(&crt); | 13 | | #if defined(MBEDTLS_USE_PSA_CRYPTO) | 14 | | psa_status_t status = psa_crypto_init(); | 15 | | if (status != PSA_SUCCESS) { | 16 | | goto exit; | 17 | | } | 18 | | #endif /* MBEDTLS_USE_PSA_CRYPTO */ | 19 | 12.9k | ret = mbedtls_x509_crt_parse(&crt, Data, Size); | 20 | 12.9k | #if !defined(MBEDTLS_X509_REMOVE_INFO) | 21 | 12.9k | if (ret == 0) { | 22 | 1.07k | ret = mbedtls_x509_crt_info((char *) buf, sizeof(buf) - 1, " ", &crt); | 23 | 1.07k | } | 24 | | #else | 25 | | ((void) ret); | 26 | | ((void) buf); | 27 | | #endif /* !MBEDTLS_X509_REMOVE_INFO */ | 28 | | | 29 | | #if defined(MBEDTLS_USE_PSA_CRYPTO) | 30 | | exit: | 31 | | mbedtls_psa_crypto_free(); | 32 | | #endif /* MBEDTLS_USE_PSA_CRYPTO */ | 33 | 12.9k | mbedtls_x509_crt_free(&crt); | 34 | | #else | 35 | | (void) Data; | 36 | | (void) Size; | 37 | | #endif | 38 | | | 39 | 12.9k | return 0; | 40 | 12.9k | } |
|