aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-11 03:49:23 +0000
committerlloyd <[email protected]>2008-11-11 03:49:23 +0000
commit54f82a91844808eb1612080427fb64d44c486aad (patch)
tree82de46d4ae586f389120a5257576e8354b1e2d3a /src/libstate
parent6d2db29350761e5573c6f7fafefb2b937993fb80 (diff)
Make SCAN_Name::arg return a new SCAN_Name that has the same providers list,
this allows provider preferences to be passed down to sub-algorithms.
Diffstat (limited to 'src/libstate')
-rw-r--r--src/libstate/engine/def_engine/lookup_hash.cpp5
-rw-r--r--src/libstate/get_enc.cpp40
2 files changed, 25 insertions, 20 deletions
diff --git a/src/libstate/engine/def_engine/lookup_hash.cpp b/src/libstate/engine/def_engine/lookup_hash.cpp
index da782fc0a..48ed8bc04 100644
--- a/src/libstate/engine/def_engine/lookup_hash.cpp
+++ b/src/libstate/engine/def_engine/lookup_hash.cpp
@@ -166,10 +166,7 @@ Default_Engine::find_hash(const SCAN_Name& request,
*/
for(size_t i = 0; i != request.arg_count(); ++i)
{
- SCAN_Name hash_request(request.arg(i),
- request.providers_string());
-
- const HashFunction* hash = af.prototype_hash_function(hash_request);
+ const HashFunction* hash = af.prototype_hash_function(request.arg(i));
if(!hash)
return 0;
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)