Mateusz Starzyk | 6c2e9b6 | 2021-05-19 17:54:54 +0200 | [diff] [blame] | 1 | #define MBEDTLS_ALLOW_PRIVATE_ACCESS |
| 2 | |
Philippe Antoine | 7233352 | 2018-05-03 16:40:24 +0200 | [diff] [blame] | 3 | #include <stdint.h> |
| 4 | #include "mbedtls/x509_crt.h" |
| 5 | |
| 6 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 7 | #ifdef MBEDTLS_X509_CRT_PARSE_C |
| 8 | int ret; |
| 9 | mbedtls_x509_crt crt; |
| 10 | unsigned char buf[4096]; |
| 11 | |
| 12 | mbedtls_x509_crt_init( &crt ); |
| 13 | ret = mbedtls_x509_crt_parse( &crt, Data, Size ); |
Hanno Becker | 54ac185 | 2020-10-09 09:45:29 +0100 | [diff] [blame] | 14 | #if !defined(MBEDTLS_X509_REMOVE_INFO) |
Philippe Antoine | 7233352 | 2018-05-03 16:40:24 +0200 | [diff] [blame] | 15 | if (ret == 0) { |
| 16 | ret = mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", &crt ); |
| 17 | } |
Hanno Becker | 54ac185 | 2020-10-09 09:45:29 +0100 | [diff] [blame] | 18 | #else |
| 19 | ((void) ret); |
Hanno Becker | eb2efb0 | 2020-10-16 06:54:39 +0100 | [diff] [blame] | 20 | ((void) buf); |
Hanno Becker | 54ac185 | 2020-10-09 09:45:29 +0100 | [diff] [blame] | 21 | #endif /* !MBEDTLS_X509_REMOVE_INFO */ |
Philippe Antoine | 7233352 | 2018-05-03 16:40:24 +0200 | [diff] [blame] | 22 | mbedtls_x509_crt_free( &crt ); |
| 23 | #else |
| 24 | (void) Data; |
| 25 | (void) Size; |
| 26 | #endif |
| 27 | |
| 28 | return 0; |
| 29 | } |