blob: bd8bdffdb2a1469135949c54dc348d8bd6e7232f [file] [log] [blame]
Mateusz Starzyk6c2e9b62021-05-19 17:54:54 +02001#define MBEDTLS_ALLOW_PRIVATE_ACCESS
2
Philippe Antoine72333522018-05-03 16:40:24 +02003#include <stdint.h>
4#include "mbedtls/x509_crt.h"
5
6int 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 Becker54ac1852020-10-09 09:45:29 +010014#if !defined(MBEDTLS_X509_REMOVE_INFO)
Philippe Antoine72333522018-05-03 16:40:24 +020015 if (ret == 0) {
16 ret = mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", &crt );
17 }
Hanno Becker54ac1852020-10-09 09:45:29 +010018#else
19 ((void) ret);
Hanno Beckereb2efb02020-10-16 06:54:39 +010020 ((void) buf);
Hanno Becker54ac1852020-10-09 09:45:29 +010021#endif /* !MBEDTLS_X509_REMOVE_INFO */
Philippe Antoine72333522018-05-03 16:40:24 +020022 mbedtls_x509_crt_free( &crt );
23#else
24 (void) Data;
25 (void) Size;
26#endif
27
28 return 0;
29}