boringssl/fuzz/cert.cc
David Benjamin 66ec5c9066 Also re-serialize X509 objects in fuzz/cert.cc.
This is a fairly common operation on an X509.

Change-Id: I1820f20b555f75c98ab7e3283b5530bc1c200e2a
Reviewed-on: https://boringssl-review.googlesource.com/7611
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2016-03-31 19:37:53 +00:00

19 lines
437 B
C++

#include <openssl/mem.h>
#include <openssl/x509.h>
extern "C" int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len) {
const uint8_t *bufp = buf;
X509 *x509 = d2i_X509(NULL, &bufp, len);
if (x509 != NULL) {
/* Extract the public key. */
EVP_PKEY_free(X509_get_pubkey(x509));
/* Reserialize the structure. */
uint8_t *der = NULL;
i2d_X509(x509, &der);
OPENSSL_free(der);
}
X509_free(x509);
return 0;
}