diff options
Diffstat (limited to 'src/block/cascade')
-rw-r--r-- | src/block/cascade/cascade.cpp | 98 | ||||
-rw-r--r-- | src/block/cascade/cascade.h | 58 | ||||
-rw-r--r-- | src/block/cascade/info.txt | 9 |
3 files changed, 0 insertions, 165 deletions
diff --git a/src/block/cascade/cascade.cpp b/src/block/cascade/cascade.cpp deleted file mode 100644 index f1b1a8f2c..000000000 --- a/src/block/cascade/cascade.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -* Block Cipher Cascade -* (C) 2010 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/cascade.h> - -namespace Botan { - -void Cascade_Cipher::encrypt_n(const byte in[], byte out[], - size_t blocks) const - { - size_t c1_blocks = blocks * (block_size() / cipher1->block_size()); - size_t c2_blocks = blocks * (block_size() / cipher2->block_size()); - - cipher1->encrypt_n(in, out, c1_blocks); - cipher2->encrypt_n(out, out, c2_blocks); - } - -void Cascade_Cipher::decrypt_n(const byte in[], byte out[], - size_t blocks) const - { - size_t c1_blocks = blocks * (block_size() / cipher1->block_size()); - size_t c2_blocks = blocks * (block_size() / cipher2->block_size()); - - cipher2->decrypt_n(in, out, c2_blocks); - cipher1->decrypt_n(out, out, c1_blocks); - } - -void Cascade_Cipher::key_schedule(const byte key[], size_t) - { - const byte* key2 = key + cipher1->maximum_keylength(); - - cipher1->set_key(key , cipher1->maximum_keylength()); - cipher2->set_key(key2, cipher2->maximum_keylength()); - } - -void Cascade_Cipher::clear() - { - cipher1->clear(); - cipher2->clear(); - } - -std::string Cascade_Cipher::name() const - { - return "Cascade(" + cipher1->name() + "," + cipher2->name() + ")"; - } - -BlockCipher* Cascade_Cipher::clone() const - { - return new Cascade_Cipher(cipher1->clone(), - cipher2->clone()); - } - -namespace { - -size_t euclids_algorithm(size_t a, size_t b) - { - while(b != 0) // gcd - { - size_t t = b; - b = a % b; - a = t; - } - - return a; - } - -size_t block_size_for_cascade(size_t bs, size_t bs2) - { - if(bs == bs2) - return bs; - - size_t gcd = euclids_algorithm(bs, bs2); - - return (bs * bs2) / gcd; - } - -} - -Cascade_Cipher::Cascade_Cipher(BlockCipher* c1, BlockCipher* c2) : - cipher1(c1), cipher2(c2) - { - block = block_size_for_cascade(c1->block_size(), c2->block_size()); - - if(block_size() % c1->block_size() || block_size() % c2->block_size()) - throw Internal_Error("Failure in " + name() + " constructor"); - } - -Cascade_Cipher::~Cascade_Cipher() - { - delete cipher1; - delete cipher2; - } - -} diff --git a/src/block/cascade/cascade.h b/src/block/cascade/cascade.h deleted file mode 100644 index 9b7d44fdf..000000000 --- a/src/block/cascade/cascade.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Block Cipher Cascade -* (C) 2010 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_CASCADE_H__ -#define BOTAN_CASCADE_H__ - -#include <botan/block_cipher.h> - -namespace Botan { - -/** -* Block Cipher Cascade -*/ -class BOTAN_DLL Cascade_Cipher : public BlockCipher - { - public: - void encrypt_n(const byte in[], byte out[], size_t blocks) const; - void decrypt_n(const byte in[], byte out[], size_t blocks) const; - - size_t block_size() const { return block; } - - Key_Length_Specification key_spec() const - { - return Key_Length_Specification(cipher1->maximum_keylength() + - cipher2->maximum_keylength()); - } - - void clear(); - std::string name() const; - BlockCipher* clone() const; - - /** - * Create a cascade of two block ciphers - * @param cipher1 the first cipher - * @param cipher2 the second cipher - */ - Cascade_Cipher(BlockCipher* cipher1, BlockCipher* cipher2); - - Cascade_Cipher(const Cascade_Cipher&) = delete; - Cascade_Cipher& operator=(const Cascade_Cipher&) = delete; - - ~Cascade_Cipher(); - private: - void key_schedule(const byte[], size_t); - - size_t block; - BlockCipher* cipher1; - BlockCipher* cipher2; - }; - - -} - -#endif diff --git a/src/block/cascade/info.txt b/src/block/cascade/info.txt deleted file mode 100644 index 445e49086..000000000 --- a/src/block/cascade/info.txt +++ /dev/null @@ -1,9 +0,0 @@ -define CASCADE 20131128 - -<header:public> -cascade.h -</header:public> - -<source> -cascade.cpp -</source> |