diff options
author | lloyd <[email protected]> | 2010-10-14 18:04:35 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-14 18:04:35 +0000 |
commit | 0cb6bcfedef6ffa797801acd7cb945feb2d05d50 (patch) | |
tree | a89de84b769036989fd59364dfb2d4fa000c697f /src/block/block_cipher.h | |
parent | a142500346e9bef5c4b0905103eac9a494d6822e (diff) |
In all cases where the block size of the cipher is fixed, the key
parameters are as well. So make them template paramters.
The sole exception was AES, because you could either initialize AES
with a fixed key length, in which case it would only be that specific
key length, or not, in which case it would support any valid AES key
size. This is removed in this checkin; you have to specifically ask for
AES-128, AES-192, or AES-256, depending on which one you want.
This is probably actually a good thing, because every implementation
other than the base one (SSSE3, AES-NI, OpenSSL) did not support
"AES", only the versions with specific fixed key sizes. So forcing
the user to ask for the one they want ensures they get the ones
that are faster and/or safer.
Diffstat (limited to 'src/block/block_cipher.h')
-rw-r--r-- | src/block/block_cipher.h | 16 |
1 files changed, 8 insertions, 8 deletions
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; } }; } |