diff options
-rw-r--r-- | src/core/libstate/get_enc.cpp | 15 | ||||
-rw-r--r-- | src/pk_pad/eme1/eme1.cpp | 10 | ||||
-rw-r--r-- | src/pk_pad/eme1/eme1.h | 8 | ||||
-rw-r--r-- | src/pk_pad/eme1/info.txt | 2 |
4 files changed, 24 insertions, 11 deletions
diff --git a/src/core/libstate/get_enc.cpp b/src/core/libstate/get_enc.cpp index fb5952a3e..5f54be199 100644 --- a/src/core/libstate/get_enc.cpp +++ b/src/core/libstate/get_enc.cpp @@ -136,10 +136,17 @@ EME* get_eme(const std::string& algo_spec) #if defined(BOTAN_HAS_EME1) if(eme_name == "EME1") { - if(name.size() == 2) - return new EME1(name[1], "MGF1"); - if(name.size() == 3) - return new EME1(name[1], name[2]); + if(name.size() >= 2) + { + if(name.size() >= 3) + { + // EME1 is hardcoded for MGF1 + if(name[2] != "MGF1") + throw Algorithm_Not_Found(algo_spec); + } + + return new EME1(get_hash(name[1])); + } } #endif diff --git a/src/pk_pad/eme1/eme1.cpp b/src/pk_pad/eme1/eme1.cpp index 2ca10c166..b5f2af6d3 100644 --- a/src/pk_pad/eme1/eme1.cpp +++ b/src/pk_pad/eme1/eme1.cpp @@ -4,7 +4,7 @@ *************************************************/ #include <botan/eme1.h> -#include <botan/lookup.h> +#include <botan/mgf1.h> #include <memory> namespace Botan { @@ -83,13 +83,11 @@ u32bit EME1::maximum_input_size(u32bit keybits) const /************************************************* * EME1 Constructor * *************************************************/ -EME1::EME1(const std::string& hash_name, const std::string& mgf_name, - const std::string& P) : - HASH_LENGTH(output_length_of(hash_name)) +EME1::EME1(HashFunction* hash, const std::string& P) : + HASH_LENGTH(hash->OUTPUT_LENGTH) { - mgf = get_mgf(mgf_name + "(" + hash_name + ")"); - std::auto_ptr<HashFunction> hash(get_hash(hash_name)); Phash = hash->process(P); + mgf = new MGF1(hash); } } diff --git a/src/pk_pad/eme1/eme1.h b/src/pk_pad/eme1/eme1.h index af8530470..e33b0e917 100644 --- a/src/pk_pad/eme1/eme1.h +++ b/src/pk_pad/eme1/eme1.h @@ -19,7 +19,13 @@ class BOTAN_DLL EME1 : public EME public: u32bit maximum_input_size(u32bit) const; - EME1(const std::string&, const std::string&, const std::string& = ""); + /** + EME1 constructor. Hash will be deleted by ~EME1 (when mgf is deleted) + + P is an optional label. Normally empty. + */ + EME1(HashFunction* hash, const std::string& P = ""); + ~EME1() { delete mgf; } private: SecureVector<byte> pad(const byte[], u32bit, u32bit, diff --git a/src/pk_pad/eme1/info.txt b/src/pk_pad/eme1/info.txt index dafb595c1..e2b74265f 100644 --- a/src/pk_pad/eme1/info.txt +++ b/src/pk_pad/eme1/info.txt @@ -11,4 +11,6 @@ eme1.cpp <requires> mgf1 +utils +core </requires> |