Botan  2.7.0
Crypto and TLS for C++11
des.h
Go to the documentation of this file.
1 /*
2 * DES
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
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_PUBLIC_API(2,0) DES final : public Block_Cipher_Fixed_Params<8, 8>
19  {
20  public:
21  void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
22  void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
23 
24  void clear() override;
25  std::string name() const override { return "DES"; }
26  BlockCipher* clone() const override { return new DES; }
27  private:
28  void key_schedule(const uint8_t[], size_t) override;
29 
30  secure_vector<uint32_t> m_round_key;
31  };
32 
33 /**
34 * Triple DES
35 */
36 class BOTAN_PUBLIC_API(2,0) TripleDES final : public Block_Cipher_Fixed_Params<8, 16, 24, 8>
37  {
38  public:
39  void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
40  void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
41 
42  void clear() override;
43  std::string name() const override { return "TripleDES"; }
44  BlockCipher* clone() const override { return new TripleDES; }
45  private:
46  void key_schedule(const uint8_t[], size_t) override;
47 
48  secure_vector<uint32_t> m_round_key;
49  };
50 
51 /*
52 * DES Tables
53 */
54 extern const uint32_t DES_SPBOX1[256];
55 extern const uint32_t DES_SPBOX2[256];
56 extern const uint32_t DES_SPBOX3[256];
57 extern const uint32_t DES_SPBOX4[256];
58 extern const uint32_t DES_SPBOX5[256];
59 extern const uint32_t DES_SPBOX6[256];
60 extern const uint32_t DES_SPBOX7[256];
61 extern const uint32_t DES_SPBOX8[256];
62 
63 extern const uint64_t DES_IPTAB1[256];
64 extern const uint64_t DES_IPTAB2[256];
65 extern const uint64_t DES_FPTAB1[256];
66 extern const uint64_t DES_FPTAB2[256];
67 
68 }
69 
70 #endif
std::string name() const override
Definition: des.h:25
const uint64_t DES_IPTAB2[256]
Definition: des_tab.cpp:438
const uint32_t DES_SPBOX6[256]
Definition: des_tab.cpp:237
const uint32_t DES_SPBOX7[256]
Definition: des_tab.cpp:282
BlockCipher * clone() const override
Definition: des.h:26
std::string name() const override
Definition: des.h:43
const uint64_t DES_IPTAB1[256]
Definition: des_tab.cpp:372
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
const uint32_t DES_SPBOX4[256]
Definition: des_tab.cpp:147
const uint32_t DES_SPBOX3[256]
Definition: des_tab.cpp:102
const uint32_t DES_SPBOX8[256]
Definition: des_tab.cpp:327
const uint32_t DES_SPBOX1[256]
Definition: des_tab.cpp:12
Definition: alg_id.cpp:13
BlockCipher * clone() const override
Definition: des.h:44
const uint32_t DES_SPBOX5[256]
Definition: des_tab.cpp:192
const uint32_t DES_SPBOX2[256]
Definition: des_tab.cpp:57
const uint64_t DES_FPTAB1[256]
Definition: des_tab.cpp:504
Definition: des.h:18
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
const uint64_t DES_FPTAB2[256]
Definition: des_tab.cpp:570