blob: 48f4bb77d96a35c9bf138254b32fff0915b9f6bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* Based on BoringSSL's cert.c fuzzer */
#ifdef __cplusplus
extern "C" {
#endif
#include <openssl/asn1.h>
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <stdint.h>
#include <stdio.h>
#include <hf_ssl_lib.h>
#include <libhfuzz/libhfuzz.h>
int LLVMFuzzerInitialize(int* argc, char*** argv) {
HFInit();
HFResetRand();
return 1;
}
int LLVMFuzzerTestOneInput(const uint8_t* buf, size_t len) {
const uint8_t* b = buf;
X509* x = d2i_X509(NULL, &b, len);
if (x) {
BIO* o = BIO_new_fp(stdout, BIO_NOCLOSE);
X509_print_ex(o, x, XN_FLAG_RFC2253, X509_FLAG_COMPAT);
unsigned char* der = NULL;
i2d_X509(x, &der);
OPENSSL_free(der);
X509_free(x);
BIO_free(o);
}
return 0;
}
#ifdef __cplusplus
}
#endif
|