aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/block')
-rw-r--r--src/lib/block/aes/aes.cpp7
-rw-r--r--src/lib/block/aes_ni/aes_ni.cpp7
-rw-r--r--src/lib/block/aes_ssse3/aes_ssse3.cpp6
-rw-r--r--src/lib/block/block_cipher.h2
-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.cpp19
-rw-r--r--src/lib/block/cast/cast128.cpp5
-rw-r--r--src/lib/block/cast/cast256.cpp5
-rw-r--r--src/lib/block/des/des.cpp6
-rw-r--r--src/lib/block/des/desx.cpp4
-rw-r--r--src/lib/block/gost_28147/gost_28147.cpp5
-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/info.txt8
-rw-r--r--src/lib/block/kasumi/kasumi.cpp5
-rw-r--r--src/lib/block/lion/lion.cpp26
-rw-r--r--src/lib/block/mars/mars.cpp5
-rw-r--r--src/lib/block/misty1/misty1.cpp14
-rw-r--r--src/lib/block/misty1/misty1.h8
-rw-r--r--src/lib/block/noekeon/noekeon.cpp5
-rw-r--r--src/lib/block/noekeon_simd/noekeon_simd.cpp3
-rw-r--r--src/lib/block/rc2/rc2.cpp5
-rw-r--r--src/lib/block/rc5/rc5.cpp6
-rw-r--r--src/lib/block/rc6/rc6.cpp6
-rw-r--r--src/lib/block/safer/safer_sk.cpp5
-rw-r--r--src/lib/block/seed/seed.cpp4
-rw-r--r--src/lib/block/serpent/serpent.cpp9
-rw-r--r--src/lib/block/serpent_simd/serp_simd.cpp4
-rw-r--r--src/lib/block/serpent_x86_32/serp_x86_32.cpp4
-rw-r--r--src/lib/block/tea/tea.cpp4
-rw-r--r--src/lib/block/threefish/threefish.cpp10
-rw-r--r--src/lib/block/threefish/threefish.h3
-rw-r--r--src/lib/block/threefish_avx2/threefish_avx2.cpp6
-rw-r--r--src/lib/block/threefish_avx2/threefish_avx2.h6
-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
38 files changed, 175 insertions, 68 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp
index 8180231ca..ff8c97b76 100644
--- a/src/lib/block/aes/aes.cpp
+++ b/src/lib/block/aes/aes.cpp
@@ -7,12 +7,15 @@
* 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>
-#include <botan/rotate.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 aa061b3c1..256895148 100644
--- a/src/lib/block/aes_ni/aes_ni.cpp
+++ b/src/lib/block/aes_ni/aes_ni.cpp
@@ -5,12 +5,17 @@
* 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");
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_192_NI, "AES-192", "aes_ni");
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_256_NI, "AES-256", "aes_ni");
+
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 40f0a5c8e..6a8fb3ed8 100644
--- a/src/lib/block/aes_ssse3/aes_ssse3.cpp
+++ b/src/lib/block/aes_ssse3/aes_ssse3.cpp
@@ -10,11 +10,17 @@
* 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_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_192_SSSE3, "AES-192", "ssse3");
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_256_SSSE3, "AES-256", "ssse3");
+
namespace {
const __m128i low_nibs = _mm_set1_epi8(0x0F);
diff --git a/src/lib/block/block_cipher.h b/src/lib/block/block_cipher.h
index 19dbc8e57..73e67b790 100644
--- a/src/lib/block/block_cipher.h
+++ b/src/lib/block/block_cipher.h
@@ -8,6 +8,7 @@
#ifndef BOTAN_BLOCK_CIPHER_H__
#define BOTAN_BLOCK_CIPHER_H__
+#include <botan/scan_name.h>
#include <botan/sym_algo.h>
namespace Botan {
@@ -18,6 +19,7 @@ namespace Botan {
class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
{
public:
+ typedef SCAN_Name Spec;
/**
* @return block size of this algorithm
diff --git a/src/lib/block/blowfish/blowfish.cpp b/src/lib/block/blowfish/blowfish.cpp
index d388f9d97..ece1a31fd 100644
--- a/src/lib/block/blowfish/blowfish.cpp
+++ b/src/lib/block/blowfish/blowfish.cpp
@@ -5,11 +5,13 @@
* 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 2ee4251d7..5f04c9d12 100644
--- a/src/lib/block/camellia/camellia.cpp
+++ b/src/lib/block/camellia/camellia.cpp
@@ -5,12 +5,16 @@
* 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 98e862de9..6c0458265 100644
--- a/src/lib/block/cascade/cascade.cpp
+++ b/src/lib/block/cascade/cascade.cpp
@@ -5,10 +5,29 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
+#include <botan/internal/block_utils.h>
+#include <botan/algo_registry.h>
#include <botan/cascade.h>
namespace Botan {
+namespace {
+
+Cascade_Cipher* make_cascade(const BlockCipher::Spec& spec)
+ {
+ auto& block_cipher = Algo_Registry<BlockCipher>::global_registry();
+ std::unique_ptr<BlockCipher> c1(block_cipher.make(spec.arg(0)));
+ std::unique_ptr<BlockCipher> c2(block_cipher.make(spec.arg(1)));
+
+ if(c1 && c2)
+ return new Cascade_Cipher(c1.release(), c2.release());
+ return nullptr;
+ }
+
+}
+
+BOTAN_REGISTER_NAMED_T(BlockCipher, "Cascade", Cascade_Cipher, make_cascade);
+
void Cascade_Cipher::encrypt_n(const byte in[], byte out[],
size_t blocks) const
{
diff --git a/src/lib/block/cast/cast128.cpp b/src/lib/block/cast/cast128.cpp
index e28106c55..3ac54f5e8 100644
--- a/src/lib/block/cast/cast128.cpp
+++ b/src/lib/block/cast/cast128.cpp
@@ -5,13 +5,14 @@
* 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>
-#include <botan/rotate.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 8dc78c11e..bbb9894e7 100644
--- a/src/lib/block/cast/cast256.cpp
+++ b/src/lib/block/cast/cast256.cpp
@@ -5,13 +5,14 @@
* 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>
-#include <botan/rotate.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 3b6c2ee4a..2994b7cb2 100644
--- a/src/lib/block/des/des.cpp
+++ b/src/lib/block/des/des.cpp
@@ -8,12 +8,14 @@
* 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>
-#include <botan/rotate.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 2e5274932..92cfc83cc 100644
--- a/src/lib/block/des/desx.cpp
+++ b/src/lib/block/des/desx.cpp
@@ -5,11 +5,13 @@
* 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 f70072f22..90bf9328d 100644
--- a/src/lib/block/gost_28147/gost_28147.cpp
+++ b/src/lib/block/gost_28147/gost_28147.cpp
@@ -5,12 +5,13 @@
* 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>
-#include <botan/rotate.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 2d282461d..fa98e3754 100644
--- a/src/lib/block/idea/idea.cpp
+++ b/src/lib/block/idea/idea.cpp
@@ -5,11 +5,13 @@
* 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 389fbdd2b..3dfd26860 100644
--- a/src/lib/block/idea_sse2/idea_sse2.cpp
+++ b/src/lib/block/idea_sse2/idea_sse2.cpp
@@ -5,11 +5,15 @@
* 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");
+
namespace {
inline __m128i mul(__m128i X, u16bit K_16)
diff --git a/src/lib/block/info.txt b/src/lib/block/info.txt
index 70e2b2ca2..f10acaa86 100644
--- a/src/lib/block/info.txt
+++ b/src/lib/block/info.txt
@@ -3,3 +3,11 @@ define BLOCK_CIPHER 20131128
<requires>
algo_base
</requires>
+
+<header:public>
+block_cipher.h
+</header:public>
+
+<header:internal>
+block_utils.h
+</header:internal>
diff --git a/src/lib/block/kasumi/kasumi.cpp b/src/lib/block/kasumi/kasumi.cpp
index 53321e94d..d0233cf5c 100644
--- a/src/lib/block/kasumi/kasumi.cpp
+++ b/src/lib/block/kasumi/kasumi.cpp
@@ -5,12 +5,13 @@
* 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>
-#include <botan/rotate.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 7e18eec56..420b92cdb 100644
--- a/src/lib/block/lion/lion.cpp
+++ b/src/lib/block/lion/lion.cpp
@@ -5,12 +5,36 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
+#include <botan/internal/block_utils.h>
#include <botan/lion.h>
-#include <botan/internal/xor_buf.h>
#include <botan/parsing.h>
+#include <botan/libstate.h>
namespace Botan {
+namespace {
+
+Lion* make_lion(const BlockCipher::Spec& spec)
+ {
+ if(spec.arg_count_between(2, 3))
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ const HashFunction* hash = af.prototype_hash_function(spec.arg(0));
+ const StreamCipher* stream_cipher = af.prototype_stream_cipher(spec.arg(1));
+
+ if(hash && stream_cipher)
+ {
+ const size_t block_size = spec.arg_as_integer(2, 1024);
+ return new Lion(hash->clone(), stream_cipher->clone(), block_size);
+ }
+ }
+ return nullptr;
+ }
+
+}
+
+BOTAN_REGISTER_NAMED_T(BlockCipher, "Lion", Lion, make_lion);
+
/*
* Lion Encryption
*/
diff --git a/src/lib/block/mars/mars.cpp b/src/lib/block/mars/mars.cpp
index 6821738dd..50f264861 100644
--- a/src/lib/block/mars/mars.cpp
+++ b/src/lib/block/mars/mars.cpp
@@ -5,12 +5,13 @@
* 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>
-#include <botan/rotate.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 d6ffda945..23233e02f 100644
--- a/src/lib/block/misty1/misty1.cpp
+++ b/src/lib/block/misty1/misty1.cpp
@@ -5,12 +5,14 @@
* 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] = {
@@ -257,14 +259,4 @@ void MISTY1::clear()
zap(DK);
}
-/*
-* MISTY1 Constructor
-*/
-MISTY1::MISTY1(size_t rounds)
- {
- if(rounds != 8)
- throw Invalid_Argument("MISTY1: Invalid number of rounds: "
- + std::to_string(rounds));
- }
-
}
diff --git a/src/lib/block/misty1/misty1.h b/src/lib/block/misty1/misty1.h
index 17b617283..177c2c0b5 100644
--- a/src/lib/block/misty1/misty1.h
+++ b/src/lib/block/misty1/misty1.h
@@ -13,7 +13,7 @@
namespace Botan {
/**
-* MISTY1
+* MISTY1 with 8 rounds
*/
class BOTAN_DLL MISTY1 : public Block_Cipher_Fixed_Params<8, 16>
{
@@ -24,12 +24,6 @@ class BOTAN_DLL MISTY1 : public Block_Cipher_Fixed_Params<8, 16>
void clear();
std::string name() const { return "MISTY1"; }
BlockCipher* clone() const { return new MISTY1; }
-
- /**
- * @param rounds the number of rounds. Must be 8 with the current
- * implementation
- */
- MISTY1(size_t rounds = 8);
private:
void key_schedule(const byte[], size_t);
diff --git a/src/lib/block/noekeon/noekeon.cpp b/src/lib/block/noekeon/noekeon.cpp
index aa593c95f..09a2f6c15 100644
--- a/src/lib/block/noekeon/noekeon.cpp
+++ b/src/lib/block/noekeon/noekeon.cpp
@@ -5,12 +5,13 @@
* 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>
-#include <botan/rotate.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 07fcf19ff..d5995ee1d 100644
--- a/src/lib/block/noekeon_simd/noekeon_simd.cpp
+++ b/src/lib/block/noekeon_simd/noekeon_simd.cpp
@@ -5,11 +5,14 @@
* 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");
+
/*
* Noekeon's Theta Operation
*/
diff --git a/src/lib/block/rc2/rc2.cpp b/src/lib/block/rc2/rc2.cpp
index 329b174e9..54f85ce00 100644
--- a/src/lib/block/rc2/rc2.cpp
+++ b/src/lib/block/rc2/rc2.cpp
@@ -5,12 +5,13 @@
* 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>
-#include <botan/rotate.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 45067678f..27fa0e14d 100644
--- a/src/lib/block/rc5/rc5.cpp
+++ b/src/lib/block/rc5/rc5.cpp
@@ -5,14 +5,14 @@
* 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/rotate.h>
#include <botan/parsing.h>
-#include <algorithm>
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 183395310..e9aa5fe8b 100644
--- a/src/lib/block/rc6/rc6.cpp
+++ b/src/lib/block/rc6/rc6.cpp
@@ -5,13 +5,13 @@
* 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>
-#include <botan/rotate.h>
-#include <algorithm>
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 390e5d9bb..f5996a986 100644
--- a/src/lib/block/safer/safer_sk.cpp
+++ b/src/lib/block/safer/safer_sk.cpp
@@ -5,15 +5,16 @@
* 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>
-#include <botan/rotate.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 833f9943f..316ef1e04 100644
--- a/src/lib/block/seed/seed.cpp
+++ b/src/lib/block/seed/seed.cpp
@@ -5,11 +5,13 @@
* 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 f66cd2a32..0fd76ce8f 100644
--- a/src/lib/block/serpent/serpent.cpp
+++ b/src/lib/block/serpent/serpent.cpp
@@ -5,17 +5,18 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
+#include <botan/internal/block_utils.h>
#include <botan/serpent.h>
#include <botan/internal/serpent_sbox.h>
-#include <botan/loadstor.h>
-#include <botan/rotate.h>
namespace Botan {
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Serpent);
+
namespace {
/*
-* Serpent's Linear Transformation
+* Serpent's Linear Transform
*/
inline void transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
{
@@ -27,7 +28,7 @@ inline void transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
}
/*
-* Serpent's Inverse Linear Transformation
+* Serpent's Inverse Linear Transform
*/
inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
{
diff --git a/src/lib/block/serpent_simd/serp_simd.cpp b/src/lib/block/serpent_simd/serp_simd.cpp
index 1a379efca..fa7f419fe 100644
--- a/src/lib/block/serpent_simd/serp_simd.cpp
+++ b/src/lib/block/serpent_simd/serp_simd.cpp
@@ -5,13 +5,15 @@
* 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>
-#include <botan/loadstor.h>
namespace Botan {
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Serpent_SIMD, "Serpent", "simd32");
+
namespace {
#define key_xor(round, B0, B1, B2, B3) \
diff --git a/src/lib/block/serpent_x86_32/serp_x86_32.cpp b/src/lib/block/serpent_x86_32/serp_x86_32.cpp
index 5548e3496..3c326d084 100644
--- a/src/lib/block/serpent_x86_32/serp_x86_32.cpp
+++ b/src/lib/block/serpent_x86_32/serp_x86_32.cpp
@@ -5,11 +5,13 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
+#include <botan/internal/block_utils.h>
#include <botan/serp_x86_32.h>
-#include <botan/loadstor.h>
namespace Botan {
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Serpent_X86_32, "Serpent", "x86-32");
+
extern "C" {
/**
diff --git a/src/lib/block/tea/tea.cpp b/src/lib/block/tea/tea.cpp
index 01f342607..ef630f715 100644
--- a/src/lib/block/tea/tea.cpp
+++ b/src/lib/block/tea/tea.cpp
@@ -5,11 +5,13 @@
* 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 f6636615b..322f54881 100644
--- a/src/lib/block/threefish/threefish.cpp
+++ b/src/lib/block/threefish/threefish.cpp
@@ -5,12 +5,13 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
+#include <botan/internal/block_utils.h>
#include <botan/threefish.h>
-#include <botan/rotate.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; \
@@ -223,6 +224,7 @@ void Threefish_512::set_tweak(const byte tweak[], size_t len)
{
if(len != 16)
throw std::runtime_error("Unsupported twofish tweak length");
+ m_T.resize(3);
m_T[0] = load_le<u64bit>(tweak, 0);
m_T[1] = load_le<u64bit>(tweak, 1);
m_T[2] = m_T[0] ^ m_T[1];
@@ -238,6 +240,10 @@ void Threefish_512::key_schedule(const byte key[], size_t)
m_K[8] = m_K[0] ^ m_K[1] ^ m_K[2] ^ m_K[3] ^
m_K[4] ^ m_K[5] ^ m_K[6] ^ m_K[7] ^ 0x1BD11BDAA9FC1A22;
+
+ // Reset tweak to all zeros on key reset
+ m_T.resize(3);
+ zeroise(m_T);
}
void Threefish_512::clear()
diff --git a/src/lib/block/threefish/threefish.h b/src/lib/block/threefish/threefish.h
index 6020b8a28..373600885 100644
--- a/src/lib/block/threefish/threefish.h
+++ b/src/lib/block/threefish/threefish.h
@@ -26,9 +26,6 @@ class BOTAN_DLL Threefish_512 : public Block_Cipher_Fixed_Params<64, 64>
void clear() override;
std::string name() const override { return "Threefish-512"; }
BlockCipher* clone() const override { return new Threefish_512; }
-
- Threefish_512() : m_T(3) {}
-
protected:
const secure_vector<u64bit>& get_T() const { return m_T; }
const secure_vector<u64bit>& get_K() const { return m_K; }
diff --git a/src/lib/block/threefish_avx2/threefish_avx2.cpp b/src/lib/block/threefish_avx2/threefish_avx2.cpp
index ee0ecde85..432059585 100644
--- a/src/lib/block/threefish_avx2/threefish_avx2.cpp
+++ b/src/lib/block/threefish_avx2/threefish_avx2.cpp
@@ -1,15 +1,19 @@
/*
-* Threefish-512
+* Threefish-512 using AVX2
* (C) 2013 Jack Lloyd
*
* 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");
+
namespace {
inline void interleave_epi64(__m256i& X0, __m256i& X1)
diff --git a/src/lib/block/threefish_avx2/threefish_avx2.h b/src/lib/block/threefish_avx2/threefish_avx2.h
index ba24f114f..d851ff0dc 100644
--- a/src/lib/block/threefish_avx2/threefish_avx2.h
+++ b/src/lib/block/threefish_avx2/threefish_avx2.h
@@ -20,6 +20,12 @@ class BOTAN_DLL Threefish_512_AVX2 : public Threefish_512
private:
void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+
+ /* TODO:
+ void skein_feedfwd(const secure_vector<u64bit>& M,
+ const secure_vector<u64bit>& T) override;
+ */
+
BlockCipher* clone() const override { return new Threefish_512_AVX2; }
};
diff --git a/src/lib/block/twofish/twofish.cpp b/src/lib/block/twofish/twofish.cpp
index ffdf4b198..43ea41bfd 100644
--- a/src/lib/block/twofish/twofish.cpp
+++ b/src/lib/block/twofish/twofish.cpp
@@ -8,12 +8,13 @@
* 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 59060dff7..9fe265457 100644
--- a/src/lib/block/xtea/xtea.cpp
+++ b/src/lib/block/xtea/xtea.cpp
@@ -5,11 +5,13 @@
* 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 87c7a20bf..6fd2f94c7 100644
--- a/src/lib/block/xtea_simd/xtea_simd.cpp
+++ b/src/lib/block/xtea_simd/xtea_simd.cpp
@@ -5,12 +5,14 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
+#include <botan/internal/block_utils.h>
#include <botan/xtea_simd.h>
-#include <botan/loadstor.h>
#include <botan/internal/simd_32.h>
namespace Botan {
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), XTEA_SIMD, "XTEA", "simd32");
+
namespace {
void xtea_encrypt_8(const byte in[64], byte out[64], const u32bit EK[64])