blob: e8dacd90b64575e235e557720d60db8934500061 [file] [log] [blame]
Philippe Antoine72333522018-05-03 16:40:24 +02001#include <stdint.h>
2#include "mbedtls/x509_crl.h"
Michael Schuster41a686b2024-06-01 21:08:45 +02003#include "common.h"
Philippe Antoine72333522018-05-03 16:40:24 +02004
Gilles Peskine449bd832023-01-11 14:50:10 +01005int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
6{
Philippe Antoine72333522018-05-03 16:40:24 +02007#ifdef MBEDTLS_X509_CRL_PARSE_C
8 int ret;
9 mbedtls_x509_crl crl;
10 unsigned char buf[4096];
11
Gilles Peskine449bd832023-01-11 14:50:10 +010012 mbedtls_x509_crl_init(&crl);
Przemek Stekiel774f9de2023-04-19 11:47:01 +020013#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 */
Gilles Peskine449bd832023-01-11 14:50:10 +010019 ret = mbedtls_x509_crl_parse(&crl, Data, Size);
Hanno Becker54ac1852020-10-09 09:45:29 +010020#if !defined(MBEDTLS_X509_REMOVE_INFO)
Philippe Antoine72333522018-05-03 16:40:24 +020021 if (ret == 0) {
Gilles Peskine449bd832023-01-11 14:50:10 +010022 ret = mbedtls_x509_crl_info((char *) buf, sizeof(buf) - 1, " ", &crl);
Philippe Antoine72333522018-05-03 16:40:24 +020023 }
Hanno Becker54ac1852020-10-09 09:45:29 +010024#else
25 ((void) ret);
Hanno Beckereb2efb02020-10-16 06:54:39 +010026 ((void) buf);
Hanno Becker54ac1852020-10-09 09:45:29 +010027#endif /* !MBEDTLS_X509_REMOVE_INFO */
Przemek Stekiel758aef62023-04-19 13:47:43 +020028
29#if defined(MBEDTLS_USE_PSA_CRYPTO)
Przemek Stekiel774f9de2023-04-19 11:47:01 +020030exit:
Przemek Stekiel774f9de2023-04-19 11:47:01 +020031 mbedtls_psa_crypto_free();
Przemek Stekiel758aef62023-04-19 13:47:43 +020032#endif /* MBEDTLS_USE_PSA_CRYPTO */
33 mbedtls_x509_crl_free(&crl);
Philippe Antoine72333522018-05-03 16:40:24 +020034#else
35 (void) Data;
36 (void) Size;
37#endif
38
39 return 0;
40}