Security Scol plugin
des.h
Go to the documentation of this file.
1// des.h - originally written and placed in the public domain by Wei Dai
2
5
6#ifndef CRYPTOPP_DES_H
7#define CRYPTOPP_DES_H
8
9#include "seckey.h"
10#include "secblock.h"
11
12NAMESPACE_BEGIN(CryptoPP)
13
14
16class CRYPTOPP_DLL RawDES
17{
18public:
19 void RawSetKey(CipherDir direction, const byte *userKey);
20 void RawProcessBlock(word32 &l, word32 &r) const;
21
22protected:
23 static const word32 Spbox[8][64];
24
26};
27
30struct DES_Info : public FixedBlockSize<8>, public FixedKeyLength<8>
31{
32 // disable DES in DLL version by not exporting this function
33 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "DES";}
34};
35
43{
45 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_Info>, public RawDES
46 {
47 public:
48 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
49 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
50 };
51
52public:
54 static bool CheckKeyParityBits(const byte *key);
56 static void CorrectKeyParityBits(byte *key);
57
60};
61
64struct DES_EDE2_Info : public FixedBlockSize<8>, public FixedKeyLength<16>
65{
66 CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "DES-EDE2";}
67};
68
73{
75 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE2_Info>
76 {
77 public:
78 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
79 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
80
81 protected:
82 RawDES m_des1, m_des2;
83 };
84
85public:
88};
89
92struct DES_EDE3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
93{
94 CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "DES-EDE3";}
95};
96
101{
103 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE3_Info>
104 {
105 public:
106 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
107 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
108
109 protected:
110 RawDES m_des1, m_des2, m_des3;
111 };
112
113public:
116};
117
120struct DES_XEX3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
121{
122 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "DES-XEX3";}
123};
124
129{
131 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_XEX3_Info>
132 {
133 public:
134 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
135 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
136
137 protected:
139 // VS2005 workaround: calling modules compiled with /clr gets unresolved external symbol DES::Base::ProcessAndXorBlock
140 // if we use DES::Encryption here directly without value_ptr.
142 };
143
144public:
147};
148
151
154
157
160
161NAMESPACE_END
162
163#endif
Provides class member functions to key a block cipher.
Definition seckey.h:318
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition seckey.h:306
2-key TripleDES block cipher
Definition des.h:73
3-key TripleDES block cipher
Definition des.h:101
DESX block cipher.
Definition des.h:129
DES block cipher.
Definition des.h:43
static bool CheckKeyParityBits(const byte *key)
check DES key parity bits
Definition des.cpp:420
static void CorrectKeyParityBits(byte *key)
correct DES key parity bits
Definition des.cpp:428
Inherited by algorithms with fixed block size.
Definition seckey.h:41
Inherited by keyed algorithms with fixed key length.
Definition seckey.h:125
Fixed size stack-based SecBlock.
Definition secblock.h:1246
Interface for retrieving values given their names.
Definition cryptlib.h:322
DES block cipher base class.
Definition des.h:17
Value pointer.
Definition smartptr.h:77
unsigned int word32
32-bit unsigned datatype
Definition config_int.h:62
CipherDir
Specifies a direction for a cipher to operate.
Definition cryptlib.h:123
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition seckey.h:399
2-key TripleDES block cipher information
Definition des.h:65
3-key TripleDES block cipher information
Definition des.h:93
DES block cipher information.
Definition des.h:31
DESX block cipher information.
Definition des.h:121