xref: /netbsd-src/crypto/external/bsd/openssl.old/dist/fuzz/crl.c (revision 4724848cf0da353df257f730694b7882798e5daf)
1*4724848cSchristos /*
2*4724848cSchristos  * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3*4724848cSchristos  *
4*4724848cSchristos  * Licensed under the OpenSSL licenses, (the "License");
5*4724848cSchristos  * you may not use this file except in compliance with the License.
6*4724848cSchristos  * You may obtain a copy of the License at
7*4724848cSchristos  * https://www.openssl.org/source/license.html
8*4724848cSchristos  * or in the file LICENSE in the source distribution.
9*4724848cSchristos  */
10*4724848cSchristos 
11*4724848cSchristos #include <openssl/x509.h>
12*4724848cSchristos #include <openssl/bio.h>
13*4724848cSchristos #include <openssl/err.h>
14*4724848cSchristos #include "fuzzer.h"
15*4724848cSchristos 
FuzzerInitialize(int * argc,char *** argv)16*4724848cSchristos int FuzzerInitialize(int *argc, char ***argv)
17*4724848cSchristos {
18*4724848cSchristos     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
19*4724848cSchristos     ERR_get_state();
20*4724848cSchristos     CRYPTO_free_ex_index(0, -1);
21*4724848cSchristos     return 1;
22*4724848cSchristos }
23*4724848cSchristos 
FuzzerTestOneInput(const uint8_t * buf,size_t len)24*4724848cSchristos int FuzzerTestOneInput(const uint8_t *buf, size_t len)
25*4724848cSchristos {
26*4724848cSchristos     const unsigned char *p = buf;
27*4724848cSchristos     unsigned char *der = NULL;
28*4724848cSchristos 
29*4724848cSchristos     X509_CRL *crl = d2i_X509_CRL(NULL, &p, len);
30*4724848cSchristos     if (crl != NULL) {
31*4724848cSchristos         BIO *bio = BIO_new(BIO_s_null());
32*4724848cSchristos         X509_CRL_print(bio, crl);
33*4724848cSchristos         BIO_free(bio);
34*4724848cSchristos 
35*4724848cSchristos         i2d_X509_CRL(crl, &der);
36*4724848cSchristos         OPENSSL_free(der);
37*4724848cSchristos 
38*4724848cSchristos         X509_CRL_free(crl);
39*4724848cSchristos     }
40*4724848cSchristos     ERR_clear_error();
41*4724848cSchristos 
42*4724848cSchristos     return 0;
43*4724848cSchristos }
44*4724848cSchristos 
FuzzerCleanup(void)45*4724848cSchristos void FuzzerCleanup(void)
46*4724848cSchristos {
47*4724848cSchristos }
48