aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad/emsa1
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-03-16 12:01:01 -0400
committerJack Lloyd <[email protected]>2018-03-16 12:01:01 -0400
commit6c8ffb4d2ee1f762804fc8d6a90a3d1761462503 (patch)
tree2b88c8d5a809cca03f3f66e6c1a053b1b7fa338a /src/lib/pk_pad/emsa1
parentf787047f33d073036883b609d293656510ce8b16 (diff)
Catch exceptions by reference not value
Fixes a new warning in GCC 8
Diffstat (limited to 'src/lib/pk_pad/emsa1')
-rw-r--r--src/lib/pk_pad/emsa1/emsa1.cpp28
1 files changed, 11 insertions, 17 deletions
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<uint8_t>& input,
const secure_vector<uint8_t>& 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<uint8_t> our_coding = emsa1_encoding(raw, key_bits);
+ // Call emsa1_encoding to handle any required bit shifting
+ const secure_vector<uint8_t> 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,