2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL licenses, (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.openssl.org/source/license.html
8 * or in the file LICENSE in the source distribution.
12 * Fuzz ASN.1 parsing for various data structures. Specify which on the
15 * asn1 <data structure>
20 #include <openssl/asn1.h>
21 #include <openssl/asn1t.h>
22 #include <openssl/ec.h>
23 #include <openssl/ocsp.h>
24 #include <openssl/pkcs12.h>
25 #include <openssl/ts.h>
26 #include <openssl/x509v3.h>
29 static const ASN1_ITEM *item_type;
31 int LLVMFuzzerInitialize(int *argc, char ***argv) {
33 OPENSSL_assert(*argc > 1);
36 (*argv)[1] = (*argv)[0];
40 // TODO: make this work like d2i_test.c does, once its decided what the
42 #define Y(t) if (!strcmp(cmd, #t)) item_type = ASN1_ITEM_rptr(t)
43 #define X(t) else Y(t)
46 X(AUTHORITY_INFO_ACCESS);
66 X(PKCS7_SIGN_ENVELOPE);
69 X(POLICY_CONSTRAINTS);
72 //X(TS_RESP); want to do this, but type is hidden, however d2i exists...
76 OPENSSL_assert(!"Bad type");
81 int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
82 const uint8_t *b = buf;
83 ASN1_VALUE *o = ASN1_item_d2i(NULL, &b, len, item_type);
84 ASN1_item_free(o, item_type);