Botan 1.10.17
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
13namespace Botan {
14
15/**
16* DES
17*/
18class 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*/
38class 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*/
58extern const u32bit DES_SPBOX1[256];
59extern const u32bit DES_SPBOX2[256];
60extern const u32bit DES_SPBOX3[256];
61extern const u32bit DES_SPBOX4[256];
62extern const u32bit DES_SPBOX5[256];
63extern const u32bit DES_SPBOX6[256];
64extern const u32bit DES_SPBOX7[256];
65extern const u32bit DES_SPBOX8[256];
66
67extern const u64bit DES_IPTAB1[256];
68extern const u64bit DES_IPTAB2[256];
69extern const u64bit DES_FPTAB1[256];
70extern const u64bit DES_FPTAB2[256];
71
72}
73
74#endif
void encrypt_n(const byte in[], byte out[], size_t blocks) const
Definition des.cpp:146
void clear()
Definition des.h:24
BlockCipher * clone() const
Definition des.h:26
void decrypt_n(const byte in[], byte out[], size_t blocks) const
Definition des.cpp:176
std::string name() const
Definition des.h:25
DES()
Definition des.h:28
BlockCipher * clone() const
Definition des.h:46
void encrypt_n(const byte in[], byte out[], size_t blocks) const
Definition des.cpp:215
std::string name() const
Definition des.h:45
void decrypt_n(const byte in[], byte out[], size_t blocks) const
Definition des.cpp:248
void clear()
Definition des.h:44
void zeroise(MemoryRegion< T > &vec)
Definition secmem.h:428
const u32bit DES_SPBOX4[256]
Definition des_tab.cpp:147
const u64bit DES_IPTAB1[256]
Definition des_tab.cpp:372
const u32bit DES_SPBOX5[256]
Definition des_tab.cpp:192
const u64bit DES_FPTAB2[256]
Definition des_tab.cpp:570
unsigned long long u64bit
Definition types.h:49
const u32bit DES_SPBOX1[256]
Definition des_tab.cpp:12
const u64bit DES_IPTAB2[256]
Definition des_tab.cpp:438
const u32bit DES_SPBOX2[256]
Definition des_tab.cpp:57
const u32bit DES_SPBOX8[256]
Definition des_tab.cpp:327
unsigned int u32bit
Definition types.h:32
const u32bit DES_SPBOX3[256]
Definition des_tab.cpp:102
const u32bit DES_SPBOX7[256]
Definition des_tab.cpp:282
const u64bit DES_FPTAB1[256]
Definition des_tab.cpp:504
const u32bit DES_SPBOX6[256]
Definition des_tab.cpp:237