Botan  1.10.9
des.h
Go to the documentation of this file.
1 /*
2 * DES
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_DES_H__
9 #define BOTAN_DES_H__
10 
11 #include <botan/block_cipher.h>
12 
13 namespace Botan {
14 
15 /**
16 * DES
17 */
18 class BOTAN_DLL DES : public Block_Cipher_Fixed_Params<8, 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 "DES"; }
26  BlockCipher* clone() const { return new DES; }
27 
28  DES() : round_key(32) {}
29  private:
30  void key_schedule(const byte[], size_t);
31 
32  SecureVector<u32bit> round_key;
33  };
34 
35 /**
36 * Triple DES
37 */
38 class BOTAN_DLL TripleDES : public Block_Cipher_Fixed_Params<8, 16, 24, 8>
39  {
40  public:
41  void encrypt_n(const byte in[], byte out[], size_t blocks) const;
42  void decrypt_n(const byte in[], byte out[], size_t blocks) const;
43 
44  void clear() { zeroise(round_key); }
45  std::string name() const { return "TripleDES"; }
46  BlockCipher* clone() const { return new TripleDES; }
47 
48  TripleDES() : round_key(96) {}
49  private:
50  void key_schedule(const byte[], size_t);
51 
52  SecureVector<u32bit> round_key;
53  };
54 
55 /*
56 * DES Tables
57 */
58 extern const u32bit DES_SPBOX1[256];
59 extern const u32bit DES_SPBOX2[256];
60 extern const u32bit DES_SPBOX3[256];
61 extern const u32bit DES_SPBOX4[256];
62 extern const u32bit DES_SPBOX5[256];
63 extern const u32bit DES_SPBOX6[256];
64 extern const u32bit DES_SPBOX7[256];
65 extern const u32bit DES_SPBOX8[256];
66 
67 extern const u64bit DES_IPTAB1[256];
68 extern const u64bit DES_IPTAB2[256];
69 extern const u64bit DES_FPTAB1[256];
70 extern const u64bit DES_FPTAB2[256];
71 
72 }
73 
74 #endif
const u32bit DES_SPBOX4[256]
Definition: des_tab.cpp:147
BlockCipher * clone() const
Definition: des.h:46
const u64bit DES_IPTAB1[256]
Definition: des_tab.cpp:372
std::string name() const
Definition: des.h:25
const u32bit DES_SPBOX6[256]
Definition: des_tab.cpp:237
const u32bit DES_SPBOX7[256]
Definition: des_tab.cpp:282
const u32bit DES_SPBOX3[256]
Definition: des_tab.cpp:102
const u32bit DES_SPBOX5[256]
Definition: des_tab.cpp:192
unsigned char byte
Definition: types.h:22
unsigned long long u64bit
Definition: types.h:49
const u32bit DES_SPBOX1[256]
Definition: des_tab.cpp:12
const u32bit DES_SPBOX8[256]
Definition: des_tab.cpp:327
const u64bit DES_IPTAB2[256]
Definition: des_tab.cpp:438
const u64bit DES_FPTAB2[256]
Definition: des_tab.cpp:570
void clear()
Definition: des.h:24
const u64bit DES_FPTAB1[256]
Definition: des_tab.cpp:504
DES()
Definition: des.h:28
Definition: des.h:18
std::string name() const
Definition: des.h:45
BlockCipher * clone() const
Definition: des.h:26
const u32bit DES_SPBOX2[256]
Definition: des_tab.cpp:57
void zeroise(MemoryRegion< T > &vec)
Definition: secmem.h:415
void clear()
Definition: des.h:44
unsigned int u32bit
Definition: types.h:32