blob: 7cf41fca9d02cca6f5bbc8836aa02f294fb9d40c [file] [log] [blame]
Adam Langley9a4beb82015-11-09 13:57:26 -08001#include <assert.h>
2
3#include <openssl/ssl.h>
4
5struct GlobalState {
6 GlobalState() : ctx(SSL_CTX_new(SSLv23_method())) {}
7
8 ~GlobalState() {
9 SSL_CTX_free(ctx);
10 }
11
12 SSL_CTX *const ctx;
13};
14
15static GlobalState g_state;
16
17extern "C" int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len) {
18 // This only fuzzes the initial flow from the server so far.
19 SSL *client = SSL_new(g_state.ctx);
20 BIO *in = BIO_new(BIO_s_mem());
21 BIO *out = BIO_new(BIO_s_mem());
22 SSL_set_bio(client, in, out);
23 SSL_set_connect_state(client);
24
25 BIO_write(in, buf, len);
26 SSL_do_handshake(client);
27 SSL_free(client);
28
29 return 0;
30}