You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

client.cc 618 B

123456789101112131415161718192021222324252627282930
  1. #include <assert.h>
  2. #include <openssl/ssl.h>
  3. struct GlobalState {
  4. GlobalState() : ctx(SSL_CTX_new(SSLv23_method())) {}
  5. ~GlobalState() {
  6. SSL_CTX_free(ctx);
  7. }
  8. SSL_CTX *const ctx;
  9. };
  10. static GlobalState g_state;
  11. extern "C" int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len) {
  12. // This only fuzzes the initial flow from the server so far.
  13. SSL *client = SSL_new(g_state.ctx);
  14. BIO *in = BIO_new(BIO_s_mem());
  15. BIO *out = BIO_new(BIO_s_mem());
  16. SSL_set_bio(client, in, out);
  17. SSL_set_connect_state(client);
  18. BIO_write(in, buf, len);
  19. SSL_do_handshake(client);
  20. SSL_free(client);
  21. return 0;
  22. }