diff options
Diffstat (limited to 'src/pk_pad')
-rw-r--r-- | src/pk_pad/emsa2/emsa2.cpp | 11 | ||||
-rw-r--r-- | src/pk_pad/emsa3/emsa3.cpp | 2 | ||||
-rw-r--r-- | src/pk_pad/hash_id/hash_id.cpp | 12 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/pk_pad/emsa2/emsa2.cpp b/src/pk_pad/emsa2/emsa2.cpp index 24292d390..9f5f4b277 100644 --- a/src/pk_pad/emsa2/emsa2.cpp +++ b/src/pk_pad/emsa2/emsa2.cpp @@ -96,11 +96,16 @@ bool EMSA2::verify(const MemoryRegion<byte>& coded, *************************************************/ EMSA2::EMSA2(const std::string& hash_name) { - hash_id = ieee1363_hash_id(hash_name); - if(hash_id == 0) - throw Encoding_Error("EMSA2 cannot be used with " + hash->name()); hash = get_hash(hash_name); empty_hash = hash->final(); + + hash_id = ieee1363_hash_id(hash->name()); + + if(hash_id == 0) + { + delete hash; + throw Encoding_Error("EMSA2 cannot be used with " + hash->name()); + } } } diff --git a/src/pk_pad/emsa3/emsa3.cpp b/src/pk_pad/emsa3/emsa3.cpp index 60880d1aa..255366503 100644 --- a/src/pk_pad/emsa3/emsa3.cpp +++ b/src/pk_pad/emsa3/emsa3.cpp @@ -90,8 +90,8 @@ bool EMSA3::verify(const MemoryRegion<byte>& coded, *************************************************/ EMSA3::EMSA3(const std::string& hash_name) { - hash_id = pkcs_hash_id(hash_name); hash = get_hash(hash_name); + hash_id = pkcs_hash_id(hash->name()); } } diff --git a/src/pk_pad/hash_id/hash_id.cpp b/src/pk_pad/hash_id/hash_id.cpp index 27225b3b5..123a0de0e 100644 --- a/src/pk_pad/hash_id/hash_id.cpp +++ b/src/pk_pad/hash_id/hash_id.cpp @@ -4,7 +4,7 @@ *************************************************/ #include <botan/hash_id.h> -#include <botan/libstate.h> +#include <botan/exceptn.h> namespace Botan { @@ -51,10 +51,8 @@ const byte TIGER_ID[] = { /************************************************* * Return the HashID, as specified by PKCS * *************************************************/ -MemoryVector<byte> pkcs_hash_id(const std::string& name_or_alias) +MemoryVector<byte> pkcs_hash_id(const std::string& name) { - const std::string name = global_state().deref_alias(name_or_alias); - MemoryVector<byte> out; if(name == "Parallel(MD5,SHA-160)") @@ -82,16 +80,14 @@ MemoryVector<byte> pkcs_hash_id(const std::string& name_or_alias) if(out.size()) return out; - throw Invalid_Argument("No PKCS #1 identifier for " + name_or_alias); + throw Invalid_Argument("No PKCS #1 identifier for " + name); } /************************************************* * Return the HashID, as specified by IEEE 1363 * *************************************************/ -byte ieee1363_hash_id(const std::string& name_or_alias) +byte ieee1363_hash_id(const std::string& name) { - const std::string name = global_state().deref_alias(name_or_alias); - if(name == "RIPEMD-160") return 0x31; if(name == "RIPEMD-128") return 0x32; if(name == "SHA-160") return 0x33; |