aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/lib/base/algo_registry.h8
-rw-r--r--src/lib/block/aes/aes.cpp6
-rw-r--r--src/lib/block/aes_ni/aes_ni.cpp6
-rw-r--r--src/lib/block/aes_ssse3/aes_ssse3.cpp8
-rw-r--r--src/lib/block/block_cipher.cpp290
-rw-r--r--src/lib/block/block_cipher.h2
-rw-r--r--src/lib/block/block_utils.h11
-rw-r--r--src/lib/block/blowfish/blowfish.cpp4
-rw-r--r--src/lib/block/camellia/camellia.cpp6
-rw-r--r--src/lib/block/cascade/cascade.cpp4
-rw-r--r--src/lib/block/cast/cast128.cpp4
-rw-r--r--src/lib/block/cast/cast256.cpp4
-rw-r--r--src/lib/block/des/des.cpp5
-rw-r--r--src/lib/block/des/desx.cpp4
-rw-r--r--src/lib/block/gost_28147/gost_28147.cpp4
-rw-r--r--src/lib/block/idea/idea.cpp4
-rw-r--r--src/lib/block/idea_sse2/idea_sse2.cpp4
-rw-r--r--src/lib/block/kasumi/kasumi.cpp4
-rw-r--r--src/lib/block/lion/lion.cpp11
-rw-r--r--src/lib/block/lion/lion.h2
-rw-r--r--src/lib/block/mars/mars.cpp4
-rw-r--r--src/lib/block/misty1/misty1.cpp4
-rw-r--r--src/lib/block/noekeon/noekeon.cpp4
-rw-r--r--src/lib/block/noekeon_simd/noekeon_simd.cpp4
-rw-r--r--src/lib/block/rc2/rc2.cpp4
-rw-r--r--src/lib/block/rc5/rc5.cpp4
-rw-r--r--src/lib/block/rc6/rc6.cpp4
-rw-r--r--src/lib/block/safer/safer_sk.cpp4
-rw-r--r--src/lib/block/seed/seed.cpp4
-rw-r--r--src/lib/block/serpent/serpent.cpp4
-rw-r--r--src/lib/block/serpent_simd/serp_simd.cpp4
-rw-r--r--src/lib/block/tea/tea.cpp4
-rw-r--r--src/lib/block/threefish/threefish.cpp4
-rw-r--r--src/lib/block/threefish_avx2/threefish_avx2.cpp4
-rw-r--r--src/lib/block/twofish/twofish.cpp5
-rw-r--r--src/lib/block/xtea/xtea.cpp4
-rw-r--r--src/lib/block/xtea_simd/xtea_simd.cpp4
-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
-rw-r--r--src/lib/kdf/hkdf/hkdf.cpp2
-rw-r--r--src/lib/kdf/kdf.cpp51
-rw-r--r--src/lib/kdf/kdf1/kdf1.cpp2
-rw-r--r--src/lib/kdf/kdf2/kdf2.cpp2
-rw-r--r--src/lib/kdf/prf_tls/prf_tls.cpp3
-rw-r--r--src/lib/kdf/prf_x942/prf_x942.cpp2
-rw-r--r--src/lib/mac/cbc_mac/cbc_mac.cpp2
-rw-r--r--src/lib/mac/cmac/cmac.cpp2
-rw-r--r--src/lib/mac/hmac/hmac.cpp2
-rw-r--r--src/lib/mac/mac.cpp52
-rw-r--r--src/lib/mac/mac.h6
-rw-r--r--src/lib/mac/poly1305/poly1305.cpp2
-rw-r--r--src/lib/mac/siphash/siphash.cpp2
-rw-r--r--src/lib/mac/x919_mac/x919_mac.cpp2
-rw-r--r--src/lib/stream/chacha/chacha.cpp2
-rw-r--r--src/lib/stream/ctr/ctr.cpp2
-rw-r--r--src/lib/stream/ofb/ofb.cpp2
-rw-r--r--src/lib/stream/rc4/rc4.cpp2
-rw-r--r--src/lib/stream/salsa20/salsa20.cpp2
-rw-r--r--src/lib/stream/stream_cipher.cpp61
-rw-r--r--src/lib/stream/stream_cipher.h10
80 files changed, 685 insertions, 218 deletions
diff --git a/src/lib/base/algo_registry.h b/src/lib/base/algo_registry.h
index 498021194..8151551d3 100644
--- a/src/lib/base/algo_registry.h
+++ b/src/lib/base/algo_registry.h
@@ -35,7 +35,8 @@ class Algo_Registry
void add(const std::string& name, const std::string& provider, maker_fn fn, byte pref)
{
std::unique_lock<std::mutex> lock(m_mutex);
- m_algo_info[name].add_provider(provider, fn, pref);
+ if(!m_algo_info[name].add_provider(provider, fn, pref))
+ throw std::runtime_error("Duplicated registration of " + name + "/" + provider);
}
std::vector<std::string> providers_of(const Spec& spec)
@@ -102,13 +103,14 @@ class Algo_Registry
struct Algo_Info
{
public:
- void add_provider(const std::string& provider, maker_fn fn, byte pref)
+ bool add_provider(const std::string& provider, maker_fn fn, byte pref)
{
if(m_maker_fns.count(provider) > 0)
- throw std::runtime_error("Duplicated registration of '" + provider + "'");
+ return false;
m_maker_fns[provider] = fn;
m_prefs.insert(std::make_pair(pref, provider));
+ return true;
}
std::vector<std::string> providers() const
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp
index b9e00fe6c..61cc9d777 100644
--- a/src/lib/block/aes/aes.cpp
+++ b/src/lib/block/aes/aes.cpp
@@ -7,15 +7,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/aes.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_128, "AES-128");
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_192, "AES-192");
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_256, "AES-256");
-
namespace {
const byte SE[256] = {
diff --git a/src/lib/block/aes_ni/aes_ni.cpp b/src/lib/block/aes_ni/aes_ni.cpp
index 29e729da4..d359ec772 100644
--- a/src/lib/block/aes_ni/aes_ni.cpp
+++ b/src/lib/block/aes_ni/aes_ni.cpp
@@ -5,17 +5,13 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/aes_ni.h>
+#include <botan/loadstor.h>
#include <botan/cpuid.h>
#include <wmmintrin.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_128_NI, "AES-128", "aes_ni", 200);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_192_NI, "AES-192", "aes_ni", 200);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_256_NI, "AES-256", "aes_ni", 200);
-
namespace {
__m128i aes_128_key_expansion(__m128i key, __m128i key_with_rcon)
diff --git a/src/lib/block/aes_ssse3/aes_ssse3.cpp b/src/lib/block/aes_ssse3/aes_ssse3.cpp
index 50acd7668..bfc76ecee 100644
--- a/src/lib/block/aes_ssse3/aes_ssse3.cpp
+++ b/src/lib/block/aes_ssse3/aes_ssse3.cpp
@@ -10,20 +10,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/aes_ssse3.h>
#include <botan/cpuid.h>
#include <tmmintrin.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_128_SSSE3, "AES-128",
- "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_192_SSSE3, "AES-192",
- "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_256_SSSE3, "AES-256",
- "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
-
namespace {
const __m128i low_nibs = _mm_set1_epi8(0x0F);
diff --git a/src/lib/block/block_cipher.cpp b/src/lib/block/block_cipher.cpp
new file mode 100644
index 000000000..cc9d16737
--- /dev/null
+++ b/src/lib/block/block_cipher.cpp
@@ -0,0 +1,290 @@
+/*
+* Block Ciphers
+* (C) 2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/block_cipher.h>
+#include <botan/cpuid.h>
+#include <botan/internal/simd_32.h>
+#include <botan/internal/block_utils.h>
+
+#if defined(BOTAN_HAS_AES)
+ #include <botan/aes.h>
+#endif
+
+#if defined(BOTAN_HAS_AES_SSSE3)
+ #include <botan/aes_ssse3.h>
+#endif
+
+#if defined(BOTAN_HAS_AES_NI)
+ #include <botan/aes_ni.h>
+#endif
+
+#if defined(BOTAN_HAS_BLOWFISH)
+ #include <botan/blowfish.h>
+#endif
+
+#if defined(BOTAN_HAS_CAMELLIA)
+ #include <botan/camellia.h>
+#endif
+
+#if defined(BOTAN_HAS_CAST)
+ #include <botan/cast128.h>
+ #include <botan/cast256.h>
+#endif
+
+#if defined(BOTAN_HAS_CASCADE)
+ #include <botan/cascade.h>
+#endif
+
+#if defined(BOTAN_HAS_DES)
+ #include <botan/des.h>
+ #include <botan/desx.h>
+#endif
+
+#if defined(BOTAN_HAS_GOST_28147_89)
+ #include <botan/gost_28147.h>
+#endif
+
+#if defined(BOTAN_HAS_IDEA)
+ #include <botan/idea.h>
+#endif
+
+#if defined(BOTAN_HAS_IDEA_SSE2)
+ #include <botan/idea_sse2.h>
+#endif
+
+#if defined(BOTAN_HAS_KASUMI)
+ #include <botan/kasumi.h>
+#endif
+
+#if defined(BOTAN_HAS_LION)
+ #include <botan/lion.h>
+#endif
+
+#if defined(BOTAN_HAS_LUBY_RACKOFF)
+ #include <botan/lubyrack.h>
+#endif
+
+#if defined(BOTAN_HAS_MARS)
+ #include <botan/mars.h>
+#endif
+
+#if defined(BOTAN_HAS_MISTY1)
+ #include <botan/misty1.h>
+#endif
+
+#if defined(BOTAN_HAS_NOEKEON)
+ #include <botan/noekeon.h>
+#endif
+
+#if defined(BOTAN_HAS_NOEKEON_SIMD)
+ #include <botan/noekeon_simd.h>
+#endif
+
+#if defined(BOTAN_HAS_RC2)
+ #include <botan/rc2.h>
+#endif
+
+#if defined(BOTAN_HAS_RC5)
+ #include <botan/rc5.h>
+#endif
+
+#if defined(BOTAN_HAS_RC6)
+ #include <botan/rc6.h>
+#endif
+
+#if defined(BOTAN_HAS_SAFER)
+ #include <botan/safer_sk.h>
+#endif
+
+#if defined(BOTAN_HAS_SEED)
+ #include <botan/seed.h>
+#endif
+
+#if defined(BOTAN_HAS_SERPENT)
+ #include <botan/serpent.h>
+#endif
+
+#if defined(BOTAN_HAS_SERPENT_SIMD)
+ #include <botan/serp_simd.h>
+#endif
+
+#if defined(BOTAN_HAS_SKIPJACK)
+ #include <botan/skipjack.h>
+#endif
+
+#if defined(BOTAN_HAS_SQUARE)
+ #include <botan/square.h>
+#endif
+
+#if defined(BOTAN_HAS_TEA)
+ #include <botan/tea.h>
+#endif
+
+#if defined(BOTAN_HAS_TWOFISH)
+ #include <botan/twofish.h>
+#endif
+
+#if defined(BOTAN_HAS_THREEFISH_512)
+ #include <botan/threefish.h>
+#endif
+
+#if defined(BOTAN_HAS_THREEFISH_512_AVX2)
+ #include <botan/threefish_avx2.h>
+#endif
+
+#if defined(BOTAN_HAS_XTEA)
+ #include <botan/xtea.h>
+#endif
+
+#if defined(BOTAN_HAS_XTEA_SIMD)
+ #include <botan/xtea_simd.h>
+#endif
+
+namespace Botan {
+
+BlockCipher::~BlockCipher() {}
+
+#if defined(BOTAN_HAS_AES)
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_128, "AES-128");
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_192, "AES-192");
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_256, "AES-256");
+#endif
+
+#if defined(BOTAN_HAS_AES_NI)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_128_NI, "AES-128", "aes_ni", 200);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_192_NI, "AES-192", "aes_ni", 200);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_256_NI, "AES-256", "aes_ni", 200);
+#endif
+
+#if defined(BOTAN_HAS_AES_SSSE3)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_128_SSSE3, "AES-128",
+ "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_192_SSSE3, "AES-192",
+ "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_256_SSSE3, "AES-256",
+ "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
+#endif
+
+#if defined(BOTAN_HAS_BLOWFISH)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Blowfish);
+#endif
+
+#if defined(BOTAN_HAS_CAMELLIA)
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Camellia_128, "Camellia-128");
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Camellia_192, "Camellia-192");
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Camellia_256, "Camellia-256");
+#endif
+
+#if defined(BOTAN_HAS_CAST)
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(CAST_128, "CAST-128");
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(CAST_256, "CAST-256");
+#endif
+
+#if defined(BOTAN_HAS_DES)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(DES);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(TripleDES);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(DESX);
+#endif
+
+#if defined(BOTAN_HAS_GOST_28147_89)
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1STR(GOST_28147_89, "GOST-28147-89", "R3411_94_TestParam");
+#endif
+
+#if defined(BOTAN_HAS_IDEA)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(IDEA);
+#endif
+
+#if defined(BOTAN_HAS_IDEA_SSE2)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_sse2(), IDEA_SSE2, "IDEA",
+ "sse2", BOTAN_SIMD_ALGORITHM_PRIO);
+#endif
+
+#if defined(BOTAN_HAS_KASUMI)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(KASUMI);
+#endif
+
+#if defined(BOTAN_HAS_MARS)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(MARS);
+#endif
+
+#if defined(BOTAN_HAS_MISTY1)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(MISTY1);
+#endif
+
+#if defined(BOTAN_HAS_NOEKEON)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Noekeon);
+#endif
+
+#if defined(BOTAN_HAS_NOEKEON_SIMD)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Noekeon_SIMD, "Noekeon",
+ "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
+#endif
+
+#if defined(BOTAN_HAS_RC2)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(RC2);
+#endif
+
+#if defined(BOTAN_HAS_RC5)
+BOTAN_REGISTER_BLOCK_CIPHER_1LEN(RC5, 12);
+#endif
+
+#if defined(BOTAN_HAS_RC6)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(RC6);
+#endif
+
+#if defined(BOTAN_HAS_SAFER)
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1LEN(SAFER_SK, "SAFER-SK", 10);
+#endif
+
+#if defined(BOTAN_HAS_SEED)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(SEED);
+#endif
+
+#if defined(BOTAN_HAS_SERPENT)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Serpent);
+#endif
+
+#if defined(BOTAN_HAS_SERPENT_SIMD)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Serpent_SIMD, "Serpent",
+ "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
+#endif
+
+#if defined(BOTAN_HAS_TEA)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(TEA);
+#endif
+
+#if defined(BOTAN_HAS_TWOFISH)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Twofish);
+#endif
+
+#if defined(BOTAN_HAS_THREEFISH_512)
+BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Threefish_512, "Threefish-512");
+#endif
+
+#if defined(BOTAN_HAS_THREEFISH_512_AVX2)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_avx2(), Threefish_512_AVX2, "Threefish-512",
+ "avx2", BOTAN_SIMD_ALGORITHM_PRIO);
+#endif
+
+#if defined(BOTAN_HAS_XTEA)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(XTEA);
+#endif
+
+#if defined(BOTAN_HAS_XTEA_SIMD)
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), XTEA_SIMD, "XTEA",
+ "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
+#endif
+
+#if defined(BOTAN_HAS_CASCADE)
+BOTAN_REGISTER_NAMED_T(BlockCipher, "Cascade", Cascade_Cipher, Cascade_Cipher::make);
+#endif
+
+#if defined(BOTAN_HAS_LION)
+BOTAN_REGISTER_NAMED_T(BlockCipher, "Lion", Lion, Lion::make);
+#endif
+
+}
diff --git a/src/lib/block/block_cipher.h b/src/lib/block/block_cipher.h
index 08bf18fd3..3f017dc89 100644
--- a/src/lib/block/block_cipher.h
+++ b/src/lib/block/block_cipher.h
@@ -141,6 +141,8 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @return new object representing the same algorithm as *this
*/
virtual BlockCipher* clone() const = 0;
+
+ virtual ~BlockCipher();
};
/**
diff --git a/src/lib/block/block_utils.h b/src/lib/block/block_utils.h
index 89f8a3dd3..c1eee27b1 100644
--- a/src/lib/block/block_utils.h
+++ b/src/lib/block/block_utils.h
@@ -1,20 +1,15 @@
/*
-* Block Cipher Utility Header
+* Internal Block Cipher Utility Header
* (C) 2015 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#ifndef BOTAN_BLOCK_CIPHER_UTILS_H__
-#define BOTAN_BLOCK_CIPHER_UTILS_H__
+#ifndef BOTAN_INTERNAL_BLOCK_CIPHER_UTILS_H__
+#define BOTAN_INTERNAL_BLOCK_CIPHER_UTILS_H__
#include <botan/block_cipher.h>
#include <botan/internal/algo_registry.h>
-#include <botan/loadstor.h>
-#include <botan/rotate.h>
-#include <botan/internal/xor_buf.h>
-#include <algorithm>
-#include <functional>
namespace Botan {
diff --git a/src/lib/block/blowfish/blowfish.cpp b/src/lib/block/blowfish/blowfish.cpp
index 63838929d..2488838c3 100644
--- a/src/lib/block/blowfish/blowfish.cpp
+++ b/src/lib/block/blowfish/blowfish.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/blowfish.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Blowfish);
-
/*
* Blowfish Encryption
*/
diff --git a/src/lib/block/camellia/camellia.cpp b/src/lib/block/camellia/camellia.cpp
index 887878910..dc57e26bc 100644
--- a/src/lib/block/camellia/camellia.cpp
+++ b/src/lib/block/camellia/camellia.cpp
@@ -5,16 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/camellia.h>
#include <botan/internal/camellia_sbox.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Camellia_128, "Camellia-128");
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Camellia_192, "Camellia-192");
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Camellia_256, "Camellia-256");
-
namespace Camellia_F {
namespace {
diff --git a/src/lib/block/cascade/cascade.cpp b/src/lib/block/cascade/cascade.cpp
index 3b59a4362..66ff293ff 100644
--- a/src/lib/block/cascade/cascade.cpp
+++ b/src/lib/block/cascade/cascade.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/cascade.h>
+#include <botan/lookup.h>
namespace Botan {
-BOTAN_REGISTER_NAMED_T(BlockCipher, "Cascade", Cascade_Cipher, Cascade_Cipher::make);
-
Cascade_Cipher* Cascade_Cipher::make(const BlockCipher::Spec& spec)
{
std::unique_ptr<BlockCipher> c1(get_block_cipher(spec.arg(0)));
diff --git a/src/lib/block/cast/cast128.cpp b/src/lib/block/cast/cast128.cpp
index e19c6dcb1..3973418a3 100644
--- a/src/lib/block/cast/cast128.cpp
+++ b/src/lib/block/cast/cast128.cpp
@@ -5,14 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/cast128.h>
#include <botan/internal/cast_sboxes.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(CAST_128, "CAST-128");
-
namespace {
/*
diff --git a/src/lib/block/cast/cast256.cpp b/src/lib/block/cast/cast256.cpp
index bbb9894e7..7178dc5c1 100644
--- a/src/lib/block/cast/cast256.cpp
+++ b/src/lib/block/cast/cast256.cpp
@@ -5,14 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/cast256.h>
#include <botan/internal/cast_sboxes.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(CAST_256, "CAST-256");
-
namespace {
/*
diff --git a/src/lib/block/des/des.cpp b/src/lib/block/des/des.cpp
index c1013b9af..6d2bcfe1e 100644
--- a/src/lib/block/des/des.cpp
+++ b/src/lib/block/des/des.cpp
@@ -8,14 +8,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/des.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(DES);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(TripleDES);
-
namespace {
/*
diff --git a/src/lib/block/des/desx.cpp b/src/lib/block/des/desx.cpp
index 0e19460fc..4ab568638 100644
--- a/src/lib/block/des/desx.cpp
+++ b/src/lib/block/des/desx.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/desx.h>
+#include <botan/internal/xor_buf.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(DESX);
-
/*
* DESX Encryption
*/
diff --git a/src/lib/block/gost_28147/gost_28147.cpp b/src/lib/block/gost_28147/gost_28147.cpp
index 90bf9328d..b8c3b7280 100644
--- a/src/lib/block/gost_28147/gost_28147.cpp
+++ b/src/lib/block/gost_28147/gost_28147.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/gost_28147.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1STR(GOST_28147_89, "GOST-28147-89", "R3411_94_TestParam");
-
byte GOST_28147_89_Params::sbox_entry(size_t row, size_t col) const
{
byte x = sboxes[4 * col + (row / 2)];
diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp
index 764115013..ddfd8e5fb 100644
--- a/src/lib/block/idea/idea.cpp
+++ b/src/lib/block/idea/idea.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/idea.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(IDEA);
-
namespace {
/*
diff --git a/src/lib/block/idea_sse2/idea_sse2.cpp b/src/lib/block/idea_sse2/idea_sse2.cpp
index 8549d74d7..a2a54ac32 100644
--- a/src/lib/block/idea_sse2/idea_sse2.cpp
+++ b/src/lib/block/idea_sse2/idea_sse2.cpp
@@ -5,16 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/idea_sse2.h>
#include <botan/cpuid.h>
#include <emmintrin.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_sse2(), IDEA_SSE2, "IDEA",
- "sse2", BOTAN_SIMD_ALGORITHM_PRIO);
-
namespace {
inline __m128i mul(__m128i X, u16bit K_16)
diff --git a/src/lib/block/kasumi/kasumi.cpp b/src/lib/block/kasumi/kasumi.cpp
index d0233cf5c..604d2d21a 100644
--- a/src/lib/block/kasumi/kasumi.cpp
+++ b/src/lib/block/kasumi/kasumi.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/kasumi.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(KASUMI);
-
namespace {
/*
diff --git a/src/lib/block/lion/lion.cpp b/src/lib/block/lion/lion.cpp
index a487e3eb0..336828d89 100644
--- a/src/lib/block/lion/lion.cpp
+++ b/src/lib/block/lion/lion.cpp
@@ -5,15 +5,14 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/lion.h>
+#include <botan/lookup.h>
#include <botan/parsing.h>
+#include <botan/internal/xor_buf.h>
namespace Botan {
-namespace {
-
-Lion* make_lion(const BlockCipher::Spec& spec)
+Lion* Lion::make(const BlockCipher::Spec& spec)
{
if(spec.arg_count_between(2, 3))
{
@@ -29,10 +28,6 @@ Lion* make_lion(const BlockCipher::Spec& spec)
return nullptr;
}
-}
-
-BOTAN_REGISTER_NAMED_T(BlockCipher, "Lion", Lion, make_lion);
-
/*
* Lion Encryption
*/
diff --git a/src/lib/block/lion/lion.h b/src/lib/block/lion/lion.h
index d03d1d1a0..116fa911b 100644
--- a/src/lib/block/lion/lion.h
+++ b/src/lib/block/lion/lion.h
@@ -39,6 +39,8 @@ class BOTAN_DLL Lion : public BlockCipher
std::string name() const override;
BlockCipher* clone() const override;
+ static Lion* make(const Spec&);
+
/**
* @param hash the hash to use internally
* @param cipher the stream cipher to use internally
diff --git a/src/lib/block/mars/mars.cpp b/src/lib/block/mars/mars.cpp
index 50f264861..becbbf2db 100644
--- a/src/lib/block/mars/mars.cpp
+++ b/src/lib/block/mars/mars.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/mars.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(MARS);
-
namespace {
/**
diff --git a/src/lib/block/misty1/misty1.cpp b/src/lib/block/misty1/misty1.cpp
index 23233e02f..490eec826 100644
--- a/src/lib/block/misty1/misty1.cpp
+++ b/src/lib/block/misty1/misty1.cpp
@@ -5,14 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/misty1.h>
+#include <botan/loadstor.h>
#include <botan/parsing.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(MISTY1);
-
namespace {
static const byte MISTY1_SBOX_S7[128] = {
diff --git a/src/lib/block/noekeon/noekeon.cpp b/src/lib/block/noekeon/noekeon.cpp
index fb1a215fe..d63ec3129 100644
--- a/src/lib/block/noekeon/noekeon.cpp
+++ b/src/lib/block/noekeon/noekeon.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/noekeon.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Noekeon);
-
namespace {
/*
diff --git a/src/lib/block/noekeon_simd/noekeon_simd.cpp b/src/lib/block/noekeon_simd/noekeon_simd.cpp
index a51c6bc8f..07fcf19ff 100644
--- a/src/lib/block/noekeon_simd/noekeon_simd.cpp
+++ b/src/lib/block/noekeon_simd/noekeon_simd.cpp
@@ -5,15 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/noekeon_simd.h>
#include <botan/internal/simd_32.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Noekeon_SIMD, "Noekeon",
- "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
-
/*
* Noekeon's Theta Operation
*/
diff --git a/src/lib/block/rc2/rc2.cpp b/src/lib/block/rc2/rc2.cpp
index d1fc8a2e6..bcd8475e3 100644
--- a/src/lib/block/rc2/rc2.cpp
+++ b/src/lib/block/rc2/rc2.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/rc2.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(RC2);
-
/*
* RC2 Encryption
*/
diff --git a/src/lib/block/rc5/rc5.cpp b/src/lib/block/rc5/rc5.cpp
index 27fa0e14d..a32efd775 100644
--- a/src/lib/block/rc5/rc5.cpp
+++ b/src/lib/block/rc5/rc5.cpp
@@ -5,14 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/rc5.h>
+#include <botan/loadstor.h>
#include <botan/parsing.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_1LEN(RC5, 12);
-
/*
* RC5 Encryption
*/
diff --git a/src/lib/block/rc6/rc6.cpp b/src/lib/block/rc6/rc6.cpp
index e9aa5fe8b..48fb1c32e 100644
--- a/src/lib/block/rc6/rc6.cpp
+++ b/src/lib/block/rc6/rc6.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/rc6.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(RC6);
-
/*
* RC6 Encryption
*/
diff --git a/src/lib/block/safer/safer_sk.cpp b/src/lib/block/safer/safer_sk.cpp
index f5996a986..a8781697d 100644
--- a/src/lib/block/safer/safer_sk.cpp
+++ b/src/lib/block/safer/safer_sk.cpp
@@ -5,16 +5,14 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/safer_sk.h>
+#include <botan/rotate.h>
#include <botan/parsing.h>
namespace Botan {
namespace {
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1LEN(SAFER_SK, "SAFER-SK", 10);
-
const byte EXP[256] = {
0x01, 0x2D, 0xE2, 0x93, 0xBE, 0x45, 0x15, 0xAE, 0x78, 0x03, 0x87, 0xA4,
0xB8, 0x38, 0xCF, 0x3F, 0x08, 0x67, 0x09, 0x94, 0xEB, 0x26, 0xA8, 0x6B,
diff --git a/src/lib/block/seed/seed.cpp b/src/lib/block/seed/seed.cpp
index 316ef1e04..833f9943f 100644
--- a/src/lib/block/seed/seed.cpp
+++ b/src/lib/block/seed/seed.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/seed.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(SEED);
-
/*
* SEED G Function
*/
diff --git a/src/lib/block/serpent/serpent.cpp b/src/lib/block/serpent/serpent.cpp
index b809e602c..c0a65ed33 100644
--- a/src/lib/block/serpent/serpent.cpp
+++ b/src/lib/block/serpent/serpent.cpp
@@ -5,14 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/serpent.h>
+#include <botan/loadstor.h>
#include <botan/internal/serpent_sbox.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Serpent);
-
namespace {
/*
diff --git a/src/lib/block/serpent_simd/serp_simd.cpp b/src/lib/block/serpent_simd/serp_simd.cpp
index 56747dd16..02fe7d6d9 100644
--- a/src/lib/block/serpent_simd/serp_simd.cpp
+++ b/src/lib/block/serpent_simd/serp_simd.cpp
@@ -5,16 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/serp_simd.h>
#include <botan/internal/serpent_sbox.h>
#include <botan/internal/simd_32.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Serpent_SIMD, "Serpent",
- "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
-
namespace {
#define key_xor(round, B0, B1, B2, B3) \
diff --git a/src/lib/block/tea/tea.cpp b/src/lib/block/tea/tea.cpp
index ef630f715..01f342607 100644
--- a/src/lib/block/tea/tea.cpp
+++ b/src/lib/block/tea/tea.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/tea.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(TEA);
-
/*
* TEA Encryption
*/
diff --git a/src/lib/block/threefish/threefish.cpp b/src/lib/block/threefish/threefish.cpp
index 322f54881..93fd122c2 100644
--- a/src/lib/block/threefish/threefish.cpp
+++ b/src/lib/block/threefish/threefish.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/threefish.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(Threefish_512, "Threefish-512");
-
#define THREEFISH_ROUND(X0,X1,X2,X3,X4,X5,X6,X7,ROT1,ROT2,ROT3,ROT4) \
do { \
X0 += X4; \
diff --git a/src/lib/block/threefish_avx2/threefish_avx2.cpp b/src/lib/block/threefish_avx2/threefish_avx2.cpp
index 435c75dbf..bed98fafa 100644
--- a/src/lib/block/threefish_avx2/threefish_avx2.cpp
+++ b/src/lib/block/threefish_avx2/threefish_avx2.cpp
@@ -5,16 +5,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/threefish_avx2.h>
#include <botan/cpuid.h>
#include <immintrin.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_avx2(), Threefish_512_AVX2, "Threefish-512",
- "avx2", BOTAN_SIMD_ALGORITHM_PRIO);
-
namespace {
inline void interleave_epi64(__m256i& X0, __m256i& X1)
diff --git a/src/lib/block/twofish/twofish.cpp b/src/lib/block/twofish/twofish.cpp
index 43ea41bfd..ffdf4b198 100644
--- a/src/lib/block/twofish/twofish.cpp
+++ b/src/lib/block/twofish/twofish.cpp
@@ -8,13 +8,12 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/twofish.h>
+#include <botan/loadstor.h>
+#include <botan/rotate.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Twofish);
-
/*
* Twofish Encryption
*/
diff --git a/src/lib/block/xtea/xtea.cpp b/src/lib/block/xtea/xtea.cpp
index 9fe265457..59060dff7 100644
--- a/src/lib/block/xtea/xtea.cpp
+++ b/src/lib/block/xtea/xtea.cpp
@@ -5,13 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/xtea.h>
+#include <botan/loadstor.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(XTEA);
-
namespace {
void xtea_encrypt_4(const byte in[32], byte out[32], const u32bit EK[64])
diff --git a/src/lib/block/xtea_simd/xtea_simd.cpp b/src/lib/block/xtea_simd/xtea_simd.cpp
index a9984ce23..6e50f4ff7 100644
--- a/src/lib/block/xtea_simd/xtea_simd.cpp
+++ b/src/lib/block/xtea_simd/xtea_simd.cpp
@@ -5,15 +5,11 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#include <botan/internal/block_utils.h>
#include <botan/xtea_simd.h>
#include <botan/internal/simd_32.h>
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), XTEA_SIMD, "XTEA",
- "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
-
namespace {
void xtea_encrypt_8(const byte in[64], byte out[64], const u32bit EK[64])
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
*/
diff --git a/src/lib/kdf/hkdf/hkdf.cpp b/src/lib/kdf/hkdf/hkdf.cpp
index b643db6d9..df6e49fad 100644
--- a/src/lib/kdf/hkdf/hkdf.cpp
+++ b/src/lib/kdf/hkdf/hkdf.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T(KDF, "HKDF", HKDF, HKDF::make);
-
HKDF* HKDF::make(const Spec& spec)
{
if(auto mac = get_mac(spec.arg(0)))
diff --git a/src/lib/kdf/kdf.cpp b/src/lib/kdf/kdf.cpp
index 793cd3d62..89bb8d58a 100644
--- a/src/lib/kdf/kdf.cpp
+++ b/src/lib/kdf/kdf.cpp
@@ -6,8 +6,31 @@
*/
#include <botan/kdf.h>
-#include <botan/internal/algo_registry.h>
-#include <botan/exceptn.h>
+#include <botan/internal/kdf_utils.h>
+
+#if defined(BOTAN_HAS_HKDF)
+#include <botan/hkdf.h>
+#endif
+
+#if defined(BOTAN_HAS_KDF1)
+#include <botan/kdf1.h>
+#endif
+
+#if defined(BOTAN_HAS_KDF2)
+#include <botan/kdf2.h>
+#endif
+
+#if defined(BOTAN_HAS_TLS_V10_PRF)
+#include <botan/prf_tls.h>
+#endif
+
+#if defined(BOTAN_HAS_TLS_V12_PRF)
+#include <botan/prf_tls.h>
+#endif
+
+#if defined(BOTAN_HAS_X942_PRF)
+#include <botan/prf_x942.h>
+#endif
namespace Botan {
@@ -23,4 +46,28 @@ KDF* get_kdf(const std::string& algo_spec)
throw Algorithm_Not_Found(algo_spec);
}
+#if defined(BOTAN_HAS_HKDF)
+BOTAN_REGISTER_NAMED_T(KDF, "HKDF", HKDF, HKDF::make);
+#endif
+
+#if defined(BOTAN_HAS_KDF1)
+BOTAN_REGISTER_KDF_1HASH(KDF1, "KDF1");
+#endif
+
+#if defined(BOTAN_HAS_KDF2)
+BOTAN_REGISTER_KDF_1HASH(KDF2, "KDF2");
+#endif
+
+#if defined(BOTAN_HAS_TLS_V10_PRF)
+BOTAN_REGISTER_KDF_NOARGS(TLS_PRF, "TLS-PRF");
+#endif
+
+#if defined(BOTAN_HAS_TLS_V12_PRF)
+BOTAN_REGISTER_NAMED_T(KDF, "TLS-12-PRF", TLS_12_PRF, TLS_12_PRF::make);
+#endif
+
+#if defined(BOTAN_HAS_X942_PRF)
+BOTAN_REGISTER_KDF_NAMED_1STR(X942_PRF, "X9.42-PRF");
+#endif
+
}
diff --git a/src/lib/kdf/kdf1/kdf1.cpp b/src/lib/kdf/kdf1/kdf1.cpp
index fa3432467..c87bacd27 100644
--- a/src/lib/kdf/kdf1/kdf1.cpp
+++ b/src/lib/kdf/kdf1/kdf1.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_KDF_1HASH(KDF1, "KDF1");
-
size_t KDF1::kdf(byte key[], size_t key_len,
const byte secret[], size_t secret_len,
const byte salt[], size_t salt_len) const
diff --git a/src/lib/kdf/kdf2/kdf2.cpp b/src/lib/kdf/kdf2/kdf2.cpp
index 9deb1a22f..1b1c3638a 100644
--- a/src/lib/kdf/kdf2/kdf2.cpp
+++ b/src/lib/kdf/kdf2/kdf2.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_KDF_1HASH(KDF2, "KDF2");
-
size_t KDF2::kdf(byte key[], size_t key_len,
const byte secret[], size_t secret_len,
const byte salt[], size_t salt_len) const
diff --git a/src/lib/kdf/prf_tls/prf_tls.cpp b/src/lib/kdf/prf_tls/prf_tls.cpp
index 4fdec8fef..ef130d5ba 100644
--- a/src/lib/kdf/prf_tls/prf_tls.cpp
+++ b/src/lib/kdf/prf_tls/prf_tls.cpp
@@ -20,9 +20,6 @@ TLS_12_PRF* TLS_12_PRF::make(const Spec& spec)
return nullptr;
}
-BOTAN_REGISTER_NAMED_T(KDF, "TLS-12-PRF", TLS_12_PRF, TLS_12_PRF::make);
-BOTAN_REGISTER_KDF_NOARGS(TLS_PRF, "TLS-PRF");
-
TLS_PRF::TLS_PRF() :
m_hmac_md5(make_message_auth("HMAC(MD5)")),
m_hmac_sha1(make_message_auth("HMAC(SHA-1)"))
diff --git a/src/lib/kdf/prf_x942/prf_x942.cpp b/src/lib/kdf/prf_x942/prf_x942.cpp
index 622d68c1a..e8f234e49 100644
--- a/src/lib/kdf/prf_x942/prf_x942.cpp
+++ b/src/lib/kdf/prf_x942/prf_x942.cpp
@@ -15,8 +15,6 @@
namespace Botan {
-BOTAN_REGISTER_KDF_NAMED_1STR(X942_PRF, "X9.42-PRF");
-
namespace {
/*
diff --git a/src/lib/mac/cbc_mac/cbc_mac.cpp b/src/lib/mac/cbc_mac/cbc_mac.cpp
index b58372c78..29507f17b 100644
--- a/src/lib/mac/cbc_mac/cbc_mac.cpp
+++ b/src/lib/mac/cbc_mac/cbc_mac.cpp
@@ -20,8 +20,6 @@ CBC_MAC* CBC_MAC::make(const Spec& spec)
return nullptr;
}
-BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "CBC-MAC", CBC_MAC, CBC_MAC::make);
-
/*
* Update an CBC-MAC Calculation
*/
diff --git a/src/lib/mac/cmac/cmac.cpp b/src/lib/mac/cmac/cmac.cpp
index 1621079dc..85c19c19f 100644
--- a/src/lib/mac/cmac/cmac.cpp
+++ b/src/lib/mac/cmac/cmac.cpp
@@ -20,8 +20,6 @@ CMAC* CMAC::make(const Spec& spec)
return nullptr;
}
-BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "CMAC", CMAC, CMAC::make);
-
/*
* Perform CMAC's multiplication in GF(2^n)
*/
diff --git a/src/lib/mac/hmac/hmac.cpp b/src/lib/mac/hmac/hmac.cpp
index 1c6821a54..2cd512746 100644
--- a/src/lib/mac/hmac/hmac.cpp
+++ b/src/lib/mac/hmac/hmac.cpp
@@ -21,8 +21,6 @@ HMAC* HMAC::make(const Spec& spec)
return nullptr;
}
-BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "HMAC", HMAC, HMAC::make);
-
/*
* Update a HMAC Calculation
*/
diff --git a/src/lib/mac/mac.cpp b/src/lib/mac/mac.cpp
index 0bb1939c7..af59bd4c6 100644
--- a/src/lib/mac/mac.cpp
+++ b/src/lib/mac/mac.cpp
@@ -6,10 +6,37 @@
*/
#include <botan/mac.h>
+#include <botan/internal/mac_utils.h>
#include <botan/mem_ops.h>
+#if defined(BOTAN_HAS_CBC_MAC)
+ #include <botan/cbc_mac.h>
+#endif
+
+#if defined(BOTAN_HAS_CMAC)
+ #include <botan/cmac.h>
+#endif
+
+#if defined(BOTAN_HAS_HMAC)
+ #include <botan/hmac.h>
+#endif
+
+#if defined(BOTAN_HAS_POLY1305)
+ #include <botan/poly1305.h>
+#endif
+
+#if defined(BOTAN_HAS_SIPHASH)
+ #include <botan/siphash.h>
+#endif
+
+#if defined(BOTAN_HAS_ANSI_X919_MAC)
+ #include <botan/x919_mac.h>
+#endif
+
namespace Botan {
+MessageAuthenticationCode::~MessageAuthenticationCode() {}
+
/*
* Default (deterministic) MAC verification operation
*/
@@ -23,4 +50,29 @@ bool MessageAuthenticationCode::verify_mac(const byte mac[], size_t length)
return same_mem(our_mac.data(), mac, length);
}
+
+#if defined(BOTAN_HAS_CBC_MAC)
+BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "CBC-MAC", CBC_MAC, CBC_MAC::make);
+#endif
+
+#if defined(BOTAN_HAS_CMAC)
+BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "CMAC", CMAC, CMAC::make);
+#endif
+
+#if defined(BOTAN_HAS_HMAC)
+BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "HMAC", HMAC, HMAC::make);
+#endif
+
+#if defined(BOTAN_HAS_POLY1305)
+BOTAN_REGISTER_MAC_NOARGS(Poly1305);
+#endif
+
+#if defined(BOTAN_HAS_SIPHASH)
+BOTAN_REGISTER_NAMED_T_2LEN(MessageAuthenticationCode, SipHash, "SipHash", "base", 2, 4);
+#endif
+
+#if defined(BOTAN_HAS_ANSI_X919_MAC)
+BOTAN_REGISTER_MAC_NAMED_NOARGS(ANSI_X919_MAC, "X9.19-MAC");
+#endif
+
}
diff --git a/src/lib/mac/mac.h b/src/lib/mac/mac.h
index 8ad2d1e99..28894bbcd 100644
--- a/src/lib/mac/mac.h
+++ b/src/lib/mac/mac.h
@@ -22,6 +22,10 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation,
public SymmetricAlgorithm
{
public:
+ typedef SCAN_Name Spec;
+
+ virtual ~MessageAuthenticationCode();
+
/**
* Verify a MAC.
* @param in the MAC to verify as a byte array
@@ -34,8 +38,6 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation,
* Get a new object representing the same algorithm as *this
*/
virtual MessageAuthenticationCode* clone() const = 0;
-
- typedef SCAN_Name Spec;
};
}
diff --git a/src/lib/mac/poly1305/poly1305.cpp b/src/lib/mac/poly1305/poly1305.cpp
index 659667baf..1a072c6b4 100644
--- a/src/lib/mac/poly1305/poly1305.cpp
+++ b/src/lib/mac/poly1305/poly1305.cpp
@@ -16,8 +16,6 @@
namespace Botan {
-BOTAN_REGISTER_MAC_NOARGS(Poly1305);
-
namespace {
void poly1305_init(secure_vector<u64bit>& X, const byte key[32])
diff --git a/src/lib/mac/siphash/siphash.cpp b/src/lib/mac/siphash/siphash.cpp
index f8ed28a84..689d03c13 100644
--- a/src/lib/mac/siphash/siphash.cpp
+++ b/src/lib/mac/siphash/siphash.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T_2LEN(MessageAuthenticationCode, SipHash, "SipHash", "base", 2, 4);
-
namespace {
void SipRounds(u64bit M, secure_vector<u64bit>& V, size_t r)
diff --git a/src/lib/mac/x919_mac/x919_mac.cpp b/src/lib/mac/x919_mac/x919_mac.cpp
index 542f9040a..ce7c38ebb 100644
--- a/src/lib/mac/x919_mac/x919_mac.cpp
+++ b/src/lib/mac/x919_mac/x919_mac.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_MAC_NAMED_NOARGS(ANSI_X919_MAC, "X9.19-MAC");
-
/*
* Update an ANSI X9.19 MAC Calculation
*/
diff --git a/src/lib/stream/chacha/chacha.cpp b/src/lib/stream/chacha/chacha.cpp
index 9841f99a2..9aa3c2a73 100644
--- a/src/lib/stream/chacha/chacha.cpp
+++ b/src/lib/stream/chacha/chacha.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_STREAM_CIPHER_NOARGS(ChaCha);
-
void ChaCha::chacha(byte output[64], const u32bit input[16])
{
u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
diff --git a/src/lib/stream/ctr/ctr.cpp b/src/lib/stream/ctr/ctr.cpp
index f1cdc7c42..d025a03d3 100644
--- a/src/lib/stream/ctr/ctr.cpp
+++ b/src/lib/stream/ctr/ctr.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T(StreamCipher, "CTR-BE", CTR_BE, CTR_BE::make);
-
CTR_BE* CTR_BE::make(const Spec& spec)
{
if(spec.algo_name() == "CTR-BE" && spec.arg_count() == 1)
diff --git a/src/lib/stream/ofb/ofb.cpp b/src/lib/stream/ofb/ofb.cpp
index b98f81be3..73ffef980 100644
--- a/src/lib/stream/ofb/ofb.cpp
+++ b/src/lib/stream/ofb/ofb.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T(StreamCipher, "OFB", OFB, OFB::make);
-
OFB* OFB::make(const Spec& spec)
{
if(spec.algo_name() == "OFB" && spec.arg_count() == 1)
diff --git a/src/lib/stream/rc4/rc4.cpp b/src/lib/stream/rc4/rc4.cpp
index 3fd0d2276..31fd2cca0 100644
--- a/src/lib/stream/rc4/rc4.cpp
+++ b/src/lib/stream/rc4/rc4.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_NAMED_T(StreamCipher, "RC4", RC4, RC4::make);
-
RC4* RC4::make(const Spec& spec)
{
if(spec.algo_name() == "RC4")
diff --git a/src/lib/stream/salsa20/salsa20.cpp b/src/lib/stream/salsa20/salsa20.cpp
index daf01dd0a..141d9e51e 100644
--- a/src/lib/stream/salsa20/salsa20.cpp
+++ b/src/lib/stream/salsa20/salsa20.cpp
@@ -10,8 +10,6 @@
namespace Botan {
-BOTAN_REGISTER_STREAM_CIPHER_NOARGS(Salsa20);
-
namespace {
#define SALSA20_QUARTER_ROUND(x1, x2, x3, x4) \
diff --git a/src/lib/stream/stream_cipher.cpp b/src/lib/stream/stream_cipher.cpp
new file mode 100644
index 000000000..2f1538914
--- /dev/null
+++ b/src/lib/stream/stream_cipher.cpp
@@ -0,0 +1,61 @@
+/*
+* Stream Ciphers
+* (C) 2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/stream_cipher.h>
+#include <botan/internal/stream_utils.h>
+
+#if defined(BOTAN_HAS_CHACHA)
+#include <botan/chacha.h>
+#endif
+
+#if defined(BOTAN_HAS_SALSA20)
+#include <botan/salsa20.h>
+#endif
+
+#if defined(BOTAN_HAS_CTR_BE)
+#include <botan/ctr.h>
+#endif
+
+#if defined(BOTAN_HAS_OFB)
+#include <botan/ofb.h>
+#endif
+
+#if defined(BOTAN_HAS_RC4)
+#include <botan/rc4.h>
+#endif
+
+namespace Botan {
+
+StreamCipher::~StreamCipher() {}
+
+void StreamCipher::set_iv(const byte[], size_t iv_len)
+ {
+ if(!valid_iv_length(iv_len))
+ throw Invalid_IV_Length(name(), iv_len);
+ }
+
+#if defined(BOTAN_HAS_CHACHA)
+BOTAN_REGISTER_STREAM_CIPHER_NOARGS(ChaCha);
+#endif
+
+#if defined(BOTAN_HAS_SALSA20)
+BOTAN_REGISTER_STREAM_CIPHER_NOARGS(Salsa20);
+#endif
+
+#if defined(BOTAN_HAS_CTR_BE)
+BOTAN_REGISTER_NAMED_T(StreamCipher, "CTR-BE", CTR_BE, CTR_BE::make);
+#endif
+
+#if defined(BOTAN_HAS_OFB)
+BOTAN_REGISTER_NAMED_T(StreamCipher, "OFB", OFB, OFB::make);
+#endif
+
+#if defined(BOTAN_HAS_RC4)
+BOTAN_REGISTER_NAMED_T(StreamCipher, "RC4", RC4, RC4::make);
+#endif
+
+}
diff --git a/src/lib/stream/stream_cipher.h b/src/lib/stream/stream_cipher.h
index bfdd152a7..5500bca49 100644
--- a/src/lib/stream/stream_cipher.h
+++ b/src/lib/stream/stream_cipher.h
@@ -20,6 +20,8 @@ namespace Botan {
class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
{
public:
+ typedef SCAN_Name Spec;
+
/**
* Encrypt or decrypt a message
* @param in the plaintext
@@ -53,11 +55,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param iv the initialization vector
* @param iv_len the length of the IV in bytes
*/
- virtual void set_iv(const byte[], size_t iv_len)
- {
- if(iv_len)
- throw Invalid_IV_Length(name(), iv_len);
- }
+ virtual void set_iv(const byte[], size_t iv_len);
/**
* @param iv_len the length of the IV in bytes
@@ -70,7 +68,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
*/
virtual StreamCipher* clone() const = 0;
- typedef SCAN_Name Spec;
+ virtual ~StreamCipher();
};
}