Botan 1.10.17

serpent.h
Go to the documentation of this file.
1 /*
2 * Serpent
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_SERPENT_H__
9 #define BOTAN_SERPENT_H__
10
11 #include <botan/block_cipher.h>
12
13 namespace Botan {
14
15 /**
16 * Serpent, an AES finalist
17 */
18 class BOTAN_DLL Serpent : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
19 {
20 public:
21 void encrypt_n(const byte in[], byte out[], size_t blocks) const;
22 void decrypt_n(const byte in[], byte out[], size_t blocks) const;
23
24 void clear() { zeroise(round_key); }
25 std::string name() const { return "Serpent"; }
26 BlockCipher* clone() const { return new Serpent; }
27
28 Serpent() : round_key(132) {}
29 protected:
30 /**
31 * For use by subclasses using SIMD, asm, etc
32 * @return const reference to the key schedule
33 */
34 const SecureVector<u32bit>& get_round_keys() const
35 { return round_key; }
36
37 /**
38 * For use by subclasses that implement the key schedule
39 * @param ks is the new key schedule value to set
40 */
41 void set_round_keys(const u32bit ks[132])
42 {
43 copy_mem(&round_key[0], ks, 132);
44 }
45
46 private:
47 void key_schedule(const byte key[], size_t length);
48 SecureVector<u32bit> round_key;
49 };
50
51 }
52
53 #endif
Botan::Serpent::get_round_keys
const SecureVector< u32bit > & get_round_keys() const
Definition: serpent.h:34
Botan::Serpent::Serpent
Serpent()
Definition: serpent.h:28
Botan::Serpent::name
std::string name() const
Definition: serpent.h:25
Botan::Serpent
Definition: serpent.h:18
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::Serpent::set_round_keys
void set_round_keys(const u32bit ks[132])
Definition: serpent.h:41
Botan::copy_mem
void copy_mem(T *out, const T *in, size_t n)
Definition: mem_ops.h:22
Botan
Definition: algo_base.h:14
Botan::Serpent::clear
void clear()
Definition: serpent.h:24
Botan::SecureVector< u32bit >
Botan::Block_Cipher_Fixed_Params
Definition: block_cipher.h:104
Botan::Serpent::clone
BlockCipher * clone() const
Definition: serpent.h:26
Botan::zeroise
void zeroise(MemoryRegion< T > &vec)
Definition: secmem.h:428
Botan::u32bit
unsigned int u32bit
Definition: types.h:32
Botan::BlockCipher
Definition: block_cipher.h:18