aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/lookup.h5
-rw-r--r--src/def_alg.cpp14
-rw-r--r--src/eng_base.cpp12
-rw-r--r--src/get_enc.cpp9
-rw-r--r--src/hash_id.cpp6
-rw-r--r--src/libstate.cpp8
-rw-r--r--src/pbes1.cpp7
-rw-r--r--src/pbes2.cpp9
8 files changed, 32 insertions, 38 deletions
diff --git a/include/lookup.h b/include/lookup.h
index 6e0cecdc7..ccf32bde2 100644
--- a/include/lookup.h
+++ b/include/lookup.h
@@ -69,11 +69,6 @@ BOTAN_DLL bool have_hash(const std::string&);
BOTAN_DLL bool have_mac(const std::string&);
/*************************************************
-* Dereference an alias *
-*************************************************/
-BOTAN_DLL std::string deref_alias(const std::string&);
-
-/*************************************************
* Query information about an algorithm *
*************************************************/
BOTAN_DLL u32bit block_size_of(const std::string&);
diff --git a/src/def_alg.cpp b/src/def_alg.cpp
index d6f6422f5..b10c4ff98 100644
--- a/src/def_alg.cpp
+++ b/src/def_alg.cpp
@@ -4,7 +4,7 @@
*************************************************/
#include <botan/eng_def.h>
-#include <botan/lookup.h>
+#include <botan/libstate.h>
#include <botan/parsing.h>
#include <botan/aes.h>
@@ -113,7 +113,7 @@ Default_Engine::find_block_cipher(const std::string& algo_spec) const
std::vector<std::string> name = parse_algorithm_name(algo_spec);
if(name.empty())
return 0;
- const std::string algo_name = deref_alias(name[0]);
+ const std::string algo_name = global_state().deref_alias(name[0]);
HANDLE_TYPE_NO_ARGS("AES", AES);
HANDLE_TYPE_NO_ARGS("AES-128", AES_128);
@@ -161,7 +161,7 @@ Default_Engine::find_stream_cipher(const std::string& algo_spec) const
std::vector<std::string> name = parse_algorithm_name(algo_spec);
if(name.empty())
return 0;
- const std::string algo_name = deref_alias(name[0]);
+ const std::string algo_name = global_state().deref_alias(name[0]);
HANDLE_TYPE_ONE_U32BIT("ARC4", ARC4, 0);
HANDLE_TYPE_ONE_U32BIT("RC4_drop", ARC4, 768);
@@ -180,7 +180,7 @@ Default_Engine::find_hash(const std::string& algo_spec) const
std::vector<std::string> name = parse_algorithm_name(algo_spec);
if(name.empty())
return 0;
- const std::string algo_name = deref_alias(name[0]);
+ const std::string algo_name = global_state().deref_alias(name[0]);
HANDLE_TYPE_NO_ARGS("Adler32", Adler32);
HANDLE_TYPE_NO_ARGS("CRC24", CRC24);
@@ -218,7 +218,7 @@ Default_Engine::find_mac(const std::string& algo_spec) const
std::vector<std::string> name = parse_algorithm_name(algo_spec);
if(name.empty())
return 0;
- const std::string algo_name = deref_alias(name[0]);
+ const std::string algo_name = global_state().deref_alias(name[0]);
HANDLE_TYPE_ONE_STRING("CBC-MAC", CBC_MAC);
HANDLE_TYPE_ONE_STRING("CMAC", CMAC);
@@ -237,7 +237,7 @@ S2K* Default_Engine::find_s2k(const std::string& algo_spec) const
if(name.empty())
return 0;
- const std::string algo_name = deref_alias(name[0]);
+ const std::string algo_name = global_state().deref_alias(name[0]);
HANDLE_TYPE_ONE_STRING("PBKDF1", PKCS5_PBKDF1);
HANDLE_TYPE_ONE_STRING("PBKDF2", PKCS5_PBKDF2);
@@ -256,7 +256,7 @@ Default_Engine::find_bc_pad(const std::string& algo_spec) const
if(name.empty())
return 0;
- const std::string algo_name = deref_alias(name[0]);
+ const std::string algo_name = global_state().deref_alias(name[0]);
HANDLE_TYPE_NO_ARGS("PKCS7", PKCS7_Padding);
HANDLE_TYPE_NO_ARGS("OneAndZeros", OneAndZeros_Padding);
diff --git a/src/eng_base.cpp b/src/eng_base.cpp
index 7f113afb6..38234d462 100644
--- a/src/eng_base.cpp
+++ b/src/eng_base.cpp
@@ -122,7 +122,7 @@ Modular_Exponentiator* Engine::mod_exp(const BigInt&,
*************************************************/
const BlockCipher* Engine::block_cipher(const std::string& name) const
{
- return lookup_algo(cache_of_bc, deref_alias(name),
+ return lookup_algo(cache_of_bc, global_state().deref_alias(name),
this, &Engine::find_block_cipher);
}
@@ -131,7 +131,7 @@ const BlockCipher* Engine::block_cipher(const std::string& name) const
*************************************************/
const StreamCipher* Engine::stream_cipher(const std::string& name) const
{
- return lookup_algo(cache_of_sc, deref_alias(name),
+ return lookup_algo(cache_of_sc, global_state().deref_alias(name),
this, &Engine::find_stream_cipher);
}
@@ -140,7 +140,7 @@ const StreamCipher* Engine::stream_cipher(const std::string& name) const
*************************************************/
const HashFunction* Engine::hash(const std::string& name) const
{
- return lookup_algo(cache_of_hf, deref_alias(name),
+ return lookup_algo(cache_of_hf, global_state().deref_alias(name),
this, &Engine::find_hash);
}
@@ -149,7 +149,7 @@ const HashFunction* Engine::hash(const std::string& name) const
*************************************************/
const MessageAuthenticationCode* Engine::mac(const std::string& name) const
{
- return lookup_algo(cache_of_mac, deref_alias(name),
+ return lookup_algo(cache_of_mac, global_state().deref_alias(name),
this, &Engine::find_mac);
}
@@ -158,7 +158,7 @@ const MessageAuthenticationCode* Engine::mac(const std::string& name) const
*************************************************/
const S2K* Engine::s2k(const std::string& name) const
{
- return lookup_algo(cache_of_s2k, deref_alias(name),
+ return lookup_algo(cache_of_s2k, global_state().deref_alias(name),
this, &Engine::find_s2k);
}
@@ -168,7 +168,7 @@ const S2K* Engine::s2k(const std::string& name) const
const BlockCipherModePaddingMethod*
Engine::bc_pad(const std::string& name) const
{
- return lookup_algo(cache_of_bc_pad, deref_alias(name),
+ return lookup_algo(cache_of_bc_pad, global_state().deref_alias(name),
this, &Engine::find_bc_pad);
}
diff --git a/src/get_enc.cpp b/src/get_enc.cpp
index 19c2da03a..17e28e9d9 100644
--- a/src/get_enc.cpp
+++ b/src/get_enc.cpp
@@ -4,6 +4,7 @@
*************************************************/
#include <botan/lookup.h>
+#include <botan/libstate.h>
#include <botan/parsing.h>
#include <botan/emsa.h>
#include <botan/eme.h>
@@ -19,7 +20,7 @@ namespace Botan {
EMSA* get_emsa(const std::string& algo_spec)
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- const std::string emsa_name = deref_alias(name[0]);
+ const std::string emsa_name = global_state().deref_alias(name[0]);
if(emsa_name == "Raw")
{
@@ -62,7 +63,7 @@ EMSA* get_emsa(const std::string& algo_spec)
EME* get_eme(const std::string& algo_spec)
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- const std::string eme_name = deref_alias(name[0]);
+ const std::string eme_name = global_state().deref_alias(name[0]);
if(eme_name == "PKCS1v15")
{
@@ -88,7 +89,7 @@ EME* get_eme(const std::string& algo_spec)
KDF* get_kdf(const std::string& algo_spec)
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- const std::string kdf_name = deref_alias(name[0]);
+ const std::string kdf_name = global_state().deref_alias(name[0]);
if(kdf_name == "KDF1")
{
@@ -117,7 +118,7 @@ KDF* get_kdf(const std::string& algo_spec)
MGF* get_mgf(const std::string& algo_spec)
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- const std::string mgf_name = deref_alias(name[0]);
+ const std::string mgf_name = global_state().deref_alias(name[0]);
if(mgf_name == "MGF1")
{
diff --git a/src/hash_id.cpp b/src/hash_id.cpp
index b517bfe58..27225b3b5 100644
--- a/src/hash_id.cpp
+++ b/src/hash_id.cpp
@@ -4,7 +4,7 @@
*************************************************/
#include <botan/hash_id.h>
-#include <botan/lookup.h>
+#include <botan/libstate.h>
namespace Botan {
@@ -53,7 +53,7 @@ const byte TIGER_ID[] = {
*************************************************/
MemoryVector<byte> pkcs_hash_id(const std::string& name_or_alias)
{
- const std::string name = deref_alias(name_or_alias);
+ const std::string name = global_state().deref_alias(name_or_alias);
MemoryVector<byte> out;
@@ -90,7 +90,7 @@ MemoryVector<byte> pkcs_hash_id(const std::string& name_or_alias)
*************************************************/
byte ieee1363_hash_id(const std::string& name_or_alias)
{
- const std::string name = deref_alias(name_or_alias);
+ const std::string name = global_state().deref_alias(name_or_alias);
if(name == "RIPEMD-160") return 0x31;
if(name == "RIPEMD-128") return 0x32;
diff --git a/src/libstate.cpp b/src/libstate.cpp
index f96a53d19..9fb2b186a 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -25,14 +25,6 @@ Library_State* global_lib_state = 0;
}
/*************************************************
-* Dereference an alias *
-*************************************************/
-std::string deref_alias(const std::string& name)
- {
- return global_state().deref_alias(name);
- }
-
-/*************************************************
* Access the global state object *
*************************************************/
Library_State& global_state()
diff --git a/src/pbes1.cpp b/src/pbes1.cpp
index 3126209b4..84b34eed6 100644
--- a/src/pbes1.cpp
+++ b/src/pbes1.cpp
@@ -8,6 +8,7 @@
#include <botan/ber_dec.h>
#include <botan/parsing.h>
#include <botan/lookup.h>
+#include <botan/libstate.h>
#include <algorithm>
#include <memory>
@@ -144,12 +145,14 @@ OID PBE_PKCS5v15::get_oid() const
*************************************************/
PBE_PKCS5v15::PBE_PKCS5v15(const std::string& d_algo,
const std::string& c_algo, Cipher_Dir dir) :
- direction(dir), digest(deref_alias(d_algo)), cipher(c_algo)
+ direction(dir),
+ digest(global_state().deref_alias(d_algo)),
+ cipher(c_algo)
{
std::vector<std::string> cipher_spec = split_on(c_algo, '/');
if(cipher_spec.size() != 2)
throw Invalid_Argument("PBE-PKCS5 v1.5: Invalid cipher spec " + c_algo);
- const std::string cipher_algo = deref_alias(cipher_spec[0]);
+ const std::string cipher_algo = global_state().deref_alias(cipher_spec[0]);
const std::string cipher_mode = cipher_spec[1];
if(!have_block_cipher(cipher_algo))
diff --git a/src/pbes2.cpp b/src/pbes2.cpp
index 62913abac..d3533f14f 100644
--- a/src/pbes2.cpp
+++ b/src/pbes2.cpp
@@ -4,6 +4,7 @@
*************************************************/
#include <botan/pbe_pkcs.h>
+#include <botan/libstate.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/parsing.h>
@@ -155,7 +156,7 @@ void PBE_PKCS5v20::decode_params(DataSource& source)
std::vector<std::string> cipher_spec = split_on(cipher, '/');
if(cipher_spec.size() != 2)
throw Decoding_Error("PBE-PKCS5 v2.0: Invalid cipher spec " + cipher);
- cipher_algo = deref_alias(cipher_spec[0]);
+ cipher_algo = global_state().deref_alias(cipher_spec[0]);
if(!known_cipher(cipher_algo) || cipher_spec[1] != "CBC")
throw Decoding_Error("PBE-PKCS5 v2.0: Don't know param format for " +
@@ -195,12 +196,14 @@ bool PBE_PKCS5v20::known_cipher(const std::string& algo) const
*************************************************/
PBE_PKCS5v20::PBE_PKCS5v20(const std::string& d_algo,
const std::string& c_algo) :
- direction(ENCRYPTION), digest(deref_alias(d_algo)), cipher(c_algo)
+ direction(ENCRYPTION),
+ digest(global_state().deref_alias(d_algo)),
+ cipher(c_algo)
{
std::vector<std::string> cipher_spec = split_on(cipher, '/');
if(cipher_spec.size() != 2)
throw Invalid_Argument("PBE-PKCS5 v2.0: Invalid cipher spec " + cipher);
- cipher_algo = deref_alias(cipher_spec[0]);
+ cipher_algo = global_state().deref_alias(cipher_spec[0]);
const std::string cipher_mode = cipher_spec[1];
if(!have_block_cipher(cipher_algo))