aboutsummaryrefslogtreecommitdiffstats
path: root/src/block
diff options
context:
space:
mode:
Diffstat (limited to 'src/block')
-rw-r--r--src/block/aes/aes.cpp126
-rw-r--r--src/block/aes/aes.h69
-rw-r--r--src/block/aes_intel/aes_intel.h18
-rw-r--r--src/block/aes_ssse3/aes_ssse3.h15
-rw-r--r--src/block/block_cipher.h16
-rw-r--r--src/block/blowfish/blowfish.h4
-rw-r--r--src/block/cast/cast128.h4
-rw-r--r--src/block/cast/cast256.h4
-rw-r--r--src/block/des/des.h8
-rw-r--r--src/block/des/desx.h4
-rw-r--r--src/block/gost_28147/gost_28147.cpp2
-rw-r--r--src/block/gost_28147/gost_28147.h4
-rw-r--r--src/block/idea/idea.h4
-rw-r--r--src/block/kasumi/kasumi.h4
-rw-r--r--src/block/mars/mars.h4
-rw-r--r--src/block/misty1/misty1.cpp4
-rw-r--r--src/block/misty1/misty1.h2
-rw-r--r--src/block/noekeon/noekeon.h4
-rw-r--r--src/block/rc2/rc2.h4
-rw-r--r--src/block/rc5/rc5.cpp2
-rw-r--r--src/block/rc5/rc5.h2
-rw-r--r--src/block/rc6/rc6.h4
-rw-r--r--src/block/safer/safer_sk.cpp3
-rw-r--r--src/block/safer/safer_sk.h2
-rw-r--r--src/block/seed/seed.h4
-rw-r--r--src/block/serpent/serpent.h5
-rw-r--r--src/block/skipjack/skipjack.h4
-rw-r--r--src/block/square/square.h6
-rw-r--r--src/block/tea/tea.h4
-rw-r--r--src/block/twofish/twofish.h6
-rw-r--r--src/block/xtea/xtea.h4
31 files changed, 193 insertions, 153 deletions
diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp
index b317fa735..f149a0ac0 100644
--- a/src/block/aes/aes.cpp
+++ b/src/block/aes/aes.cpp
@@ -1,6 +1,6 @@
/*
* AES
-* (C) 1999-2009 Jack Lloyd
+* (C) 1999-2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -410,13 +410,16 @@ const u32bit TD[1024] = {
0x3C498B28, 0x0D9541FF, 0xA8017139, 0x0CB3DE08, 0xB4E49CD8, 0x56C19064,
0xCB84617B, 0x32B670D5, 0x6C5C7448, 0xB85742D0 };
-}
-
/*
* AES Encryption
*/
-void AES::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void aes_encrypt_n(const byte in[], byte out[],
+ size_t blocks,
+ const MemoryRegion<u32bit>& EK,
+ const MemoryRegion<byte>& ME)
{
+ const size_t BLOCK_SIZE = 16;
+
const u32bit* TE0 = TE;
const u32bit* TE1 = TE + 256;
const u32bit* TE2 = TE + 512;
@@ -522,8 +525,12 @@ void AES::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* AES Decryption
*/
-void AES::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void aes_decrypt_n(const byte in[], byte out[], size_t blocks,
+ const MemoryRegion<u32bit>& DK,
+ const MemoryRegion<byte>& MD)
{
+ const size_t BLOCK_SIZE = 16;
+
const u32bit* TD0 = TD;
const u32bit* TD1 = TD + 256;
const u32bit* TD2 = TD + 512;
@@ -599,18 +606,19 @@ void AES::decrypt_n(const byte in[], byte out[], size_t blocks) const
}
}
-/*
-* AES Key Schedule
-*/
-void AES::key_schedule(const byte key[], size_t length)
+void aes_key_schedule(const byte key[], size_t length,
+ MemoryRegion<u32bit>& EK,
+ MemoryRegion<u32bit>& DK,
+ MemoryRegion<byte>& ME,
+ MemoryRegion<byte>& MD)
{
static const u32bit RC[10] = {
- 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000,
- 0x40000000, 0x80000000, 0x1B000000, 0x36000000 };
+ 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000,
+ 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000 };
const u32bit rounds = (length / 4) + 6;
- SecureVector<u32bit> XEK(64), XDK(64);
+ SecureVector<u32bit> XEK(length + 32), XDK(length + 32);
const size_t X = length / 4;
for(size_t i = 0; i != X; ++i)
@@ -618,13 +626,23 @@ void AES::key_schedule(const byte key[], size_t length)
for(size_t i = X; i < 4*(rounds+1); i += X)
{
- XEK[i] = XEK[i-X] ^ S(rotate_left(XEK[i-1], 8)) ^ RC[(i-X)/X];
+ XEK[i] = XEK[i-X] ^ RC[(i-X)/X] ^
+ make_u32bit(SE[get_byte(1, XEK[i-1])],
+ SE[get_byte(2, XEK[i-1])],
+ SE[get_byte(3, XEK[i-1])],
+ SE[get_byte(0, XEK[i-1])]);
+
for(size_t j = 1; j != X; ++j)
{
+ XEK[i+j] = XEK[i+j-X];
+
if(X == 8 && j == 4)
- XEK[i+j] = XEK[i+j-X] ^ S(XEK[i+j-1]);
+ XEK[i+j] ^= make_u32bit(SE[get_byte(0, XEK[i+j-1])],
+ SE[get_byte(1, XEK[i+j-1])],
+ SE[get_byte(2, XEK[i+j-1])],
+ SE[get_byte(3, XEK[i+j-1])]);
else
- XEK[i+j] = XEK[i+j-X] ^ XEK[i+j-1];
+ XEK[i+j] ^= XEK[i+j-1];
}
}
@@ -652,38 +670,70 @@ void AES::key_schedule(const byte key[], size_t length)
DK.set(&XDK[0], length + 24);
}
-/*
-* AES Byte Substitution
-*/
-u32bit AES::S(u32bit input)
+}
+
+void AES_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
- return make_u32bit(SE[get_byte(0, input)], SE[get_byte(1, input)],
- SE[get_byte(2, input)], SE[get_byte(3, input)]);
+ aes_encrypt_n(in, out, blocks, EK, ME);
}
-/*
-* AES Constructor
-*/
-AES::AES() : BlockCipher_Fixed_Block_Size(16, 32, 8),
- EK(0), ME(16), DK(0), MD(16)
+void AES_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
+ aes_decrypt_n(in, out, blocks, DK, MD);
}
-/*
-* AES Constructor
-*/
-AES::AES(size_t key_size) : BlockCipher_Fixed_Block_Size(key_size),
- EK(key_size+24), ME(16),
- DK(key_size+24), MD(16)
+void AES_128::key_schedule(const byte key[], size_t length)
{
- if(key_size != 16 && key_size != 24 && key_size != 32)
- throw Invalid_Key_Length(name(), key_size);
+ aes_key_schedule(key, length, EK, DK, ME, MD);
}
-/*
-* Clear memory of sensitive data
-*/
-void AES::clear()
+void AES_128::clear()
+ {
+ zeroise(EK);
+ zeroise(DK);
+ zeroise(ME);
+ zeroise(MD);
+ }
+
+void AES_192::encrypt_n(const byte in[], byte out[], size_t blocks) const
+ {
+ aes_encrypt_n(in, out, blocks, EK, ME);
+ }
+
+void AES_192::decrypt_n(const byte in[], byte out[], size_t blocks) const
+ {
+ aes_decrypt_n(in, out, blocks, DK, MD);
+ }
+
+void AES_192::key_schedule(const byte key[], size_t length)
+ {
+ aes_key_schedule(key, length, EK, DK, ME, MD);
+ }
+
+void AES_192::clear()
+ {
+ zeroise(EK);
+ zeroise(DK);
+ zeroise(ME);
+ zeroise(MD);
+ }
+
+void AES_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
+ {
+ aes_encrypt_n(in, out, blocks, EK, ME);
+ }
+
+void AES_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
+ {
+ aes_decrypt_n(in, out, blocks, DK, MD);
+ }
+
+void AES_256::key_schedule(const byte key[], size_t length)
+ {
+ aes_key_schedule(key, length, EK, DK, ME, MD);
+ }
+
+void AES_256::clear()
{
zeroise(EK);
zeroise(DK);
diff --git a/src/block/aes/aes.h b/src/block/aes/aes.h
index d2e051f83..a165f83b5 100644
--- a/src/block/aes/aes.h
+++ b/src/block/aes/aes.h
@@ -1,6 +1,6 @@
/*
* AES
-* (C) 1999-2009 Jack Lloyd
+* (C) 1999-2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -13,68 +13,69 @@
namespace Botan {
/**
-* Rijndael aka AES
+* AES-128
*/
-class BOTAN_DLL AES : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL AES_128 : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- std::string name() const { return "AES"; }
+ AES_128() : EK(40), DK(40), ME(16), MD(16) {}
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
void decrypt_n(const byte in[], byte out[], size_t blocks) const;
void clear();
- BlockCipher* clone() const { return new AES; }
-
- AES();
-
- /**
- * AES fixed to a particular key_size (16, 24, or 32 bytes)
- * @param key_size the chosen fixed key size
- */
- AES(size_t key_size);
- private:
- void key_schedule(const byte[], size_t);
- static u32bit S(u32bit);
- SecureVector<u32bit> EK;
- SecureVector<byte> ME;
-
- SecureVector<u32bit > DK;
- SecureVector<byte> MD;
- };
-
-/**
-* AES-128
-*/
-class BOTAN_DLL AES_128 : public AES
- {
- public:
std::string name() const { return "AES-128"; }
BlockCipher* clone() const { return new AES_128; }
- AES_128() : AES(16) {}
+ private:
+ void key_schedule(const byte key[], size_t length);
+
+ SecureVector<u32bit> EK, DK;
+ SecureVector<byte> ME, MD;
};
/**
* AES-192
*/
-class BOTAN_DLL AES_192 : public AES
+class BOTAN_DLL AES_192 : public Block_Cipher_Fixed_Params<16, 24>
{
public:
+ AES_192() : EK(48), DK(48), ME(16), MD(16) {}
+
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
+
+ void clear();
+
std::string name() const { return "AES-192"; }
BlockCipher* clone() const { return new AES_192; }
- AES_192() : AES(24) {}
+ private:
+ void key_schedule(const byte key[], size_t length);
+
+ SecureVector<u32bit> EK, DK;
+ SecureVector<byte> ME, MD;
};
/**
* AES-256
*/
-class BOTAN_DLL AES_256 : public AES
+class BOTAN_DLL AES_256 : public Block_Cipher_Fixed_Params<16, 32>
{
public:
+ AES_256() : EK(56), DK(56), ME(16), MD(16) {}
+
+ void encrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void decrypt_n(const byte in[], byte out[], size_t blocks) const;
+
+ void clear();
+
std::string name() const { return "AES-256"; }
BlockCipher* clone() const { return new AES_256; }
- AES_256() : AES(32) {}
+ private:
+ void key_schedule(const byte key[], size_t length);
+
+ SecureVector<u32bit> EK, DK;
+ SecureVector<byte> ME, MD;
};
}
diff --git a/src/block/aes_intel/aes_intel.h b/src/block/aes_intel/aes_intel.h
index 1d8a68389..a8e6b53e8 100644
--- a/src/block/aes_intel/aes_intel.h
+++ b/src/block/aes_intel/aes_intel.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* AES-128 using AES-NI
*/
-class BOTAN_DLL AES_128_Intel : public BlockCipher
+class BOTAN_DLL AES_128_Intel : public Block_Cipher_Fixed_Params<16, 16>
{
public:
size_t parallelism() const { return 4; }
@@ -27,17 +27,17 @@ class BOTAN_DLL AES_128_Intel : public BlockCipher
std::string name() const { return "AES-128"; }
BlockCipher* clone() const { return new AES_128_Intel; }
- AES_128_Intel() : BlockCipher(16, 16) { }
+ AES_128_Intel() : EK(44), DK(44) { }
private:
void key_schedule(const byte[], size_t);
- SecureVector<u32bit, 44> EK, DK;
+ SecureVector<u32bit> EK, DK;
};
/**
* AES-192 using AES-NI
*/
-class BOTAN_DLL AES_192_Intel : public BlockCipher
+class BOTAN_DLL AES_192_Intel : public Block_Cipher_Fixed_Params<16, 24>
{
public:
size_t parallelism() const { return 4; }
@@ -49,17 +49,17 @@ class BOTAN_DLL AES_192_Intel : public BlockCipher
std::string name() const { return "AES-192"; }
BlockCipher* clone() const { return new AES_192_Intel; }
- AES_192_Intel() : BlockCipher(16, 24) { }
+ AES_192_Intel() : EK(52), DK(52) { }
private:
void key_schedule(const byte[], size_t);
- SecureVector<u32bit, 52> EK, DK;
+ SecureVector<u32bit> EK, DK;
};
/**
* AES-256 using AES-NI
*/
-class BOTAN_DLL AES_256_Intel : public BlockCipher
+class BOTAN_DLL AES_256_Intel : public Block_Cipher_Fixed_Params<16, 32>
{
public:
size_t parallelism() const { return 4; }
@@ -71,11 +71,11 @@ class BOTAN_DLL AES_256_Intel : public BlockCipher
std::string name() const { return "AES-256"; }
BlockCipher* clone() const { return new AES_256_Intel; }
- AES_256_Intel() : BlockCipher(16, 32) { }
+ AES_256_Intel() : EK(60), DK(60) { }
private:
void key_schedule(const byte[], size_t);
- SecureVector<u32bit, 60> EK, DK;
+ SecureVector<u32bit> EK, DK;
};
}
diff --git a/src/block/aes_ssse3/aes_ssse3.h b/src/block/aes_ssse3/aes_ssse3.h
index 59bb85f12..686b7999f 100644
--- a/src/block/aes_ssse3/aes_ssse3.h
+++ b/src/block/aes_ssse3/aes_ssse3.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* AES-128 using SSSE3
*/
-class BOTAN_DLL AES_128_SSSE3 : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL AES_128_SSSE3 : public Block_Cipher_Fixed_Params<16, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,8 +25,7 @@ class BOTAN_DLL AES_128_SSSE3 : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "AES-128"; }
BlockCipher* clone() const { return new AES_128_SSSE3; }
- AES_128_SSSE3() : BlockCipher_Fixed_Block_Size(16),
- EK(44), DK(44) {}
+ AES_128_SSSE3() : EK(44), DK(44) {}
private:
void key_schedule(const byte[], size_t);
@@ -36,7 +35,7 @@ class BOTAN_DLL AES_128_SSSE3 : public BlockCipher_Fixed_Block_Size<16>
/**
* AES-192 using SSSE3
*/
-class BOTAN_DLL AES_192_SSSE3 : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL AES_192_SSSE3 : public Block_Cipher_Fixed_Params<16, 24>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -46,8 +45,7 @@ class BOTAN_DLL AES_192_SSSE3 : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "AES-192"; }
BlockCipher* clone() const { return new AES_192_SSSE3; }
- AES_192_SSSE3() : BlockCipher_Fixed_Block_Size(24),
- EK(52), DK(52) {}
+ AES_192_SSSE3() : EK(52), DK(52) {}
private:
void key_schedule(const byte[], size_t);
@@ -57,7 +55,7 @@ class BOTAN_DLL AES_192_SSSE3 : public BlockCipher_Fixed_Block_Size<16>
/**
* AES-256 using SSSE3
*/
-class BOTAN_DLL AES_256_SSSE3 : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL AES_256_SSSE3 : public Block_Cipher_Fixed_Params<16, 32>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -67,8 +65,7 @@ class BOTAN_DLL AES_256_SSSE3 : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "AES-256"; }
BlockCipher* clone() const { return new AES_256_SSSE3; }
- AES_256_SSSE3() : BlockCipher_Fixed_Block_Size(32),
- EK(60), DK(60) {}
+ AES_256_SSSE3() : EK(60), DK(60) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/block_cipher.h b/src/block/block_cipher.h
index 3e14e0739..b5a3c8439 100644
--- a/src/block/block_cipher.h
+++ b/src/block/block_cipher.h
@@ -115,17 +115,17 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
virtual void clear() = 0;
};
-template<size_t N>
-class BlockCipher_Fixed_Block_Size : public BlockCipher
+/**
+* Represents a block cipher with a single fixed block size
+*/
+template<size_t BS, size_t KMIN, size_t KMAX = 0, size_t KMOD = 1>
+class Block_Cipher_Fixed_Params : public BlockCipher
{
public:
- BlockCipher_Fixed_Block_Size(size_t kmin,
- size_t kmax = 0,
- size_t kmod = 1) :
- BlockCipher(kmin, kmax, kmod) {}
+ Block_Cipher_Fixed_Params() : BlockCipher(KMIN, KMAX, KMOD) {}
- enum { BLOCK_SIZE = N };
- size_t block_size() const { return N; }
+ enum { BLOCK_SIZE = BS };
+ size_t block_size() const { return BS; }
};
}
diff --git a/src/block/blowfish/blowfish.h b/src/block/blowfish/blowfish.h
index c9bf8b2e0..b89ffcaaa 100644
--- a/src/block/blowfish/blowfish.h
+++ b/src/block/blowfish/blowfish.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* Blowfish
*/
-class BOTAN_DLL Blowfish : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL Blowfish : public Block_Cipher_Fixed_Params<8, 1, 56>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL Blowfish : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "Blowfish"; }
BlockCipher* clone() const { return new Blowfish; }
- Blowfish() : BlockCipher_Fixed_Block_Size(1, 56), S(1024), P(18) {}
+ Blowfish() : S(1024), P(18) {}
private:
void key_schedule(const byte[], size_t);
void generate_sbox(MemoryRegion<u32bit>& box,
diff --git a/src/block/cast/cast128.h b/src/block/cast/cast128.h
index 3ecbcaa5a..10c646c94 100644
--- a/src/block/cast/cast128.h
+++ b/src/block/cast/cast128.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* CAST-128
*/
-class BOTAN_DLL CAST_128 : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL CAST_128 : public Block_Cipher_Fixed_Params<8, 11, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL CAST_128 : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "CAST-128"; }
BlockCipher* clone() const { return new CAST_128; }
- CAST_128() : BlockCipher_Fixed_Block_Size(11, 16), MK(16), RK(16) {}
+ CAST_128() : MK(16), RK(16) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/cast/cast256.h b/src/block/cast/cast256.h
index 0dda7f0d7..2f2beef47 100644
--- a/src/block/cast/cast256.h
+++ b/src/block/cast/cast256.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* CAST-256
*/
-class BOTAN_DLL CAST_256 : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL CAST_256 : public Block_Cipher_Fixed_Params<16, 4, 32, 4>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL CAST_256 : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "CAST-256"; }
BlockCipher* clone() const { return new CAST_256; }
- CAST_256() : BlockCipher_Fixed_Block_Size(4, 32, 4), MK(48), RK(48) {}
+ CAST_256() : MK(48), RK(48) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/des/des.h b/src/block/des/des.h
index d758cc4c1..db5a375e0 100644
--- a/src/block/des/des.h
+++ b/src/block/des/des.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* DES
*/
-class BOTAN_DLL DES : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL DES : public Block_Cipher_Fixed_Params<8, 8>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL DES : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "DES"; }
BlockCipher* clone() const { return new DES; }
- DES() : BlockCipher_Fixed_Block_Size(8), round_key(32) {}
+ DES() : round_key(32) {}
private:
void key_schedule(const byte[], size_t);
@@ -35,7 +35,7 @@ class BOTAN_DLL DES : public BlockCipher_Fixed_Block_Size<8>
/**
* Triple DES
*/
-class BOTAN_DLL TripleDES : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL TripleDES : public Block_Cipher_Fixed_Params<8, 16, 24, 8>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -45,7 +45,7 @@ class BOTAN_DLL TripleDES : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "TripleDES"; }
BlockCipher* clone() const { return new TripleDES; }
- TripleDES() : BlockCipher_Fixed_Block_Size(16, 24, 8), round_key(96) {}
+ TripleDES() : round_key(96) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/des/desx.h b/src/block/des/desx.h
index 962575529..993eca86b 100644
--- a/src/block/des/desx.h
+++ b/src/block/des/desx.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* DESX
*/
-class BOTAN_DLL DESX : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL DESX : public Block_Cipher_Fixed_Params<8, 24>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL DESX : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "DESX"; }
BlockCipher* clone() const { return new DESX; }
- DESX() : BlockCipher_Fixed_Block_Size(24), K1(8), K2(8) {}
+ DESX() : K1(8), K2(8) {}
private:
void key_schedule(const byte[], size_t);
SecureVector<byte> K1, K2;
diff --git a/src/block/gost_28147/gost_28147.cpp b/src/block/gost_28147/gost_28147.cpp
index 9adc0d568..07f3359cd 100644
--- a/src/block/gost_28147/gost_28147.cpp
+++ b/src/block/gost_28147/gost_28147.cpp
@@ -52,7 +52,7 @@ GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : name(n)
* GOST Constructor
*/
GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) :
- BlockCipher_Fixed_Block_Size(32), SBOX(1024), EK(8)
+ SBOX(1024), EK(8)
{
// Convert the parallel 4x4 sboxes into larger word-based sboxes
for(size_t i = 0; i != 4; ++i)
diff --git a/src/block/gost_28147/gost_28147.h b/src/block/gost_28147/gost_28147.h
index adf542bbe..75ba74c44 100644
--- a/src/block/gost_28147/gost_28147.h
+++ b/src/block/gost_28147/gost_28147.h
@@ -49,7 +49,7 @@ class BOTAN_DLL GOST_28147_89_Params
/**
* GOST 28147-89
*/
-class BOTAN_DLL GOST_28147_89 : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL GOST_28147_89 : public Block_Cipher_Fixed_Params<8, 32>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -66,7 +66,7 @@ class BOTAN_DLL GOST_28147_89 : public BlockCipher_Fixed_Block_Size<8>
GOST_28147_89(const GOST_28147_89_Params& params);
private:
GOST_28147_89(const SecureVector<u32bit>& other_SBOX) :
- BlockCipher_Fixed_Block_Size(32), SBOX(other_SBOX), EK(8) {}
+ SBOX(other_SBOX), EK(8) {}
void key_schedule(const byte[], size_t);
diff --git a/src/block/idea/idea.h b/src/block/idea/idea.h
index 3552d282f..42fa60c47 100644
--- a/src/block/idea/idea.h
+++ b/src/block/idea/idea.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* IDEA
*/
-class BOTAN_DLL IDEA : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL IDEA : public Block_Cipher_Fixed_Params<8, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL IDEA : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "IDEA"; }
BlockCipher* clone() const { return new IDEA; }
- IDEA() : BlockCipher_Fixed_Block_Size(16), EK(52), DK(52) {}
+ IDEA() : EK(52), DK(52) {}
protected:
/**
* @return const reference to encryption subkeys
diff --git a/src/block/kasumi/kasumi.h b/src/block/kasumi/kasumi.h
index 7b416f193..7871aa170 100644
--- a/src/block/kasumi/kasumi.h
+++ b/src/block/kasumi/kasumi.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* KASUMI, the block cipher used in 3G telephony
*/
-class BOTAN_DLL KASUMI : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL KASUMI : public Block_Cipher_Fixed_Params<8, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL KASUMI : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "KASUMI"; }
BlockCipher* clone() const { return new KASUMI; }
- KASUMI() : BlockCipher_Fixed_Block_Size(16), EK(64) {}
+ KASUMI() : EK(64) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/mars/mars.h b/src/block/mars/mars.h
index 7a53d116b..5ca05f886 100644
--- a/src/block/mars/mars.h
+++ b/src/block/mars/mars.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* MARS, IBM's candidate for AES
*/
-class BOTAN_DLL MARS : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL MARS : public Block_Cipher_Fixed_Params<16, 16, 32, 4>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL MARS : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "MARS"; }
BlockCipher* clone() const { return new MARS; }
- MARS() : BlockCipher_Fixed_Block_Size(16, 32, 4), EK(40) {}
+ MARS() : EK(40) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/misty1/misty1.cpp b/src/block/misty1/misty1.cpp
index 9ad30502c..77d1047b1 100644
--- a/src/block/misty1/misty1.cpp
+++ b/src/block/misty1/misty1.cpp
@@ -251,9 +251,7 @@ void MISTY1::key_schedule(const byte key[], size_t length)
/*
* MISTY1 Constructor
*/
-MISTY1::MISTY1(size_t rounds) :
- BlockCipher_Fixed_Block_Size(16),
- EK(100), DK(100)
+MISTY1::MISTY1(size_t rounds) : EK(100), DK(100)
{
if(rounds != 8)
throw Invalid_Argument("MISTY1: Invalid number of rounds: "
diff --git a/src/block/misty1/misty1.h b/src/block/misty1/misty1.h
index 3bd05b4c6..14d8a2958 100644
--- a/src/block/misty1/misty1.h
+++ b/src/block/misty1/misty1.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* MISTY1
*/
-class BOTAN_DLL MISTY1 : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL MISTY1 : public Block_Cipher_Fixed_Params<8, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
diff --git a/src/block/noekeon/noekeon.h b/src/block/noekeon/noekeon.h
index 79c627579..7c5c73dcb 100644
--- a/src/block/noekeon/noekeon.h
+++ b/src/block/noekeon/noekeon.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* Noekeon
*/
-class BOTAN_DLL Noekeon : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL Noekeon : public Block_Cipher_Fixed_Params<16, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL Noekeon : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "Noekeon"; }
BlockCipher* clone() const { return new Noekeon; }
- Noekeon() : BlockCipher_Fixed_Block_Size(16), EK(4), DK(4) {}
+ Noekeon() : EK(4), DK(4) {}
protected:
/**
* The Noekeon round constants
diff --git a/src/block/rc2/rc2.h b/src/block/rc2/rc2.h
index ad4b1a308..1ebad1e73 100644
--- a/src/block/rc2/rc2.h
+++ b/src/block/rc2/rc2.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* RC2
*/
-class BOTAN_DLL RC2 : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL RC2 : public Block_Cipher_Fixed_Params<8, 1, 32>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -32,7 +32,7 @@ class BOTAN_DLL RC2 : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "RC2"; }
BlockCipher* clone() const { return new RC2; }
- RC2() : BlockCipher_Fixed_Block_Size(1, 32), K(64) {}
+ RC2() : K(64) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/rc5/rc5.cpp b/src/block/rc5/rc5.cpp
index d08b44425..981f73564 100644
--- a/src/block/rc5/rc5.cpp
+++ b/src/block/rc5/rc5.cpp
@@ -122,7 +122,7 @@ std::string RC5::name() const
/*
* RC5 Constructor
*/
-RC5::RC5(size_t rounds) : BlockCipher_Fixed_Block_Size(1, 32)
+RC5::RC5(size_t rounds)
{
if(rounds < 8 || rounds > 32 || (rounds % 4 != 0))
throw Invalid_Argument("RC5: Invalid number of rounds " +
diff --git a/src/block/rc5/rc5.h b/src/block/rc5/rc5.h
index cb282af4e..c69705471 100644
--- a/src/block/rc5/rc5.h
+++ b/src/block/rc5/rc5.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* RC5
*/
-class BOTAN_DLL RC5 : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL RC5 : public Block_Cipher_Fixed_Params<8, 1, 32>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
diff --git a/src/block/rc6/rc6.h b/src/block/rc6/rc6.h
index 8446138e0..af7b62316 100644
--- a/src/block/rc6/rc6.h
+++ b/src/block/rc6/rc6.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* RC6, Ron Rivest's AES candidate
*/
-class BOTAN_DLL RC6 : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL RC6 : public Block_Cipher_Fixed_Params<16, 1, 32>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL RC6 : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "RC6"; }
BlockCipher* clone() const { return new RC6; }
- RC6() : BlockCipher_Fixed_Block_Size(1, 32), S(44) {}
+ RC6() : S(44) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/safer/safer_sk.cpp b/src/block/safer/safer_sk.cpp
index a91e5f687..1d103040d 100644
--- a/src/block/safer/safer_sk.cpp
+++ b/src/block/safer/safer_sk.cpp
@@ -131,8 +131,7 @@ BlockCipher* SAFER_SK::clone() const
/*
* SAFER-SK Constructor
*/
-SAFER_SK::SAFER_SK(size_t rounds) :
- BlockCipher_Fixed_Block_Size(16)
+SAFER_SK::SAFER_SK(size_t rounds)
{
if(rounds > 13 || rounds == 0)
throw Invalid_Argument(name() + ": Invalid number of rounds");
diff --git a/src/block/safer/safer_sk.h b/src/block/safer/safer_sk.h
index 2fde757bd..803afffa0 100644
--- a/src/block/safer/safer_sk.h
+++ b/src/block/safer/safer_sk.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* SAFER-SK
*/
-class BOTAN_DLL SAFER_SK : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL SAFER_SK : public Block_Cipher_Fixed_Params<8, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
diff --git a/src/block/seed/seed.h b/src/block/seed/seed.h
index 649e28a68..979312930 100644
--- a/src/block/seed/seed.h
+++ b/src/block/seed/seed.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* SEED, a Korean block cipher
*/
-class BOTAN_DLL SEED : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL SEED : public Block_Cipher_Fixed_Params<16, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL SEED : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "SEED"; }
BlockCipher* clone() const { return new SEED; }
- SEED() : BlockCipher_Fixed_Block_Size(16), K(32) {}
+ SEED() : K(32) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/serpent/serpent.h b/src/block/serpent/serpent.h
index fccdcf214..33bd747cd 100644
--- a/src/block/serpent/serpent.h
+++ b/src/block/serpent/serpent.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* Serpent, an AES finalist
*/
-class BOTAN_DLL Serpent : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL Serpent : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,8 +25,7 @@ class BOTAN_DLL Serpent : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "Serpent"; }
BlockCipher* clone() const { return new Serpent; }
- Serpent() : BlockCipher_Fixed_Block_Size(16, 32, 8),
- round_key(132) {}
+ Serpent() : round_key(132) {}
protected:
/**
* For use by subclasses using SIMD, asm, etc
diff --git a/src/block/skipjack/skipjack.h b/src/block/skipjack/skipjack.h
index 73ae28de2..051d35351 100644
--- a/src/block/skipjack/skipjack.h
+++ b/src/block/skipjack/skipjack.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* Skipjack, a NSA designed cipher used in Fortezza
*/
-class BOTAN_DLL Skipjack : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL Skipjack : public Block_Cipher_Fixed_Params<8, 10>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL Skipjack : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "Skipjack"; }
BlockCipher* clone() const { return new Skipjack; }
- Skipjack() : BlockCipher_Fixed_Block_Size(10), FTAB(2560) {}
+ Skipjack() : FTAB(2560) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/square/square.h b/src/block/square/square.h
index d6df63131..5147c0383 100644
--- a/src/block/square/square.h
+++ b/src/block/square/square.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* Square
*/
-class BOTAN_DLL Square : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL Square : public Block_Cipher_Fixed_Params<16, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,9 +25,7 @@ class BOTAN_DLL Square : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "Square"; }
BlockCipher* clone() const { return new Square; }
- Square() : BlockCipher_Fixed_Block_Size(16),
- EK(28), DK(28), ME(32), MD(32) {}
-
+ Square() : EK(28), DK(28), ME(32), MD(32) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/tea/tea.h b/src/block/tea/tea.h
index a7318ba5c..0290b112f 100644
--- a/src/block/tea/tea.h
+++ b/src/block/tea/tea.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* TEA
*/
-class BOTAN_DLL TEA : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL TEA : public Block_Cipher_Fixed_Params<8, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL TEA : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "TEA"; }
BlockCipher* clone() const { return new TEA; }
- TEA() : BlockCipher_Fixed_Block_Size(16), K(4) {}
+ TEA() : K(4) {}
private:
void key_schedule(const byte[], size_t);
SecureVector<u32bit> K;
diff --git a/src/block/twofish/twofish.h b/src/block/twofish/twofish.h
index a212bd285..7594bdcfd 100644
--- a/src/block/twofish/twofish.h
+++ b/src/block/twofish/twofish.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* Twofish, an AES finalist
*/
-class BOTAN_DLL Twofish : public BlockCipher_Fixed_Block_Size<16>
+class BOTAN_DLL Twofish : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,9 +25,7 @@ class BOTAN_DLL Twofish : public BlockCipher_Fixed_Block_Size<16>
std::string name() const { return "Twofish"; }
BlockCipher* clone() const { return new Twofish; }
- Twofish() : BlockCipher_Fixed_Block_Size(16, 32, 8),
- SB(1024), RK(40) {}
-
+ Twofish() : SB(1024), RK(40) {}
private:
void key_schedule(const byte[], size_t);
diff --git a/src/block/xtea/xtea.h b/src/block/xtea/xtea.h
index 539725be8..985e9d6d1 100644
--- a/src/block/xtea/xtea.h
+++ b/src/block/xtea/xtea.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* XTEA
*/
-class BOTAN_DLL XTEA : public BlockCipher_Fixed_Block_Size<8>
+class BOTAN_DLL XTEA : public Block_Cipher_Fixed_Params<8, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
@@ -25,7 +25,7 @@ class BOTAN_DLL XTEA : public BlockCipher_Fixed_Block_Size<8>
std::string name() const { return "XTEA"; }
BlockCipher* clone() const { return new XTEA; }
- XTEA() : BlockCipher_Fixed_Block_Size(16), EK(64) {}
+ XTEA() : EK(64) {}
protected:
/**
* @return const reference to the key schedule