decode_client_hello_inner.cc
Go to the documentation of this file.
1 /* Copyright (c) 2021, 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/bytestring.h>
16 #include <openssl/ssl.h>
17 #include <openssl/span.h>
18 
19 #include "../ssl/internal.h"
20 
21 
22 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
23  static bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method()));
24  static bssl::UniquePtr<SSL> ssl(SSL_new(ctx.get()));
25 
27  CBS encoded_client_hello_inner_cbs;
28 
29  if (!CBS_get_u24_length_prefixed(&reader, &encoded_client_hello_inner_cbs)) {
30  return 0;
31  }
32 
33  bssl::Array<uint8_t> encoded_client_hello_inner;
34  if (!encoded_client_hello_inner.CopyFrom(encoded_client_hello_inner_cbs)) {
35  return 0;
36  }
37 
38  // Use the remaining bytes in |reader| as the ClientHelloOuter.
39  SSL_CLIENT_HELLO client_hello_outer;
40  if (!bssl::ssl_client_hello_init(ssl.get(), &client_hello_outer, reader)) {
41  return 0;
42  }
43 
44  // Recover the ClientHelloInner from the EncodedClientHelloInner and
45  // ClientHelloOuter.
46  uint8_t alert_unused;
47  bssl::Array<uint8_t> client_hello_inner;
49  ssl.get(), &alert_unused, &client_hello_inner, encoded_client_hello_inner,
50  &client_hello_outer);
51  return 0;
52 }
CBS_get_u24_length_prefixed
#define CBS_get_u24_length_prefixed
Definition: boringssl_prefix_symbols.h:1077
cbs_st
Definition: bytestring.h:39
ctx
Definition: benchmark-async.c:30
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
Definition: decode_client_hello_inner.cc:22
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
ctx
static struct test_ctx ctx
Definition: test-ipc-send-recv.c:65
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
bytestring.h
ssl_decode_client_hello_inner
bool ssl_decode_client_hello_inner(SSL *ssl, uint8_t *out_alert, Array< uint8_t > *out_client_hello_inner, Span< const uint8_t > encoded_client_hello_inner, const SSL_CLIENT_HELLO *client_hello_outer)
Definition: encrypted_client_hello.cc:125
SSL_CTX_new
#define SSL_CTX_new
Definition: boringssl_prefix_symbols.h:115
ssl_early_callback_ctx
Definition: ssl.h:4186
ssl_client_hello_init
bool ssl_client_hello_init(const SSL *ssl, SSL_CLIENT_HELLO *out, Span< const uint8_t > body)
Definition: extensions.cc:211
ssl.h
TLS_method
#define TLS_method
Definition: boringssl_prefix_symbols.h:538
SSL_new
#define SSL_new
Definition: boringssl_prefix_symbols.h:414
span.h
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
reader
void reader(void *n)
Definition: libuv/docs/code/locks/main.c:8
absl::MakeConstSpan
constexpr Span< const T > MakeConstSpan(T *ptr, size_t size) noexcept
Definition: abseil-cpp/absl/types/span.h:707


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:02