-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a simple fuzz target for TLS 1.3 handshake messages
Co-Authored-By: Lukas Zeller <[email protected]>
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | ||
} |