|
Packit Service |
084de1 |
/*
|
|
Packit Service |
084de1 |
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
|
Packit Service |
084de1 |
*
|
|
Packit Service |
084de1 |
* Licensed under the OpenSSL licenses, (the "License");
|
|
Packit Service |
084de1 |
* you may not use this file except in compliance with the License.
|
|
Packit Service |
084de1 |
* You may obtain a copy of the License at
|
|
Packit Service |
084de1 |
* https://www.openssl.org/source/license.html
|
|
Packit Service |
084de1 |
* or in the file LICENSE in the source distribution.
|
|
Packit Service |
084de1 |
*/
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
/*
|
|
Packit Service |
084de1 |
* Fuzz the parser used for dumping ASN.1 using "openssl asn1parse".
|
|
Packit Service |
084de1 |
*/
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#include <stdio.h>
|
|
Packit Service |
084de1 |
#include <openssl/asn1.h>
|
|
Packit Service |
084de1 |
#include <openssl/x509.h>
|
|
Packit Service |
084de1 |
#include <openssl/x509v3.h>
|
|
Packit Service |
084de1 |
#include <openssl/err.h>
|
|
Packit Service |
084de1 |
#include "fuzzer.h"
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
static BIO *bio_out;
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
int FuzzerInitialize(int *argc, char ***argv)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
bio_out = BIO_new_file("/dev/null", "w");
|
|
Packit Service |
084de1 |
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
|
Packit Service |
084de1 |
ERR_get_state();
|
|
Packit Service |
084de1 |
CRYPTO_free_ex_index(0, -1);
|
|
Packit Service |
084de1 |
return 1;
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
(void)ASN1_parse_dump(bio_out, buf, len, 0, 0);
|
|
Packit Service |
084de1 |
ERR_clear_error();
|
|
Packit Service |
084de1 |
return 0;
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
void FuzzerCleanup(void)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
BIO_free(bio_out);
|
|
Packit Service |
084de1 |
}
|