Botan 3.5.0
Crypto and TLS for C&
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/hash.h>
13#include <botan/stream_cipher.h>
14
15namespace 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* https://www.cl.cam.ac.uk/~rja14/Papers/bear-lion.pdf
24*/
25class Lion final : public BlockCipher {
26 public:
27 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
28 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
29
30 size_t block_size() const override { return m_block_size; }
31
33 return Key_Length_Specification(2, 2 * m_hash->output_length(), 2);
34 }
35
36 void clear() override;
37 std::string name() const override;
38 std::unique_ptr<BlockCipher> new_object() const override;
39 bool has_keying_material() const override;
40
41 /**
42 * @param hash the hash to use internally
43 * @param cipher the stream cipher to use internally
44 * @param block_size the size of the block to use
45 */
46 Lion(std::unique_ptr<HashFunction> hash, std::unique_ptr<StreamCipher> cipher, size_t block_size);
47
48 private:
49 void key_schedule(std::span<const uint8_t> key) override;
50
51 size_t left_size() const { return m_hash->output_length(); }
52
53 size_t right_size() const { return m_block_size - left_size(); }
54
55 const size_t m_block_size;
56 std::unique_ptr<HashFunction> m_hash;
57 std::unique_ptr<StreamCipher> m_cipher;
58 secure_vector<uint8_t> m_key1, m_key2;
59};
60
61} // namespace Botan
62
63#endif
std::unique_ptr< BlockCipher > new_object() const override
Definition lion.cpp:102
bool has_keying_material() const override
Definition lion.cpp:75
void clear() override
Definition lion.cpp:109
size_t block_size() const override
Definition lion.h:30
Lion(std::unique_ptr< HashFunction > hash, std::unique_ptr< StreamCipher > cipher, size_t block_size)
Definition lion.cpp:119
std::string name() const override
Definition lion.cpp:98
void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
Definition lion.cpp:48
Key_Length_Specification key_spec() const override
Definition lion.h:32
void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
Definition lion.cpp:18
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61