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.assign(key, key + (length / 2));
76 key2.assign(key + (length / 2), key + length);
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)
124 key1.resize(LEFT_SIZE);
125 key2.resize(LEFT_SIZE);