diff options
Diffstat (limited to 'src/pk_pad/emsa4')
-rw-r--r-- | src/pk_pad/emsa4/emsa4.cpp | 16 | ||||
-rw-r--r-- | src/pk_pad/emsa4/emsa4.h | 7 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/pk_pad/emsa4/emsa4.cpp b/src/pk_pad/emsa4/emsa4.cpp index e41b0d2fa..038489e15 100644 --- a/src/pk_pad/emsa4/emsa4.cpp +++ b/src/pk_pad/emsa4/emsa4.cpp @@ -4,7 +4,7 @@ *************************************************/ #include <botan/emsa4.h> -#include <botan/lookup.h> +#include <botan/mgf1.h> #include <botan/bit_ops.h> namespace Botan { @@ -123,21 +123,19 @@ bool EMSA4::verify(const MemoryRegion<byte>& const_coded, /************************************************* * EMSA4 Constructor * *************************************************/ -EMSA4::EMSA4(const std::string& hash_name, const std::string& mgf_name) : - SALT_SIZE(output_length_of(hash_name)) +EMSA4::EMSA4(HashFunction* h) : + SALT_SIZE(h->OUTPUT_LENGTH), hash(h) { - hash = get_hash(hash_name); - mgf = get_mgf(mgf_name + "(" + hash_name + ")"); + mgf = new MGF1(hash->clone()); } /************************************************* * EMSA4 Constructor * *************************************************/ -EMSA4::EMSA4(const std::string& hash_name, const std::string& mgf_name, - u32bit salt_size) : SALT_SIZE(salt_size) +EMSA4::EMSA4(HashFunction* h, u32bit salt_size) : + SALT_SIZE(salt_size), hash(h) { - hash = get_hash(hash_name); - mgf = get_mgf(mgf_name + "(" + hash_name + ")"); + mgf = new MGF1(hash->clone()); } } diff --git a/src/pk_pad/emsa4/emsa4.h b/src/pk_pad/emsa4/emsa4.h index 8f2505281..dded20ec3 100644 --- a/src/pk_pad/emsa4/emsa4.h +++ b/src/pk_pad/emsa4/emsa4.h @@ -17,8 +17,9 @@ namespace Botan { class BOTAN_DLL EMSA4 : public EMSA { public: - EMSA4(const std::string&, const std::string&); - EMSA4(const std::string&, const std::string&, u32bit); + EMSA4(HashFunction*); + EMSA4(HashFunction*, u32bit); + ~EMSA4() { delete hash; delete mgf; } private: void update(const byte[], u32bit); @@ -29,7 +30,7 @@ class BOTAN_DLL EMSA4 : public EMSA bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&, u32bit) throw(); - const u32bit SALT_SIZE; + u32bit SALT_SIZE; HashFunction* hash; const MGF* mgf; }; |