aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-09-11 22:44:45 -0400
committerJack Lloyd <[email protected]>2015-09-11 22:44:45 -0400
commit72719f52640d2ac3ff00fce46a72082e5938d212 (patch)
tree51018f639724326c0e967eb7372a762ce0b89e53 /src/lib/pk_pad
parent8211fdc11fa3bbe692b50d42126f74d259a4a96a (diff)
Fix pbkdf, pk padding and ECDH registration for static linking.
With this change the tests pass when linked against a static library built in the normal (non-amalgamation) fashion. Remove the restriction in configure.py, and have circleci build the clang static build as a non-amalg.
Diffstat (limited to 'src/lib/pk_pad')
-rw-r--r--src/lib/pk_pad/eme.cpp38
-rw-r--r--src/lib/pk_pad/eme_oaep/oaep.cpp6
-rw-r--r--src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp3
-rw-r--r--src/lib/pk_pad/eme_raw/eme_raw.cpp3
-rw-r--r--src/lib/pk_pad/emsa.cpp74
-rw-r--r--src/lib/pk_pad/emsa.h7
-rw-r--r--src/lib/pk_pad/emsa1/emsa1.cpp3
-rw-r--r--src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp3
-rw-r--r--src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp8
-rw-r--r--src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h2
-rw-r--r--src/lib/pk_pad/emsa_pssr/pssr.cpp4
-rw-r--r--src/lib/pk_pad/emsa_raw/emsa_raw.cpp2
-rw-r--r--src/lib/pk_pad/emsa_x931/emsa_x931.cpp3
-rw-r--r--src/lib/pk_pad/get_pk_pad.cpp38
-rw-r--r--src/lib/pk_pad/pad_utils.h3
15 files changed, 122 insertions, 75 deletions
diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp
index 9398b4c83..153ef8922 100644
--- a/src/lib/pk_pad/eme.cpp
+++ b/src/lib/pk_pad/eme.cpp
@@ -6,9 +6,47 @@
*/
#include <botan/eme.h>
+#include <botan/internal/pad_utils.h>
+
+#if defined(BOTAN_HAS_EME_OAEP)
+#include <botan/oaep.h>
+#endif
+
+#if defined(BOTAN_HAS_EME_PKCS1v15)
+#include <botan/eme_pkcs.h>
+#endif
+
+#if defined(BOTAN_HAS_EME_RAW)
+#include <botan/eme_raw.h>
+#endif
namespace Botan {
+#if defined(BOTAN_HAS_EME_OAEP)
+BOTAN_REGISTER_NAMED_T(EME, "OAEP", OAEP, OAEP::make);
+#endif
+
+#if defined(BOTAN_HAS_EME_PKCS1v15)
+BOTAN_REGISTER_EME_NAMED_NOARGS(EME_PKCS1v15, "PKCS1v15");
+#endif
+
+#if defined(BOTAN_HAS_EME_RAW)
+BOTAN_REGISTER_EME_NAMED_NOARGS(EME_Raw, "Raw");
+#endif
+
+EME* get_eme(const std::string& algo_spec)
+ {
+ SCAN_Name request(algo_spec);
+
+ if(EME* eme = make_a<EME>(algo_spec))
+ return eme;
+
+ if(request.algo_name() == "Raw")
+ return nullptr; // No padding
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
/*
* Encode a message
*/
diff --git a/src/lib/pk_pad/eme_oaep/oaep.cpp b/src/lib/pk_pad/eme_oaep/oaep.cpp
index 871f40142..a484202da 100644
--- a/src/lib/pk_pad/eme_oaep/oaep.cpp
+++ b/src/lib/pk_pad/eme_oaep/oaep.cpp
@@ -5,11 +5,10 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pad_utils.h>
#include <botan/oaep.h>
#include <botan/mgf1.h>
#include <botan/mem_ops.h>
-
+#include <botan/lookup.h>
namespace Botan {
@@ -28,9 +27,6 @@ OAEP* OAEP::make(const Spec& request)
return nullptr;
}
-BOTAN_REGISTER_NAMED_T(EME, "OAEP", OAEP, OAEP::make);
-
-
/*
* OAEP Pad Operation
*/
diff --git a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
index 90af17565..65d29cd59 100644
--- a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
+++ b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
@@ -5,13 +5,10 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pad_utils.h>
#include <botan/eme_pkcs.h>
namespace Botan {
-BOTAN_REGISTER_EME_NAMED_NOARGS(EME_PKCS1v15, "PKCS1v15");
-
/*
* PKCS1 Pad Operation
*/
diff --git a/src/lib/pk_pad/eme_raw/eme_raw.cpp b/src/lib/pk_pad/eme_raw/eme_raw.cpp
index 9ae894c70..78b670b65 100644
--- a/src/lib/pk_pad/eme_raw/eme_raw.cpp
+++ b/src/lib/pk_pad/eme_raw/eme_raw.cpp
@@ -4,14 +4,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pad_utils.h>
#include <botan/internal/bit_ops.h>
#include <botan/eme_raw.h>
namespace Botan {
-BOTAN_REGISTER_EME_NAMED_NOARGS(EME_Raw, "Raw");
-
secure_vector<byte> EME_Raw::pad(const byte in[], size_t in_length,
size_t key_bits,
RandomNumberGenerator&) const
diff --git a/src/lib/pk_pad/emsa.cpp b/src/lib/pk_pad/emsa.cpp
new file mode 100644
index 000000000..9682d9b6e
--- /dev/null
+++ b/src/lib/pk_pad/emsa.cpp
@@ -0,0 +1,74 @@
+/*
+* (C) 2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/emsa.h>
+#include <botan/internal/pad_utils.h>
+
+#if defined(BOTAN_HAS_EMSA1)
+ #include <botan/emsa1.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA1_BSI)
+ #include <botan/emsa1_bsi.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA_X931)
+ #include <botan/emsa_x931.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA_PKCS1)
+ #include <botan/emsa_pkcs1.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA_PSSR)
+ #include <botan/pssr.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA_RAW)
+ #include <botan/emsa_raw.h>
+#endif
+
+namespace Botan {
+
+EMSA::~EMSA() {}
+
+EMSA* get_emsa(const std::string& algo_spec)
+ {
+ SCAN_Name request(algo_spec);
+
+ if(EMSA* emsa = make_a<EMSA>(algo_spec))
+ return emsa;
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
+#if defined(BOTAN_HAS_EMSA1)
+BOTAN_REGISTER_EMSA_1HASH(EMSA1, "EMSA1");
+#endif
+
+#if defined(BOTAN_HAS_EMSA1_BSI)
+BOTAN_REGISTER_EMSA_1HASH(EMSA1_BSI, "EMSA1_BSI");
+#endif
+
+#if defined(BOTAN_HAS_EMSA_PKCS1)
+BOTAN_REGISTER_NAMED_T(EMSA, "EMSA_PKCS1", EMSA_PCS1v15, EMSA_PKCS1v15::make);
+#endif
+
+#if defined(BOTAN_HAS_EMSA_PSSR)
+BOTAN_REGISTER_NAMED_T(EMSA, "PSSR", PSSR, PSSR::make);
+#endif
+
+#if defined(BOTAN_HAS_EMSA_X931)
+BOTAN_REGISTER_EMSA_1HASH(EMSA_X931, "EMSA_X931");
+#endif
+
+#if defined(BOTAN_HAS_EMSA_RAW)
+BOTAN_REGISTER_EMSA_NAMED_NOARGS(EMSA_Raw, "Raw");
+#endif
+
+}
+
+
diff --git a/src/lib/pk_pad/emsa.h b/src/lib/pk_pad/emsa.h
index b0295636c..d4fd146da 100644
--- a/src/lib/pk_pad/emsa.h
+++ b/src/lib/pk_pad/emsa.h
@@ -15,7 +15,9 @@
namespace Botan {
/**
-* Encoding Method for Signatures, Appendix
+* EMSA, from IEEE 1363s Encoding Method for Signatures, Appendix
+*
+* Any way of encoding/padding signatures
*/
class BOTAN_DLL EMSA
{
@@ -55,7 +57,8 @@ class BOTAN_DLL EMSA
virtual bool verify(const secure_vector<byte>& coded,
const secure_vector<byte>& raw,
size_t key_bits) = 0;
- virtual ~EMSA() {}
+
+ virtual ~EMSA();
};
/**
diff --git a/src/lib/pk_pad/emsa1/emsa1.cpp b/src/lib/pk_pad/emsa1/emsa1.cpp
index 89f0d244a..0031bf263 100644
--- a/src/lib/pk_pad/emsa1/emsa1.cpp
+++ b/src/lib/pk_pad/emsa1/emsa1.cpp
@@ -5,13 +5,10 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pad_utils.h>
#include <botan/emsa1.h>
namespace Botan {
-BOTAN_REGISTER_EMSA_1HASH(EMSA1, "EMSA1");
-
namespace {
secure_vector<byte> emsa1_encoding(const secure_vector<byte>& msg,
diff --git a/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp
index 81a168b7d..5fc96da8d 100644
--- a/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp
+++ b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp
@@ -6,13 +6,10 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pad_utils.h>
#include <botan/emsa1_bsi.h>
namespace Botan {
-BOTAN_REGISTER_EMSA_1HASH(EMSA1_BSI, "EMSA1_BSI");
-
/*
* EMSA1 BSI Encode Operation
*/
diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
index e6ce5ec2f..d928511d3 100644
--- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
+++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
@@ -11,9 +11,7 @@
namespace Botan {
-namespace {
-
-EMSA* make_pkcs1v15(const EMSA::Spec& spec)
+EMSA* EMSA_PKCS1v15::make(const EMSA::Spec& spec)
{
if(spec.arg(0) == "Raw")
return new EMSA_PKCS1v15_Raw;
@@ -25,10 +23,6 @@ EMSA* make_pkcs1v15(const EMSA::Spec& spec)
return nullptr;
}
-}
-
-BOTAN_REGISTER_NAMED_T(EMSA, "EMSA_PKCS1", EMSA_PCS1v15, make_pkcs1v15);
-
namespace {
secure_vector<byte> emsa3_encoding(const secure_vector<byte>& msg,
diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
index 7bcae3bd1..19886f80c 100644
--- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
+++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
@@ -21,6 +21,8 @@ namespace Botan {
class BOTAN_DLL EMSA_PKCS1v15 : public EMSA
{
public:
+ static EMSA* make(const EMSA::Spec& spec);
+
/**
* @param hash the hash object to use
*/
diff --git a/src/lib/pk_pad/emsa_pssr/pssr.cpp b/src/lib/pk_pad/emsa_pssr/pssr.cpp
index a4744f8f4..06ca007c8 100644
--- a/src/lib/pk_pad/emsa_pssr/pssr.cpp
+++ b/src/lib/pk_pad/emsa_pssr/pssr.cpp
@@ -5,10 +5,10 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pad_utils.h>
#include <botan/pssr.h>
#include <botan/mgf1.h>
#include <botan/internal/bit_ops.h>
+#include <botan/lookup.h>
namespace Botan {
@@ -26,8 +26,6 @@ PSSR* PSSR::make(const Spec& request)
return nullptr;
}
-BOTAN_REGISTER_NAMED_T(EMSA, "PSSR", PSSR, PSSR::make);
-
/*
* PSSR Update Operation
*/
diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
index dcce888f2..287acb233 100644
--- a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
+++ b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_EMSA_NAMED_NOARGS(EMSA_Raw, "Raw");
-
/*
* EMSA-Raw Encode Operation
*/
diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
index fb1e4343a..2feedee1c 100644
--- a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
+++ b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
@@ -5,14 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pad_utils.h>
#include <botan/emsa_x931.h>
#include <botan/hash_id.h>
namespace Botan {
-BOTAN_REGISTER_EMSA_1HASH(EMSA_X931, "EMSA_X931");
-
namespace {
secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg,
diff --git a/src/lib/pk_pad/get_pk_pad.cpp b/src/lib/pk_pad/get_pk_pad.cpp
deleted file mode 100644
index 691de23e2..000000000
--- a/src/lib/pk_pad/get_pk_pad.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-* EMSA/EME Retrieval
-* (C) 1999-2007 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#include <botan/emsa.h>
-#include <botan/eme.h>
-#include <botan/scan_name.h>
-#include <botan/internal/algo_registry.h>
-
-namespace Botan {
-
-EMSA* get_emsa(const std::string& algo_spec)
- {
- SCAN_Name request(algo_spec);
-
- if(EMSA* emsa = make_a<EMSA>(algo_spec))
- return emsa;
-
- throw Algorithm_Not_Found(algo_spec);
- }
-
-EME* get_eme(const std::string& algo_spec)
- {
- SCAN_Name request(algo_spec);
-
- if(EME* eme = make_a<EME>(algo_spec))
- return eme;
-
- if(request.algo_name() == "Raw")
- return nullptr; // No padding
-
- throw Algorithm_Not_Found(algo_spec);
- }
-
-}
diff --git a/src/lib/pk_pad/pad_utils.h b/src/lib/pk_pad/pad_utils.h
index 3918e133a..ba2de65ea 100644
--- a/src/lib/pk_pad/pad_utils.h
+++ b/src/lib/pk_pad/pad_utils.h
@@ -9,9 +9,6 @@
#define BOTAN_PK_PAD_UTILS_H__
#include <botan/internal/algo_registry.h>
-#include <botan/internal/xor_buf.h>
-#include <botan/loadstor.h>
-#include <algorithm>
namespace Botan {