diff options
Diffstat (limited to 'src/libstate/get_enc.cpp')
-rw-r--r-- | src/libstate/get_enc.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/libstate/get_enc.cpp b/src/libstate/get_enc.cpp index 143cec21c..a5231db91 100644 --- a/src/libstate/get_enc.cpp +++ b/src/libstate/get_enc.cpp @@ -85,19 +85,21 @@ S2K* get_s2k(const std::string& algo_spec) { SCAN_Name request(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + #if defined(BOTAN_HAS_PBKDF1) if(request.algo_name() == "PBKDF1" && request.arg_count() == 1) - return new PKCS5_PBKDF1(get_hash(request.arg(0))); + return new PKCS5_PBKDF1(af.make_hash_function(request.arg(0))); #endif #if defined(BOTAN_HAS_PBKDF2) if(request.algo_name() == "PBKDF2" && request.arg_count() == 1) - return new PKCS5_PBKDF2(new HMAC(get_hash(request.arg(0)))); + return new PKCS5_PBKDF2(new HMAC(af.make_hash_function(request.arg(0)))); #endif #if defined(BOTAN_HAS_PGPS2K) if(request.algo_name() == "OpenPGP-S2K" && request.arg_count() == 1) - return new OpenPGP_S2K(get_hash(request.arg(0))); + return new OpenPGP_S2K(af.make_hash_function(request.arg(0))); #endif throw Algorithm_Not_Found(algo_spec); @@ -110,6 +112,8 @@ EMSA* get_emsa(const std::string& algo_spec) { SCAN_Name request(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + #if defined(BOTAN_HAS_EMSA_RAW) if(request.algo_name() == "Raw" && request.arg_count() == 0) return new EMSA_Raw; @@ -117,22 +121,22 @@ EMSA* get_emsa(const std::string& algo_spec) #if defined(BOTAN_HAS_EMSA1) if(request.algo_name() == "EMSA1" && request.arg_count() == 1) - return new EMSA1(get_hash(request.arg(0))); + return new EMSA1(af.make_hash_function(request.arg(0))); #endif #if defined(BOTAN_HAS_EMSA1_BSI) if(request.algo_name() == "EMSA1_BSI" && request.arg_count() == 1) - return new EMSA1_BSI(get_hash(request.arg(0))); + return new EMSA1_BSI(af.make_hash_function(request.arg(0))); #endif #if defined(BOTAN_HAS_EMSA2) if(request.algo_name() == "EMSA2" && request.arg_count() == 1) - return new EMSA2(get_hash(request.arg(0))); + return new EMSA2(af.make_hash_function(request.arg(0))); #endif #if defined(BOTAN_HAS_EMSA3) if(request.algo_name() == "EMSA3" && request.arg_count() == 1) - return new EMSA3(get_hash(request.arg(0))); + return new EMSA3(af.make_hash_function(request.arg(0))); #endif #if defined(BOTAN_HAS_EMSA4) @@ -140,13 +144,13 @@ EMSA* get_emsa(const std::string& algo_spec) { // 3 args: Hash, MGF, salt size (MGF is hardcoded MGF1 in Botan) if(request.arg_count() == 1) - return new EMSA4(get_hash(request.arg(0))); + return new EMSA4(af.make_hash_function(request.arg(0))); - if(request.arg_count() == 2 && request.arg(1) != "MGF1") - return new EMSA4(get_hash(request.arg(0))); + if(request.arg_count() == 2 && request.arg_as_string(1) != "MGF1") + return new EMSA4(af.make_hash_function(request.arg(0))); if(request.arg_count() == 3) - return new EMSA4(get_hash(request.arg(0)), + return new EMSA4(af.make_hash_function(request.arg(0)), request.arg_as_u32bit(2, 0)); } #endif @@ -161,6 +165,8 @@ EME* get_eme(const std::string& algo_spec) { SCAN_Name request(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + if(request.algo_name() == "Raw") return 0; // No padding @@ -173,9 +179,9 @@ EME* get_eme(const std::string& algo_spec) if(request.algo_name() == "EME1" && request.arg_count_between(1, 2)) { if(request.arg_count() == 1 || - (request.arg_count() == 2 && request.arg(1) == "MGF1")) + (request.arg_count() == 2 && request.arg_as_string(1) == "MGF1")) { - return new EME1(get_hash(request.arg(0))); + return new EME1(af.make_hash_function(request.arg(0))); } } #endif @@ -190,22 +196,24 @@ KDF* get_kdf(const std::string& algo_spec) { SCAN_Name request(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + if(request.algo_name() == "Raw") return 0; // No KDF #if defined(BOTAN_HAS_KDF1) if(request.algo_name() == "KDF1" && request.arg_count() == 1) - return new KDF1(get_hash(request.arg(0))); + return new KDF1(af.make_hash_function(request.arg(0))); #endif #if defined(BOTAN_HAS_KDF2) if(request.algo_name() == "KDF2" && request.arg_count() == 1) - return new KDF2(get_hash(request.arg(0))); + return new KDF2(af.make_hash_function(request.arg(0))); #endif #if defined(BOTAN_HAS_X942_PRF) if(request.algo_name() == "X9.42-PRF" && request.arg_count() == 1) - return new X942_PRF(request.arg(0)); + return new X942_PRF(request.arg_as_string(0)); // OID #endif #if defined(BOTAN_HAS_TLS_V10_PRF) |