Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

lion.h
Go to the documentation of this file.
1 /*
2 * Lion
3 * (C) 1999-2007,2014 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_LION_H__
9 #define BOTAN_LION_H__
10
11 #include <botan/block_cipher.h>
12 #include <botan/stream_cipher.h>
13 #include <botan/hash.h>
14
15 namespace Botan {
16
17 /**
18 * Lion is a block cipher construction designed by Ross Anderson and
19 * Eli Biham, described in "Two Practical and Provably Secure Block
20 * Ciphers: BEAR and LION". It has a variable block size and is
21 * designed to encrypt very large blocks (up to a megabyte)
22
23 * http://www.cl.cam.ac.uk/~rja14/Papers/bear-lion.pdf
24 */
25 class BOTAN_DLL Lion final : public BlockCipher
26 {
27 public:
28 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
29 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
30
31 size_t block_size() const override { return m_block_size; }
32
33 Key_Length_Specification key_spec() const override
34 {
35 return Key_Length_Specification(2, 2*m_hash->output_length(), 2);
36 }
37
38 void clear() override;
39 std::string name() const override;
40 BlockCipher* clone() const override;
41
42 /**
43 * @param hash the hash to use internally
44 * @param cipher the stream cipher to use internally
45 * @param block_size the size of the block to use
46 */
47 Lion(HashFunction* hash,
48 StreamCipher* cipher,
49 size_t block_size);
50 private:
51 void key_schedule(const uint8_t[], size_t) override;
52
53 size_t left_size() const { return m_hash->output_length(); }
54 size_t right_size() const { return m_block_size - left_size(); }
55
56 const size_t m_block_size;
57 std::unique_ptr<HashFunction> m_hash;
58 std::unique_ptr<StreamCipher> m_cipher;
59 secure_vector<uint8_t> m_key1, m_key2;
60 };
61
62 }
63
64 #endif
Botan::Lion::key_spec
Key_Length_Specification key_spec() const override
Definition: lion.h:33
Botan::Key_Length_Specification
Definition: key_spec.h:18
Botan::Lion::block_size
size_t block_size() const override
Definition: lion.h:31
Botan::StreamCipher
Definition: stream_cipher.h:19
Botan::Lion
Definition: lion.h:25
Botan
Definition: alg_id.cpp:13
Botan::HashFunction
Definition: hash.h:19
m_hash
std::unique_ptr< HashFunction > m_hash
Definition: tpm.cpp:439
hash
MechanismType hash
Definition: p11_mechanism.cpp:63
Botan::BlockCipher
Definition: block_cipher.h:19