1
/*************************************************
2
* Serpent Source File *
3
* (C) 1999-2007 The Botan Project *
4
*************************************************/
6
#include <botan/serpent.h>
7
#include <botan/bit_ops.h>
13
void serpent_encrypt(const byte[16], byte[16], const u32bit[132]);
14
void serpent_decrypt(const byte[16], byte[16], const u32bit[132]);
15
void serpent_key_schedule(u32bit[140]);
19
/*************************************************
20
* Serpent Encryption *
21
*************************************************/
22
void Serpent::enc(const byte in[], byte out[]) const
24
serpent_encrypt(in, out, round_key);
27
/*************************************************
28
* Serpent Decryption *
29
*************************************************/
30
void Serpent::dec(const byte in[], byte out[]) const
32
serpent_decrypt(in, out, round_key);
35
/*************************************************
36
* Serpent Key Schedule *
37
*************************************************/
38
void Serpent::key(const byte key[], u32bit length)
40
SecureBuffer<u32bit, 140> W;
41
for(u32bit j = 0; j != length / 4; ++j)
42
W[j] = make_u32bit(key[4*j+3], key[4*j+2], key[4*j+1], key[4*j]);
43
W[length / 4] |= u32bit(1) << ((length%4)*8);
45
serpent_key_schedule(W);
46
round_key.copy(W + 8, 132);