From 6c8ffb4d2ee1f762804fc8d6a90a3d1761462503 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Fri, 16 Mar 2018 12:01:01 -0400 Subject: Catch exceptions by reference not value Fixes a new warning in GCC 8 --- src/lib/pk_pad/emsa1/emsa1.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src/lib/pk_pad/emsa1') diff --git a/src/lib/pk_pad/emsa1/emsa1.cpp b/src/lib/pk_pad/emsa1/emsa1.cpp index b4391b48d..66d8ec852 100644 --- a/src/lib/pk_pad/emsa1/emsa1.cpp +++ b/src/lib/pk_pad/emsa1/emsa1.cpp @@ -77,29 +77,23 @@ bool EMSA1::verify(const secure_vector& input, const secure_vector& raw, size_t key_bits) { - try { - if(raw.size() != m_hash->output_length()) - throw Encoding_Error("EMSA1::encoding_of: Invalid size for input"); + if(raw.size() != m_hash->output_length()) + return false; - // Call emsa1_encoding to handle any required bit shifting - const secure_vector our_coding = emsa1_encoding(raw, key_bits); + // Call emsa1_encoding to handle any required bit shifting + const secure_vector our_coding = emsa1_encoding(raw, key_bits); - if(our_coding.size() < input.size()) - return false; + if(our_coding.size() < input.size()) + return false; - const size_t offset = our_coding.size() - input.size(); // must be >= 0 per check above + const size_t offset = our_coding.size() - input.size(); // must be >= 0 per check above - // If our encoding is longer, all the bytes in it must be zero - for(size_t i = 0; i != offset; ++i) - if(our_coding[i] != 0) + // If our encoding is longer, all the bytes in it must be zero + for(size_t i = 0; i != offset; ++i) + if(our_coding[i] != 0) return false; - return constant_time_compare(input.data(), &our_coding[offset], input.size()); - } - catch(Invalid_Argument) - { - return false; - } + return constant_time_compare(input.data(), &our_coding[offset], input.size()); } AlgorithmIdentifier EMSA1::config_for_x509(const Private_Key& key, -- cgit v1.2.3