1 1.1 christos /* 2 1.1.1.4 christos * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the OpenSSL licenses, (the "License"); 5 1.1 christos * you may not use this file except in compliance with the License. 6 1.1 christos * You may obtain a copy of the License at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos * or in the file LICENSE in the source distribution. 9 1.1 christos */ 10 1.1 christos 11 1.1 christos #include <openssl/x509.h> 12 1.1 christos #include <openssl/bio.h> 13 1.1.1.2 christos #include <openssl/err.h> 14 1.1.1.2 christos #include <openssl/rand.h> 15 1.1 christos #include "fuzzer.h" 16 1.1 christos 17 1.1.1.2 christos #include "rand.inc" 18 1.1.1.2 christos 19 1.1.1.2 christos int FuzzerInitialize(int *argc, char ***argv) 20 1.1.1.2 christos { 21 1.1.1.2 christos OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); 22 1.1.1.2 christos ERR_get_state(); 23 1.1.1.2 christos CRYPTO_free_ex_index(0, -1); 24 1.1.1.2 christos FuzzerSetRand(); 25 1.1 christos return 1; 26 1.1 christos } 27 1.1 christos 28 1.1.1.2 christos int FuzzerTestOneInput(const uint8_t *buf, size_t len) 29 1.1.1.2 christos { 30 1.1 christos const unsigned char *p = buf; 31 1.1 christos unsigned char *der = NULL; 32 1.1 christos 33 1.1 christos X509 *x509 = d2i_X509(NULL, &p, len); 34 1.1 christos if (x509 != NULL) { 35 1.1 christos BIO *bio = BIO_new(BIO_s_null()); 36 1.1 christos /* This will load and print the public key as well as extensions */ 37 1.1 christos X509_print(bio, x509); 38 1.1 christos BIO_free(bio); 39 1.1 christos 40 1.1.1.3 christos X509_issuer_and_serial_hash(x509); 41 1.1.1.3 christos 42 1.1 christos i2d_X509(x509, &der); 43 1.1 christos OPENSSL_free(der); 44 1.1 christos 45 1.1 christos X509_free(x509); 46 1.1 christos } 47 1.1.1.2 christos ERR_clear_error(); 48 1.1 christos return 0; 49 1.1 christos } 50 1.1.1.2 christos 51 1.1.1.2 christos void FuzzerCleanup(void) 52 1.1.1.2 christos { 53 1.1.1.2 christos } 54