diff options
-rw-r--r-- | src/cli/tls_server.cpp | 19 | ||||
-rw-r--r-- | src/scripts/fuzzer.xml | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp index 0ec45dc42..fba0aa95f 100644 --- a/src/cli/tls_server.cpp +++ b/src/cli/tls_server.cpp @@ -12,6 +12,7 @@ #include <botan/tls_server.h> #include <botan/hex.h> +#include <botan/internal/os_utils.h> #include "credentials.h" #include <list> @@ -46,7 +47,7 @@ namespace Botan_CLI { class TLS_Server final : public Command { public: - TLS_Server() : Command("tls_server cert key --port=443 --type=tcp --policy=") + TLS_Server() : Command("tls_server cert key --port=443 --type=tcp --policy= --dump-traces=") { #if defined(BOTAN_TARGET_OS_IS_WINDOWS) WSAData wsa_data; @@ -78,6 +79,7 @@ class TLS_Server final : public Command const std::string server_key = get_arg("key"); const int port = get_arg_sz("port"); const std::string transport = get_arg("type"); + const std::string dump_traces_to = get_arg("dump-traces"); if(transport != "tcp" && transport != "udp") { @@ -179,6 +181,16 @@ class TLS_Server final : public Command protocol_chooser, !is_tcp); + std::unique_ptr<std::ostream> dump_stream; + + if(!dump_traces_to.empty()) + { + uint64_t timestamp = Botan::OS::get_high_resolution_clock(); + const std::string dump_file = + dump_traces_to + "/tls_" + std::to_string(timestamp) + ".bin"; + dump_stream.reset(new std::ofstream(dump_file.c_str())); + } + try { while(!server.is_closed()) @@ -188,6 +200,11 @@ class TLS_Server final : public Command uint8_t buf[4 * 1024] = { 0 }; ssize_t got = ::read(fd, buf, sizeof(buf)); + if(dump_stream) + { + dump_stream->write(reinterpret_cast<const char*>(buf), got); + } + if(got == -1) { error_output() << "Error in socket read - " << strerror(errno) << std::endl; diff --git a/src/scripts/fuzzer.xml b/src/scripts/fuzzer.xml index 9c3d86551..686059f8c 100644 --- a/src/scripts/fuzzer.xml +++ b/src/scripts/fuzzer.xml @@ -9,7 +9,7 @@ <startupCommandsList> <startupCommands> <fuzzerCommand>simple_fuzzer -connect localhost:$PORT</fuzzerCommand> - <serverCommandParameters>tls_server $rsa_cert $rsa_key --port=$PORT --policy=$fuzz_policy --output=/tmp/botan_output.log --error-output=/tmp/botan_error_output.log </serverCommandParameters> + <serverCommandParameters>tls_server $rsa_cert $rsa_key --port=$PORT --policy=$fuzz_policy --dump-traces=/tmp/tls/ --output=/tmp/botan_output.log --error-output=/tmp/botan_error_output.log </serverCommandParameters> <shortName>botan-rsa</shortName> </startupCommands> <!-- TODO ECDSA --> |