third_party/boringssl-with-bazel/src/fuzz/cert.cc
Go to the documentation of this file.
1 /* Copyright (c) 2016, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #include <openssl/err.h>
16 #include <openssl/mem.h>
17 #include <openssl/x509.h>
18 
19 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
20  X509 *x509 = d2i_X509(NULL, &buf, len);
21  if (x509 != NULL) {
22  // Extract the public key.
24 
25  // Reserialize the structure.
26  uint8_t *der = NULL;
27  i2d_X509(x509, &der);
28  OPENSSL_free(der);
29 
30  BIO *bio = BIO_new(BIO_s_mem());
31  X509_print(bio, x509);
32  BIO_free(bio);
33  }
34  X509_free(x509);
36  return 0;
37 }
bio_st
Definition: bio.h:822
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
i2d_X509
#define i2d_X509
Definition: boringssl_prefix_symbols.h:3274
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
X509_free
#define X509_free
Definition: boringssl_prefix_symbols.h:2632
X509_get_pubkey
#define X509_get_pubkey
Definition: boringssl_prefix_symbols.h:2669
BIO_s_mem
#define BIO_s_mem
Definition: boringssl_prefix_symbols.h:839
X509_print
#define X509_print
Definition: boringssl_prefix_symbols.h:2701
EVP_PKEY_free
#define EVP_PKEY_free
Definition: boringssl_prefix_symbols.h:1625
err.h
BIO_new
#define BIO_new
Definition: boringssl_prefix_symbols.h:814
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
Definition: third_party/boringssl-with-bazel/src/fuzz/cert.cc:19
d2i_X509
#define d2i_X509
Definition: boringssl_prefix_symbols.h:3031
BIO_free
#define BIO_free
Definition: boringssl_prefix_symbols.h:787
x509_st
Definition: third_party/boringssl-with-bazel/src/crypto/x509/internal.h:139
ERR_clear_error
#define ERR_clear_error
Definition: boringssl_prefix_symbols.h:1413
mem.h
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
OPENSSL_free
#define OPENSSL_free
Definition: boringssl_prefix_symbols.h:1869
x509.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:52