8 #include <botan/lion.h>
9 #include <botan/internal/xor_buf.h>
10 #include <botan/parsing.h>
20 byte* buffer = &buffer_vec[0];
22 for(
size_t i = 0; i != blocks; ++i)
24 xor_buf(buffer, in, &key1[0], LEFT_SIZE);
25 cipher->
set_key(buffer, LEFT_SIZE);
26 cipher->
cipher(in + LEFT_SIZE, out + LEFT_SIZE, RIGHT_SIZE);
28 hash->
update(out + LEFT_SIZE, RIGHT_SIZE);
30 xor_buf(out, in, buffer, LEFT_SIZE);
32 xor_buf(buffer, out, &key2[0], LEFT_SIZE);
33 cipher->
set_key(buffer, LEFT_SIZE);
34 cipher->
cipher1(out + LEFT_SIZE, RIGHT_SIZE);
47 byte* buffer = &buffer_vec[0];
49 for(
size_t i = 0; i != blocks; ++i)
51 xor_buf(buffer, in, &key2[0], LEFT_SIZE);
52 cipher->
set_key(buffer, LEFT_SIZE);
53 cipher->
cipher(in + LEFT_SIZE, out + LEFT_SIZE, RIGHT_SIZE);
55 hash->
update(out + LEFT_SIZE, RIGHT_SIZE);
57 xor_buf(out, in, buffer, LEFT_SIZE);
59 xor_buf(buffer, out, &key1[0], LEFT_SIZE);
60 cipher->
set_key(buffer, LEFT_SIZE);
61 cipher->
cipher1(out + LEFT_SIZE, RIGHT_SIZE);
71 void Lion::key_schedule(
const byte key[],
size_t length)
75 key1.
copy(key, length / 2);
76 key2.
copy(key + length / 2, length / 2);
84 return "Lion(" + hash->
name() +
"," +
85 cipher->
name() +
"," +
112 BLOCK_SIZE(
std::max<size_t>(2*hash_in->output_length() + 1, block_len)),
113 LEFT_SIZE(hash_in->output_length()),
114 RIGHT_SIZE(BLOCK_SIZE - LEFT_SIZE),
118 if(2*LEFT_SIZE + 1 > BLOCK_SIZE)
BlockCipher * clone() const
void cipher1(byte buf[], size_t len)
std::invalid_argument Invalid_Argument
virtual HashFunction * clone() const =0
void copy(const T in[], size_t n)
bool valid_keylength(size_t length) const
void encrypt_n(const byte in[], byte out[], size_t blocks) const
void set_key(const SymmetricKey &key)
void update(const byte in[], size_t length)
virtual void cipher(const byte in[], byte out[], size_t len)=0
virtual std::string name() const =0
void decrypt_n(const byte in[], byte out[], size_t blocks) const
virtual StreamCipher * clone() const =0
std::string to_string(u64bit n, size_t min_len)
Lion(HashFunction *hash, StreamCipher *cipher, size_t block_size)
void xor_buf(byte out[], const byte in[], size_t length)
void zeroise(MemoryRegion< T > &vec)