diff options
author | Jack Lloyd <[email protected]> | 2019-05-24 07:06:07 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-05-24 07:06:07 -0400 |
commit | d3706175d560ed8fbf3f4d3961cae910be1c77e0 (patch) | |
tree | a791958ae6eeefef5f10a72213a69553dabb707f /src/lib | |
parent | 78dff743222447cd626c6a7a1d94c5ccd46de02b (diff) |
Add script for running TLS fuzzer
Fix a few minor issues found thereby
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/math/numbertheory/pow_mod.cpp | 4 | ||||
-rw-r--r-- | src/lib/tls/msg_client_kex.cpp | 4 | ||||
-rw-r--r-- | src/lib/tls/tls_callbacks.cpp | 2 | ||||
-rw-r--r-- | src/lib/tls/tls_handshake_io.cpp | 3 |
4 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/math/numbertheory/pow_mod.cpp b/src/lib/math/numbertheory/pow_mod.cpp index 00917a5f9..02434fe68 100644 --- a/src/lib/math/numbertheory/pow_mod.cpp +++ b/src/lib/math/numbertheory/pow_mod.cpp @@ -65,8 +65,8 @@ void Power_Mod::set_modulus(const BigInt& n, Usage_Hints hints, bool disable_mon */ void Power_Mod::set_base(const BigInt& b) const { - if(b.is_zero() || b.is_negative()) - throw Invalid_Argument("Power_Mod::set_base: arg must be > 0"); + if(b.is_negative()) + throw Invalid_Argument("Power_Mod::set_base: arg must be non-negative"); if(!m_core) throw Internal_Error("Power_Mod::set_base: m_core was NULL"); diff --git a/src/lib/tls/msg_client_kex.cpp b/src/lib/tls/msg_client_kex.cpp index f55568c8e..9cb92447b 100644 --- a/src/lib/tls/msg_client_kex.cpp +++ b/src/lib/tls/msg_client_kex.cpp @@ -377,6 +377,10 @@ Client_Key_Exchange::Client_Key_Exchange(const std::vector<uint8_t>& contents, else m_pre_master = shared_secret; } + catch(Invalid_Argument& e) + { + throw TLS_Exception(Alert::ILLEGAL_PARAMETER, e.what()); + } catch(std::exception &) { /* diff --git a/src/lib/tls/tls_callbacks.cpp b/src/lib/tls/tls_callbacks.cpp index 28884c1e2..bcd3aa39b 100644 --- a/src/lib/tls/tls_callbacks.cpp +++ b/src/lib/tls/tls_callbacks.cpp @@ -119,7 +119,7 @@ std::pair<secure_vector<uint8_t>, std::vector<uint8_t>> TLS::Callbacks::tls_dh_a * advantage to bogus keys anyway. */ if(Y <= 1 || Y >= p - 1) - throw TLS_Exception(Alert::INSUFFICIENT_SECURITY, + throw TLS_Exception(Alert::ILLEGAL_PARAMETER, "Server sent bad DH key for DHE exchange"); DL_Group group(p, g); diff --git a/src/lib/tls/tls_handshake_io.cpp b/src/lib/tls/tls_handshake_io.cpp index acc30b102..7ac868612 100644 --- a/src/lib/tls/tls_handshake_io.cpp +++ b/src/lib/tls/tls_handshake_io.cpp @@ -78,6 +78,9 @@ Stream_Handshake_IO::get_next_record(bool) { Handshake_Type type = static_cast<Handshake_Type>(m_queue[0]); + if(type == HANDSHAKE_NONE) + throw Decoding_Error("Invalid handshake message type"); + std::vector<uint8_t> contents(m_queue.begin() + 4, m_queue.begin() + length); |