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
13namespace Botan {
14
15/**
16* Serpent, an AES finalist
17*/
18class 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 */
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
void clear()
Definition serpent.h:24
BlockCipher * clone() const
Definition serpent.h:26
const SecureVector< u32bit > & get_round_keys() const
Definition serpent.h:34
void set_round_keys(const u32bit ks[132])
Definition serpent.h:41
void encrypt_n(const byte in[], byte out[], size_t blocks) const
Definition serpent.cpp:249
void decrypt_n(const byte in[], byte out[], size_t blocks) const
Definition serpent.cpp:301
std::string name() const
Definition serpent.h:25
void zeroise(MemoryRegion< T > &vec)
Definition secmem.h:428
void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:22
unsigned int u32bit
Definition types.h:32