/src/botan/build/include/botan/internal/cascade.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Block Cipher Cascade |
3 | | * (C) 2010 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_CASCADE_H_ |
9 | | #define BOTAN_CASCADE_H_ |
10 | | |
11 | | #include <botan/block_cipher.h> |
12 | | |
13 | | namespace Botan { |
14 | | |
15 | | /** |
16 | | * Block Cipher Cascade |
17 | | */ |
18 | | class Cascade_Cipher final : public BlockCipher |
19 | | { |
20 | | public: |
21 | | void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
22 | | void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
23 | | |
24 | 0 | size_t block_size() const override { return m_block; } |
25 | | |
26 | | Key_Length_Specification key_spec() const override |
27 | 0 | { |
28 | 0 | return Key_Length_Specification(m_cipher1->maximum_keylength() + |
29 | 0 | m_cipher2->maximum_keylength()); |
30 | 0 | } |
31 | | |
32 | | void clear() override; |
33 | | std::string name() const override; |
34 | | BlockCipher* clone() const override; |
35 | | |
36 | | /** |
37 | | * Create a cascade of two block ciphers |
38 | | * @param cipher1 the first cipher |
39 | | * @param cipher2 the second cipher |
40 | | */ |
41 | | Cascade_Cipher(BlockCipher* cipher1, BlockCipher* cipher2); |
42 | | |
43 | | Cascade_Cipher(const Cascade_Cipher&) = delete; |
44 | | Cascade_Cipher& operator=(const Cascade_Cipher&) = delete; |
45 | | private: |
46 | | void key_schedule(const uint8_t[], size_t) override; |
47 | | |
48 | | size_t m_block; |
49 | | std::unique_ptr<BlockCipher> m_cipher1, m_cipher2; |
50 | | }; |
51 | | |
52 | | |
53 | | } |
54 | | |
55 | | #endif |