Botan  1.11.15
src/lib/block/cascade/cascade.h
Go to the documentation of this file.
00001 /*
00002 * Block Cipher Cascade
00003 * (C) 2010 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_CASCADE_H__
00009 #define BOTAN_CASCADE_H__
00010 
00011 #include <botan/block_cipher.h>
00012 
00013 namespace Botan {
00014 
00015 /**
00016 * Block Cipher Cascade
00017 */
00018 class BOTAN_DLL Cascade_Cipher : public BlockCipher
00019    {
00020    public:
00021       void encrypt_n(const byte in[], byte out[], size_t blocks) const;
00022       void decrypt_n(const byte in[], byte out[], size_t blocks) const;
00023 
00024       size_t block_size() const { return m_block; }
00025 
00026       Key_Length_Specification key_spec() const
00027          {
00028          return Key_Length_Specification(m_cipher1->maximum_keylength() +
00029                                          m_cipher2->maximum_keylength());
00030          }
00031 
00032       void clear();
00033       std::string name() const;
00034       BlockCipher* clone() const;
00035 
00036       static Cascade_Cipher* make(const Spec& spec);
00037 
00038       /**
00039       * Create a cascade of two block ciphers
00040       * @param cipher1 the first cipher
00041       * @param cipher2 the second cipher
00042       */
00043       Cascade_Cipher(BlockCipher* cipher1, BlockCipher* cipher2);
00044 
00045       Cascade_Cipher(const Cascade_Cipher&) = delete;
00046       Cascade_Cipher& operator=(const Cascade_Cipher&) = delete;
00047    private:
00048       void key_schedule(const byte[], size_t);
00049 
00050       size_t m_block;
00051       std::unique_ptr<BlockCipher> m_cipher1, m_cipher2;
00052    };
00053 
00054 
00055 }
00056 
00057 #endif