aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
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
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')
-rw-r--r--src/lib/kdf/kdf.cpp2
-rw-r--r--src/lib/kdf/kdf.h2
-rw-r--r--src/lib/pbkdf/info.txt4
-rw-r--r--src/lib/pbkdf/pbkdf.cpp20
-rw-r--r--src/lib/pbkdf/pbkdf1/pbkdf1.cpp3
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.cpp4
-rw-r--r--src/lib/pbkdf/pbkdf_utils.h23
-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
-rw-r--r--src/lib/pubkey/ecdh/ecdh.cpp2
-rw-r--r--src/lib/pubkey/ecdh/ecdh.h2
24 files changed, 149 insertions, 110 deletions
diff --git a/src/lib/kdf/kdf.cpp b/src/lib/kdf/kdf.cpp
index 89bb8d58a..836e9b982 100644
--- a/src/lib/kdf/kdf.cpp
+++ b/src/lib/kdf/kdf.cpp
@@ -34,6 +34,8 @@
namespace Botan {
+KDF::~KDF() {}
+
KDF* get_kdf(const std::string& algo_spec)
{
SCAN_Name request(algo_spec);
diff --git a/src/lib/kdf/kdf.h b/src/lib/kdf/kdf.h
index d69c1ece5..936e7c5f1 100644
--- a/src/lib/kdf/kdf.h
+++ b/src/lib/kdf/kdf.h
@@ -21,7 +21,7 @@ namespace Botan {
class BOTAN_DLL KDF
{
public:
- virtual ~KDF() {}
+ virtual ~KDF();
virtual std::string name() const = 0;
diff --git a/src/lib/pbkdf/info.txt b/src/lib/pbkdf/info.txt
index 81f7c1260..3addbdb58 100644
--- a/src/lib/pbkdf/info.txt
+++ b/src/lib/pbkdf/info.txt
@@ -7,7 +7,3 @@ base
<header:public>
pbkdf.h
</header:public>
-
-<header:internal>
-pbkdf_utils.h
-</header:internal>
diff --git a/src/lib/pbkdf/pbkdf.cpp b/src/lib/pbkdf/pbkdf.cpp
index 7f0a68a01..f11fbc44d 100644
--- a/src/lib/pbkdf/pbkdf.cpp
+++ b/src/lib/pbkdf/pbkdf.cpp
@@ -6,10 +6,30 @@
*/
#include <botan/pbkdf.h>
+#include <botan/internal/algo_registry.h>
#include <stdexcept>
+#if defined(BOTAN_HAS_PBKDF1)
+#include <botan/pbkdf1.h>
+#endif
+
+#if defined(BOTAN_HAS_PBKDF2)
+#include <botan/pbkdf2.h>
+#endif
+
namespace Botan {
+#define BOTAN_REGISTER_PBKDF_1HASH(type, name) \
+ BOTAN_REGISTER_NAMED_T(PBKDF, name, type, (make_new_T_1X<type, HashFunction>))
+
+#if defined(BOTAN_HAS_PBKDF1)
+BOTAN_REGISTER_PBKDF_1HASH(PKCS5_PBKDF1, "PBKDF1");
+#endif
+
+#if defined(BOTAN_HAS_PBKDF2)
+BOTAN_REGISTER_NAMED_T(PBKDF, "PBKDF2", PKCS5_PBKDF2, PKCS5_PBKDF2::make);
+#endif
+
void PBKDF::pbkdf_timed(byte out[], size_t out_len,
const std::string& passphrase,
const byte salt[], size_t salt_len,
diff --git a/src/lib/pbkdf/pbkdf1/pbkdf1.cpp b/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
index 28bac9572..49e1cf268 100644
--- a/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
+++ b/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
@@ -5,14 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pbkdf_utils.h>
#include <botan/pbkdf1.h>
#include <botan/exceptn.h>
namespace Botan {
-BOTAN_REGISTER_PBKDF_1HASH(PKCS5_PBKDF1, "PBKDF1");
-
size_t PKCS5_PBKDF1::pbkdf(byte output_buf[], size_t output_len,
const std::string& passphrase,
const byte salt[], size_t salt_len,
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
index a27b9b15c..a5b7f011e 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
@@ -5,16 +5,14 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/pbkdf_utils.h>
#include <botan/pbkdf2.h>
+#include <botan/lookup.h>
#include <botan/get_byte.h>
#include <botan/internal/xor_buf.h>
#include <botan/internal/rounding.h>
namespace Botan {
-BOTAN_REGISTER_NAMED_T(PBKDF, "PBKDF2", PKCS5_PBKDF2, PKCS5_PBKDF2::make);
-
PKCS5_PBKDF2* PKCS5_PBKDF2::make(const Spec& spec)
{
if(auto mac = get_mac(spec.arg(0)))
diff --git a/src/lib/pbkdf/pbkdf_utils.h b/src/lib/pbkdf/pbkdf_utils.h
deleted file mode 100644
index 480fc70eb..000000000
--- a/src/lib/pbkdf/pbkdf_utils.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* PBKDF Utility Header
-* (C) 2015 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#ifndef BOTAN_PBKDF_UTILS_H__
-#define BOTAN_PBKDF_UTILS_H__
-
-#include <botan/pbkdf.h>
-#include <botan/internal/algo_registry.h>
-
-namespace Botan {
-
-#define BOTAN_REGISTER_PBKDF_1HASH(type, name) \
- BOTAN_REGISTER_NAMED_T(PBKDF, name, type, (make_new_T_1X<type, HashFunction>))
-#define BOTAN_REGISTER_PBKDF_1MAC(type, name) \
- BOTAN_REGISTER_NAMED_T(PBKDF, name, type, (make_new_T_1X<type, MessageAuthenticationCode>))
-
-}
-
-#endif
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 {
diff --git a/src/lib/pubkey/ecdh/ecdh.cpp b/src/lib/pubkey/ecdh/ecdh.cpp
index bad0f2c0b..6b589df9b 100644
--- a/src/lib/pubkey/ecdh/ecdh.cpp
+++ b/src/lib/pubkey/ecdh/ecdh.cpp
@@ -12,6 +12,8 @@
namespace Botan {
+ECDH_PublicKey::ECDH_PublicKey() {}
+
namespace {
/**
diff --git a/src/lib/pubkey/ecdh/ecdh.h b/src/lib/pubkey/ecdh/ecdh.h
index ef3e8ef7a..2f892436c 100644
--- a/src/lib/pubkey/ecdh/ecdh.h
+++ b/src/lib/pubkey/ecdh/ecdh.h
@@ -56,7 +56,7 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey
{ return unlock(EC2OSP(public_point(), PointGFp::UNCOMPRESSED)); }
protected:
- ECDH_PublicKey() {}
+ ECDH_PublicKey();
};
/**