| 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 |  | 
| Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 6 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) | 
|  | 7 | { | 
| Philippe Antoine | 7233352 | 2018-05-03 16:40:24 +0200 | [diff] [blame] | 8 | #ifdef MBEDTLS_X509_CRT_PARSE_C | 
|  | 9 | int ret; | 
|  | 10 | mbedtls_x509_crt crt; | 
|  | 11 | unsigned char buf[4096]; | 
|  | 12 |  | 
| Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 13 | mbedtls_x509_crt_init(&crt); | 
|  | 14 | ret = mbedtls_x509_crt_parse(&crt, Data, Size); | 
| Hanno Becker | 54ac185 | 2020-10-09 09:45:29 +0100 | [diff] [blame] | 15 | #if !defined(MBEDTLS_X509_REMOVE_INFO) | 
| Philippe Antoine | 7233352 | 2018-05-03 16:40:24 +0200 | [diff] [blame] | 16 | if (ret == 0) { | 
| Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 17 | ret = mbedtls_x509_crt_info((char *) buf, sizeof(buf) - 1, " ", &crt); | 
| Philippe Antoine | 7233352 | 2018-05-03 16:40:24 +0200 | [diff] [blame] | 18 | } | 
| Hanno Becker | 54ac185 | 2020-10-09 09:45:29 +0100 | [diff] [blame] | 19 | #else | 
|  | 20 | ((void) ret); | 
| Hanno Becker | eb2efb0 | 2020-10-16 06:54:39 +0100 | [diff] [blame] | 21 | ((void) buf); | 
| Hanno Becker | 54ac185 | 2020-10-09 09:45:29 +0100 | [diff] [blame] | 22 | #endif /* !MBEDTLS_X509_REMOVE_INFO */ | 
| Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 23 | mbedtls_x509_crt_free(&crt); | 
| Philippe Antoine | 7233352 | 2018-05-03 16:40:24 +0200 | [diff] [blame] | 24 | #else | 
|  | 25 | (void) Data; | 
|  | 26 | (void) Size; | 
|  | 27 | #endif | 
|  | 28 |  | 
|  | 29 | return 0; | 
|  | 30 | } |