aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-09-10 01:45:47 -0400
committerJack Lloyd <[email protected]>2015-09-10 01:45:47 -0400
commitd21de17f070863c7e0b7e8d254eb35689001a53a (patch)
tree2627df5d3c911a56dea6a56aeca693a73d66f85e /src/lib/hash
parenta96a7b79662f5045f0810dfa5d5cb4ebbd04ae42 (diff)
Fix static lib registration for block, hash, mac, stream, kdf
The support problems from having static libraries not work in the obvious way will be endless trouble. Instead have each set of registrations tag along in a source file for the basic type, at the cost of some extra ifdefs. On shared libs this is harmless - everything is going into the shared object anyway. With static libs, this means pulling in a single block cipher pulls in the text of all the them. But that's still strictly better than the amalgamation (which is really pulling in everything), and it works (unlike status quo).
Diffstat (limited to 'src/lib/hash')
-rw-r--r--src/lib/hash/checksum/adler32/adler32.cpp2
-rw-r--r--src/lib/hash/checksum/crc24/crc24.cpp2
-rw-r--r--src/lib/hash/checksum/crc32/crc32.cpp2
-rw-r--r--src/lib/hash/comb4p/comb4p.cpp2
-rw-r--r--src/lib/hash/gost_3411/gost_3411.cpp2
-rw-r--r--src/lib/hash/has160/has160.cpp2
-rw-r--r--src/lib/hash/hash.cpp180
-rw-r--r--src/lib/hash/hash.h6
-rw-r--r--src/lib/hash/keccak/keccak.cpp2
-rw-r--r--src/lib/hash/md2/md2.cpp2
-rw-r--r--src/lib/hash/md4/md4.cpp2
-rw-r--r--src/lib/hash/md5/md5.cpp2
-rw-r--r--src/lib/hash/par_hash/par_hash.cpp2
-rw-r--r--src/lib/hash/rmd128/rmd128.cpp2
-rw-r--r--src/lib/hash/rmd160/rmd160.cpp2
-rw-r--r--src/lib/hash/sha1/sha160.cpp2
-rw-r--r--src/lib/hash/sha1_sse2/sha1_sse2.cpp3
-rw-r--r--src/lib/hash/sha2_32/sha2_32.cpp3
-rw-r--r--src/lib/hash/sha2_64/sha2_64.cpp4
-rw-r--r--src/lib/hash/skein/skein_512.cpp2
-rw-r--r--src/lib/hash/tiger/tiger.cpp2
-rw-r--r--src/lib/hash/whirlpool/whirlpool.cpp2
22 files changed, 184 insertions, 46 deletions
diff --git a/src/lib/hash/checksum/adler32/adler32.cpp b/src/lib/hash/checksum/adler32/adler32.cpp
index f2385c5b8..aadc5d39f 100644
--- a/src/lib/hash/checksum/adler32/adler32.cpp
+++ b/src/lib/hash/checksum/adler32/adler32.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS(Adler32);
-
namespace {
void adler32_update(const byte input[], size_t length,
diff --git a/src/lib/hash/checksum/crc24/crc24.cpp b/src/lib/hash/checksum/crc24/crc24.cpp
index 4f747c232..054d23684 100644
--- a/src/lib/hash/checksum/crc24/crc24.cpp
+++ b/src/lib/hash/checksum/crc24/crc24.cpp
@@ -11,8 +11,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS(CRC24);
-
/*
* Update a CRC24 Checksum
*/
diff --git a/src/lib/hash/checksum/crc32/crc32.cpp b/src/lib/hash/checksum/crc32/crc32.cpp
index cb4ff7b5f..ca9514c26 100644
--- a/src/lib/hash/checksum/crc32/crc32.cpp
+++ b/src/lib/hash/checksum/crc32/crc32.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS(CRC32);
-
/*
* Update a CRC32 Checksum
*/
diff --git a/src/lib/hash/comb4p/comb4p.cpp b/src/lib/hash/comb4p/comb4p.cpp
index 843c530ef..ec39bbc31 100644
--- a/src/lib/hash/comb4p/comb4p.cpp
+++ b/src/lib/hash/comb4p/comb4p.cpp
@@ -12,8 +12,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T(HashFunction, "Comb4P", Comb4P, Comb4P::make);
-
namespace {
void comb4p_round(secure_vector<byte>& out,
diff --git a/src/lib/hash/gost_3411/gost_3411.cpp b/src/lib/hash/gost_3411/gost_3411.cpp
index 918556ca0..fb1c39384 100644
--- a/src/lib/hash/gost_3411/gost_3411.cpp
+++ b/src/lib/hash/gost_3411/gost_3411.cpp
@@ -11,8 +11,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NAMED_NOARGS(GOST_34_11, "GOST-R-34.11-94");
-
/**
* GOST 34.11 Constructor
*/
diff --git a/src/lib/hash/has160/has160.cpp b/src/lib/hash/has160/has160.cpp
index 2f2a5f9de..dd4bc1428 100644
--- a/src/lib/hash/has160/has160.cpp
+++ b/src/lib/hash/has160/has160.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NAMED_NOARGS(HAS_160, "HAS-160");
-
namespace HAS_160_F {
/*
diff --git a/src/lib/hash/hash.cpp b/src/lib/hash/hash.cpp
new file mode 100644
index 000000000..723a7eba7
--- /dev/null
+++ b/src/lib/hash/hash.cpp
@@ -0,0 +1,180 @@
+/*
+* Hash Functions
+* (C) 2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/hash.h>
+#include <botan/cpuid.h>
+#include <botan/internal/hash_utils.h>
+
+#if defined(BOTAN_HAS_ADLER32)
+ #include <botan/adler32.h>
+#endif
+
+#if defined(BOTAN_HAS_CRC24)
+ #include <botan/crc24.h>
+#endif
+
+#if defined(BOTAN_HAS_CRC32)
+ #include <botan/crc32.h>
+#endif
+
+#if defined(BOTAN_HAS_GOST_34_11)
+ #include <botan/gost_3411.h>
+#endif
+
+#if defined(BOTAN_HAS_HAS_160)
+ #include <botan/has160.h>
+#endif
+
+#if defined(BOTAN_HAS_KECCAK)
+ #include <botan/keccak.h>
+#endif
+
+#if defined(BOTAN_HAS_MD2)
+ #include <botan/md2.h>
+#endif
+
+#if defined(BOTAN_HAS_MD4)
+ #include <botan/md4.h>
+#endif
+
+#if defined(BOTAN_HAS_MD5)
+ #include <botan/md5.h>
+#endif
+
+#if defined(BOTAN_HAS_RIPEMD_128)
+ #include <botan/rmd128.h>
+#endif
+
+#if defined(BOTAN_HAS_RIPEMD_160)
+ #include <botan/rmd160.h>
+#endif
+
+#if defined(BOTAN_HAS_SHA1)
+ #include <botan/sha160.h>
+#endif
+
+#if defined(BOTAN_HAS_SHA1_SSE2)
+ #include <botan/sha1_sse2.h>
+#endif
+
+#if defined(BOTAN_HAS_SHA2_32)
+ #include <botan/sha2_32.h>
+#endif
+
+#if defined(BOTAN_HAS_SHA2_64)
+ #include <botan/sha2_64.h>
+#endif
+
+#if defined(BOTAN_HAS_SKEIN_512)
+ #include <botan/skein_512.h>
+#endif
+
+#if defined(BOTAN_HAS_TIGER)
+ #include <botan/tiger.h>
+#endif
+
+#if defined(BOTAN_HAS_WHIRLPOOL)
+ #include <botan/whrlpool.h>
+#endif
+
+#if defined(BOTAN_HAS_PARALLEL_HASH)
+ #include <botan/par_hash.h>
+#endif
+
+#if defined(BOTAN_HAS_COMB4P)
+ #include <botan/comb4p.h>
+#endif
+
+namespace Botan {
+
+HashFunction::~HashFunction() {}
+
+#if defined(BOTAN_HAS_ADLER32)
+BOTAN_REGISTER_HASH_NOARGS(Adler32);
+#endif
+
+#if defined(BOTAN_HAS_CRC24)
+BOTAN_REGISTER_HASH_NOARGS(CRC24);
+#endif
+
+#if defined(BOTAN_HAS_CRC32)
+BOTAN_REGISTER_HASH_NOARGS(CRC32);
+#endif
+
+#if defined(BOTAN_HAS_COMB4P)
+BOTAN_REGISTER_NAMED_T(HashFunction, "Comb4P", Comb4P, Comb4P::make);
+#endif
+
+#if defined(BOTAN_HAS_PARALLEL_HASH)
+BOTAN_REGISTER_NAMED_T(HashFunction, "Parallel", Parallel, Parallel::make);
+#endif
+
+#if defined(BOTAN_HAS_GOST_34_11)
+BOTAN_REGISTER_HASH_NAMED_NOARGS(GOST_34_11, "GOST-R-34.11-94");
+#endif
+
+#if defined(BOTAN_HAS_HAS_160)
+BOTAN_REGISTER_HASH_NAMED_NOARGS(HAS_160, "HAS-160");
+#endif
+
+#if defined(BOTAN_HAS_KECCAK)
+BOTAN_REGISTER_HASH_NAMED_1LEN(Keccak_1600, "Keccak-1600", 512);
+#endif
+
+#if defined(BOTAN_HAS_MD2)
+BOTAN_REGISTER_HASH_NOARGS(MD2);
+#endif
+
+#if defined(BOTAN_HAS_MD4)
+BOTAN_REGISTER_HASH_NOARGS(MD4);
+#endif
+
+#if defined(BOTAN_HAS_MD5)
+BOTAN_REGISTER_HASH_NOARGS(MD5);
+#endif
+
+#if defined(BOTAN_HAS_RIPEMD_128)
+BOTAN_REGISTER_HASH_NAMED_NOARGS(RIPEMD_128, "RIPEMD-128");
+#endif
+
+#if defined(BOTAN_HAS_RIPEMD_160)
+BOTAN_REGISTER_HASH_NAMED_NOARGS(RIPEMD_160, "RIPEMD-160");
+#endif
+
+#if defined(BOTAN_HAS_SHA1)
+BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_160, "SHA-160");
+#endif
+
+#if defined(BOTAN_HAS_SHA1_SSE2)
+BOTAN_REGISTER_HASH_NOARGS_IF(CPUID::has_sse2(), SHA_160_SSE2, "SHA-160",
+ "sse2", BOTAN_SIMD_ALGORITHM_PRIO);
+#endif
+
+#if defined(BOTAN_HAS_SHA2_32)
+BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_224, "SHA-224");
+BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_256, "SHA-256");
+#endif
+
+#if defined(BOTAN_HAS_SHA2_64)
+BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_384, "SHA-384");
+BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_512, "SHA-512");
+BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_512_256, "SHA-512-256");
+#endif
+
+#if defined(BOTAN_HAS_TIGER)
+BOTAN_REGISTER_NAMED_T_2LEN(HashFunction, Tiger, "Tiger", "base", 24, 3);
+#endif
+
+#if defined(BOTAN_HAS_SKEIN_512)
+BOTAN_REGISTER_NAMED_T(HashFunction, "Skein-512", Skein_512, Skein_512::make);
+#endif
+
+#if defined(BOTAN_HAS_WHIRLPOOL)
+BOTAN_REGISTER_HASH_NOARGS(Whirlpool);
+#endif
+
+}
diff --git a/src/lib/hash/hash.h b/src/lib/hash/hash.h
index 9b2ca0d3b..8406a4c0f 100644
--- a/src/lib/hash/hash.h
+++ b/src/lib/hash/hash.h
@@ -20,11 +20,15 @@ namespace Botan {
class BOTAN_DLL HashFunction : public Buffered_Computation
{
public:
+ typedef SCAN_Name Spec;
+
/**
* @return new object representing the same algorithm as *this
*/
virtual HashFunction* clone() const = 0;
+ virtual ~HashFunction();
+
virtual void clear() = 0;
virtual std::string name() const = 0;
@@ -33,8 +37,6 @@ class BOTAN_DLL HashFunction : public Buffered_Computation
* @return hash block size as defined for this algorithm
*/
virtual size_t hash_block_size() const { return 0; }
-
- typedef SCAN_Name Spec;
};
}
diff --git a/src/lib/hash/keccak/keccak.cpp b/src/lib/hash/keccak/keccak.cpp
index 8ee2357b6..3cebe42da 100644
--- a/src/lib/hash/keccak/keccak.cpp
+++ b/src/lib/hash/keccak/keccak.cpp
@@ -13,8 +13,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NAMED_1LEN(Keccak_1600, "Keccak-1600", 512);
-
namespace {
void keccak_f_1600(u64bit A[25])
diff --git a/src/lib/hash/md2/md2.cpp b/src/lib/hash/md2/md2.cpp
index 6543cf1a0..8b8810941 100644
--- a/src/lib/hash/md2/md2.cpp
+++ b/src/lib/hash/md2/md2.cpp
@@ -11,8 +11,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS(MD2);
-
/**
* MD2 Compression Function
*/
diff --git a/src/lib/hash/md4/md4.cpp b/src/lib/hash/md4/md4.cpp
index cc11baafa..f8cbb2b6b 100644
--- a/src/lib/hash/md4/md4.cpp
+++ b/src/lib/hash/md4/md4.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS(MD4);
-
namespace {
/*
diff --git a/src/lib/hash/md5/md5.cpp b/src/lib/hash/md5/md5.cpp
index 2ce8df48a..61d8aa980 100644
--- a/src/lib/hash/md5/md5.cpp
+++ b/src/lib/hash/md5/md5.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS(MD5);
-
namespace {
/*
diff --git a/src/lib/hash/par_hash/par_hash.cpp b/src/lib/hash/par_hash/par_hash.cpp
index b6133929c..12271640a 100644
--- a/src/lib/hash/par_hash/par_hash.cpp
+++ b/src/lib/hash/par_hash/par_hash.cpp
@@ -11,8 +11,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T(HashFunction, "Parallel", Parallel, Parallel::make);
-
Parallel* Parallel::make(const Spec& spec)
{
std::vector<std::unique_ptr<HashFunction>> hashes;
diff --git a/src/lib/hash/rmd128/rmd128.cpp b/src/lib/hash/rmd128/rmd128.cpp
index 7138d54d7..1f655199e 100644
--- a/src/lib/hash/rmd128/rmd128.cpp
+++ b/src/lib/hash/rmd128/rmd128.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NAMED_NOARGS(RIPEMD_128, "RIPEMD-128");
-
namespace RIPEMD_128_F {
/*
diff --git a/src/lib/hash/rmd160/rmd160.cpp b/src/lib/hash/rmd160/rmd160.cpp
index dad1d367a..c1b1032ae 100644
--- a/src/lib/hash/rmd160/rmd160.cpp
+++ b/src/lib/hash/rmd160/rmd160.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NAMED_NOARGS(RIPEMD_160, "RIPEMD-160");
-
namespace {
/*
diff --git a/src/lib/hash/sha1/sha160.cpp b/src/lib/hash/sha1/sha160.cpp
index 96bc2c682..04227c6bb 100644
--- a/src/lib/hash/sha1/sha160.cpp
+++ b/src/lib/hash/sha1/sha160.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_160, "SHA-160");
-
namespace SHA1_F {
namespace {
diff --git a/src/lib/hash/sha1_sse2/sha1_sse2.cpp b/src/lib/hash/sha1_sse2/sha1_sse2.cpp
index 7cd457597..fefea52af 100644
--- a/src/lib/hash/sha1_sse2/sha1_sse2.cpp
+++ b/src/lib/hash/sha1_sse2/sha1_sse2.cpp
@@ -14,9 +14,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS_IF(CPUID::has_sse2(), SHA_160_SSE2, "SHA-160",
- "sse2", BOTAN_SIMD_ALGORITHM_PRIO);
-
namespace SHA1_SSE2_F {
namespace {
diff --git a/src/lib/hash/sha2_32/sha2_32.cpp b/src/lib/hash/sha2_32/sha2_32.cpp
index b06d485aa..a867e6dd0 100644
--- a/src/lib/hash/sha2_32/sha2_32.cpp
+++ b/src/lib/hash/sha2_32/sha2_32.cpp
@@ -11,9 +11,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_224, "SHA-224");
-BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_256, "SHA-256");
-
namespace {
namespace SHA2_32 {
diff --git a/src/lib/hash/sha2_64/sha2_64.cpp b/src/lib/hash/sha2_64/sha2_64.cpp
index 733cf0f19..98d16900b 100644
--- a/src/lib/hash/sha2_64/sha2_64.cpp
+++ b/src/lib/hash/sha2_64/sha2_64.cpp
@@ -10,10 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_384, "SHA-384");
-BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_512, "SHA-512");
-BOTAN_REGISTER_HASH_NAMED_NOARGS(SHA_512_256, "SHA-512-256");
-
namespace {
namespace SHA2_64 {
diff --git a/src/lib/hash/skein/skein_512.cpp b/src/lib/hash/skein/skein_512.cpp
index 5e186b996..ce0e8353d 100644
--- a/src/lib/hash/skein/skein_512.cpp
+++ b/src/lib/hash/skein/skein_512.cpp
@@ -14,8 +14,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T(HashFunction, "Skein-512", Skein_512, Skein_512::make);
-
Skein_512* Skein_512::make(const Spec& spec)
{
return new Skein_512(spec.arg_as_integer(0, 512), spec.arg(1, ""));
diff --git a/src/lib/hash/tiger/tiger.cpp b/src/lib/hash/tiger/tiger.cpp
index c6dec2f33..d724c3da8 100644
--- a/src/lib/hash/tiger/tiger.cpp
+++ b/src/lib/hash/tiger/tiger.cpp
@@ -12,8 +12,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T_2LEN(HashFunction, Tiger, "Tiger", "base", 24, 3);
-
namespace {
/*
diff --git a/src/lib/hash/whirlpool/whirlpool.cpp b/src/lib/hash/whirlpool/whirlpool.cpp
index 573c49f91..edcc31d26 100644
--- a/src/lib/hash/whirlpool/whirlpool.cpp
+++ b/src/lib/hash/whirlpool/whirlpool.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS(Whirlpool);
-
/*
* Whirlpool Compression Function
*/