aboutsummaryrefslogtreecommitdiffstats
path: root/src/get_enc.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-28 17:35:11 +0000
committerlloyd <[email protected]>2008-09-28 17:35:11 +0000
commit8c085b3c40c30607ca5cac10d04062355fcad187 (patch)
tree4fe7387db56f4422c997b88f2a92e52f669c2de4 /src/get_enc.cpp
parentda412e1f1169d4b51bbef84eb2948b73416bd48a (diff)
Modularize EMSA
Diffstat (limited to 'src/get_enc.cpp')
-rw-r--r--src/get_enc.cpp72
1 files changed, 51 insertions, 21 deletions
diff --git a/src/get_enc.cpp b/src/get_enc.cpp
index 31c1e06aa..98cba0ad2 100644
--- a/src/get_enc.cpp
+++ b/src/get_enc.cpp
@@ -6,12 +6,31 @@
#include <botan/lookup.h>
#include <botan/libstate.h>
#include <botan/parsing.h>
-#include <botan/emsa.h>
#include <botan/eme.h>
#include <botan/kdf.h>
#include <botan/mgf1.h>
#include <botan/util.h>
+#ifdef BOTAN_HAS_EMSA1
+ #include <botan/emsa1.h>
+#endif
+
+#ifdef BOTAN_HAS_EMSA2
+ #include <botan/emsa2.h>
+#endif
+
+#ifdef BOTAN_HAS_EMSA3
+ #include <botan/emsa3.h>
+#endif
+
+#ifdef BOTAN_HAS_EMSA4
+ #include <botan/emsa4.h>
+#endif
+
+#ifdef BOTAN_HAS_EMSA_RAW
+ #include <botan/emsa_raw.h>
+#endif
+
namespace Botan {
/*************************************************
@@ -22,27 +41,40 @@ EMSA* get_emsa(const std::string& algo_spec)
std::vector<std::string> name = parse_algorithm_name(algo_spec);
const std::string emsa_name = global_state().deref_alias(name[0]);
+#ifdef BOTAN_HAS_EMSA_RAW
if(emsa_name == "Raw")
{
if(name.size() == 1)
return new EMSA_Raw;
}
- else if(emsa_name == "EMSA1")
+#endif
+
+#ifdef BOTAN_HAS_EMSA1
+ if(emsa_name == "EMSA1")
{
if(name.size() == 2)
return new EMSA1(name[1]);
}
- else if(emsa_name == "EMSA2")
+#endif
+
+#ifdef BOTAN_HAS_EMSA2
+ if(emsa_name == "EMSA2")
{
if(name.size() == 2)
return new EMSA2(name[1]);
}
- else if(emsa_name == "EMSA3")
+#endif
+
+#ifdef BOTAN_HAS_EMSA3
+ if(emsa_name == "EMSA3")
{
if(name.size() == 2)
return new EMSA3(name[1]);
}
- else if(emsa_name == "EMSA4")
+#endif
+
+#ifdef BOTAN_HAS_EMSA4
+ if(emsa_name == "EMSA4")
{
if(name.size() == 2)
return new EMSA4(name[1], "MGF1");
@@ -51,10 +83,9 @@ EMSA* get_emsa(const std::string& algo_spec)
if(name.size() == 4)
return new EMSA4(name[1], name[2], to_u32bit(name[3]));
}
- else
- throw Algorithm_Not_Found(algo_spec);
+#endif
- throw Invalid_Algorithm_Name(algo_spec);
+ throw Algorithm_Not_Found(algo_spec);
}
/*************************************************
@@ -70,17 +101,16 @@ EME* get_eme(const std::string& algo_spec)
if(name.size() == 1)
return new EME_PKCS1v15;
}
- else if(eme_name == "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]);
}
- else
- throw Algorithm_Not_Found(algo_spec);
- throw Invalid_Algorithm_Name(algo_spec);
+ throw Algorithm_Not_Found(algo_spec);
}
/*************************************************
@@ -96,30 +126,32 @@ KDF* get_kdf(const std::string& algo_spec)
if(name.size() == 2)
return new KDF1(name[1]);
}
- else if(kdf_name == "KDF2")
+
+ if(kdf_name == "KDF2")
{
if(name.size() == 2)
return new KDF2(name[1]);
}
- else if(kdf_name == "X9.42-PRF")
+
+ if(kdf_name == "X9.42-PRF")
{
if(name.size() == 2)
return new X942_PRF(name[1]);
}
+
if(kdf_name == "TLS-PRF")
{
if(name.size() == 1)
return new TLS_PRF;
}
- else if(kdf_name == "SSL3-PRF")
+
+ if(kdf_name == "SSL3-PRF")
{
if(name.size() == 1)
return new SSL3_PRF;
}
- else
- throw Algorithm_Not_Found(algo_spec);
- throw Invalid_Algorithm_Name(algo_spec);
+ throw Algorithm_Not_Found(algo_spec);
}
/*************************************************
@@ -135,10 +167,8 @@ MGF* get_mgf(const std::string& algo_spec)
if(name.size() == 2)
return new MGF1(get_hash(name[1]));
}
- else
- throw Algorithm_Not_Found(algo_spec);
- throw Invalid_Algorithm_Name(algo_spec);
+ throw Algorithm_Not_Found(algo_spec);
}
}