diff options
author | lloyd <[email protected]> | 2015-01-31 15:30:49 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-01-31 15:30:49 +0000 |
commit | 00c9b3f4834603946065c15b9b2e9fa5e973b979 (patch) | |
tree | b0f82333a1eeab624409db9515e511838f6fa2d6 /src/lib/pk_pad | |
parent | 710229be83cdbc061949c61942896b5af9e134d8 (diff) |
Use registry for streams and MACs. Start updating callers.
Diffstat (limited to 'src/lib/pk_pad')
-rw-r--r-- | src/lib/pk_pad/get_pk_pad.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/lib/pk_pad/get_pk_pad.cpp b/src/lib/pk_pad/get_pk_pad.cpp index 0cb533084..b7df17158 100644 --- a/src/lib/pk_pad/get_pk_pad.cpp +++ b/src/lib/pk_pad/get_pk_pad.cpp @@ -7,7 +7,6 @@ #include <botan/emsa.h> #include <botan/eme.h> -#include <botan/libstate.h> #include <botan/scan_name.h> #if defined(BOTAN_HAS_EMSA1) @@ -51,7 +50,7 @@ EMSA* get_emsa(const std::string& algo_spec) { SCAN_Name request(algo_spec); - Algorithm_Factory& af = global_state().algorithm_factory(); + auto& hashes = Algo_Registry<HashFunction>::global_registry(); #if defined(BOTAN_HAS_EMSA_RAW) if(request.algo_name() == "Raw" && request.arg_count() == 0) @@ -66,18 +65,18 @@ EMSA* get_emsa(const std::string& algo_spec) #endif #if defined(BOTAN_HAS_EMSA1) - return new EMSA1(af.make_hash_function(request.arg(0))); + return new EMSA1(hashes.make(request.arg(0))); #endif } #if defined(BOTAN_HAS_EMSA1_BSI) if(request.algo_name() == "EMSA1_BSI" && request.arg_count() == 1) - return new EMSA1_BSI(af.make_hash_function(request.arg(0))); + return new EMSA1_BSI(hashes.make(request.arg(0))); #endif #if defined(BOTAN_HAS_EMSA_X931) if(request.algo_name() == "EMSA_X931" && request.arg_count() == 1) - return new EMSA_X931(af.make_hash_function(request.arg(0))); + return new EMSA_X931(hashes.make(request.arg(0))); #endif #if defined(BOTAN_HAS_EMSA_PKCS1) @@ -85,7 +84,7 @@ EMSA* get_emsa(const std::string& algo_spec) { if(request.arg(0) == "Raw") return new EMSA_PKCS1v15_Raw; - return new EMSA_PKCS1v15(af.make_hash_function(request.arg(0))); + return new EMSA_PKCS1v15(hashes.make(request.arg(0))); } #endif @@ -94,13 +93,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 PSSR(af.make_hash_function(request.arg(0))); + return new PSSR(hashes.make(request.arg(0))); if(request.arg_count() == 2 && request.arg(1) != "MGF1") - return new PSSR(af.make_hash_function(request.arg(0))); + return new PSSR(hashes.make(request.arg(0))); if(request.arg_count() == 3) - return new PSSR(af.make_hash_function(request.arg(0)), + return new PSSR(hashes.make(request.arg(0)), request.arg_as_integer(2, 0)); } #endif @@ -124,14 +123,14 @@ EME* get_eme(const std::string& algo_spec) #endif #if defined(BOTAN_HAS_EME_OAEP) - Algorithm_Factory& af = global_state().algorithm_factory(); - if(request.algo_name() == "OAEP" && request.arg_count_between(1, 2)) { + auto& hashes = Algo_Registry<HashFunction>::global_registry(); + if(request.arg_count() == 1 || (request.arg_count() == 2 && request.arg(1) == "MGF1")) { - return new OAEP(af.make_hash_function(request.arg(0))); + return new OAEP(hashes.make(request.arg(0))); } } #endif |