Skip to content

Commit

Permalink
add a simple fuzz target for TLS 1.3 handshake messages
Browse files Browse the repository at this point in the history
Co-Authored-By: Lukas Zeller <[email protected]>
  • Loading branch information
reneme and lz101010 committed Jul 6, 2022
1 parent 987c7af commit 6486350
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/fuzzer/tls_13_handshake_layer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* (C) 2022 Jack Lloyd
* (C) 2002 René Meusel - neXenio GmbH
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include "fuzzers.h"
#include <botan/internal/tls_handshake_layer_13.h>
#include <botan/internal/tls_transcript_hash_13.h>


namespace {

Botan::TLS::Handshake_Layer prepare(const std::vector<uint8_t>& data)
{
Botan::TLS::Handshake_Layer hl(Botan::TLS::Connection_Side::CLIENT);
hl.copy_data(data);
return hl;
}

} // namespace;


void fuzz(const uint8_t in[], size_t len)
{
static Botan::TLS::Default_Policy policy;

try
{
std::vector<uint8_t> v(in, in + len);
auto hl1 = prepare(v);
Botan::TLS::Transcript_Hash_State ths("SHA-256");
while (hl1.next_message(policy, ths).has_value()) {};

auto hl2 = prepare(v);
while (hl2.next_post_handshake_message(policy).has_value()) {};
}
catch(Botan::Exception& e) {}
}

0 comments on commit 6486350

Please sign in to comment.