Botan  1.10.9
cast128.h
Go to the documentation of this file.
1 /*
2 * CAST-128
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_CAST128_H__
9 #define BOTAN_CAST128_H__
10 
11 #include <botan/block_cipher.h>
12 
13 namespace Botan {
14 
15 /**
16 * CAST-128
17 */
18 class BOTAN_DLL CAST_128 : public Block_Cipher_Fixed_Params<8, 11, 16>
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(MK); zeroise(RK); }
25  std::string name() const { return "CAST-128"; }
26  BlockCipher* clone() const { return new CAST_128; }
27 
28  CAST_128() : MK(16), RK(16) {}
29  private:
30  void key_schedule(const byte[], size_t);
31 
32  static void cast_ks(MemoryRegion<u32bit>& ks,
33  MemoryRegion<u32bit>& user_key);
34 
35  static const u32bit S5[256];
36  static const u32bit S6[256];
37  static const u32bit S7[256];
38  static const u32bit S8[256];
39 
40  SecureVector<u32bit> MK, RK;
41  };
42 
43 extern const u32bit CAST_SBOX1[256];
44 extern const u32bit CAST_SBOX2[256];
45 extern const u32bit CAST_SBOX3[256];
46 extern const u32bit CAST_SBOX4[256];
47 
48 }
49 
50 #endif
void clear()
Definition: cast128.h:24
const u32bit CAST_SBOX2[256]
Definition: cast256.h:40
const u32bit CAST_SBOX1[256]
Definition: cast256.h:39
std::string name() const
Definition: cast128.h:25
unsigned char byte
Definition: types.h:22
const u32bit CAST_SBOX4[256]
Definition: cast256.h:42
BlockCipher * clone() const
Definition: cast128.h:26
void zeroise(MemoryRegion< T > &vec)
Definition: secmem.h:415
unsigned int u32bit
Definition: types.h:32
const u32bit CAST_SBOX3[256]
Definition: cast256.h:41