Botan 2.13.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 BOTAN_FUTURE_INTERNAL_HEADER(lion.h)
16
17 namespace Botan {
18
19 /**
20 * Lion is a block cipher construction designed by Ross Anderson and
21 * Eli Biham, described in "Two Practical and Provably Secure Block
22 * Ciphers: BEAR and LION". It has a variable block size and is
23 * designed to encrypt very large blocks (up to a megabyte)
24
25 * https://www.cl.cam.ac.uk/~rja14/Papers/bear-lion.pdf
26 */
27 class BOTAN_PUBLIC_API(2,0) Lion final : public BlockCipher
28 {
29 public:
30 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
31 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
32
33 size_t block_size() const override { return m_block_size; }
34
35 Key_Length_Specification key_spec() const override
36 {
37 return Key_Length_Specification(2, 2*m_hash->output_length(), 2);
38 }
39
40 void clear() override;
41 std::string name() const override;
42 BlockCipher* clone() const override;
43
44 /**
45 * @param hash the hash to use internally
46 * @param cipher the stream cipher to use internally
47 * @param block_size the size of the block to use
48 */
49 Lion(HashFunction* hash,
50 StreamCipher* cipher,
51 size_t block_size);
52 private:
53 void key_schedule(const uint8_t[], size_t) override;
54
55 size_t left_size() const { return m_hash->output_length(); }
56 size_t right_size() const { return m_block_size - left_size(); }
57
58 const size_t m_block_size;
59 std::unique_ptr<HashFunction> m_hash;
60 std::unique_ptr<StreamCipher> m_cipher;
61 secure_vector<uint8_t> m_key1, m_key2;
62 };
63
64 }
65
66 #endif
Botan::Lion::key_spec
Key_Length_Specification key_spec() const override
Definition: lion.h:35
m_cipher
CCCryptorRef m_cipher
Definition: commoncrypto_mode.cpp:50
Botan::BlockCipher::decrypt_n
virtual void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const =0
Botan::Key_Length_Specification
Definition: key_spec.h:18
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan::BlockCipher::clone
virtual BlockCipher * clone() const =0
Botan::Lion::block_size
size_t block_size() const override
Definition: lion.h:33
Botan::SymmetricAlgorithm::name
virtual std::string name() const =0
Botan::StreamCipher
Definition: stream_cipher.h:21
Botan::Lion
Definition: lion.h:27
Botan::SymmetricAlgorithm::clear
virtual void clear()=0
Botan
Definition: alg_id.cpp:13
Botan::BlockCipher::encrypt_n
virtual void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const =0
Botan::HashFunction
Definition: hash.h:20
m_block_size
size_t m_block_size
Definition: openssl_mode.cpp:47
m_hash
std::unique_ptr< HashFunction > m_hash
Definition: tpm.cpp:446
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139
hash
MechanismType hash
Definition: p11_mechanism.cpp:64
Botan::BlockCipher
Definition: block_cipher.h:21