Crypto++ 8.7
Free C++ class library of cryptographic schemes
seckey.h
Go to the documentation of this file.
1// seckey.h - originally written and placed in the public domain by Wei Dai
2
3/// \file seckey.h
4/// \brief Classes and functions for implementing secret key algorithms.
5
6#ifndef CRYPTOPP_SECKEY_H
7#define CRYPTOPP_SECKEY_H
8
9#include "config.h"
10#include "cryptlib.h"
11#include "misc.h"
12#include "simple.h"
13#include "stdcpp.h"
14
15#if CRYPTOPP_MSC_VERSION
16# pragma warning(push)
17# pragma warning(disable: 4189 4296)
18#endif
19
20// Issue 340
21#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
22# pragma GCC diagnostic push
23# pragma GCC diagnostic ignored "-Wconversion"
24# pragma GCC diagnostic ignored "-Wsign-conversion"
25#endif
26
27NAMESPACE_BEGIN(CryptoPP)
28
29/// \brief Inverts the cipher's direction
30/// \param dir the cipher's direction
31/// \return DECRYPTION if \ref CipherDir "dir" is ENCRYPTION, DECRYPTION otherwise
33{
34 return (dir == ENCRYPTION) ? DECRYPTION : ENCRYPTION;
35}
36
37/// \brief Inherited by algorithms with fixed block size
38/// \tparam N the blocksize of the algorithm
39template <unsigned int N>
41{
42public:
43 /// \brief The block size of the algorithm provided as a constant.
44 CRYPTOPP_CONSTANT(BLOCKSIZE = N);
45};
46
47// ************** rounds ***************
48
49/// \brief Inherited by algorithms with fixed number of rounds
50/// \tparam R the number of rounds used by the algorithm
51template <unsigned int R>
53{
54public:
55 /// \brief The number of rounds for the algorithm provided as a constant.
56 CRYPTOPP_CONSTANT(ROUNDS = R);
57};
58
59/// \brief Inherited by algorithms with variable number of rounds
60/// \tparam D Default number of rounds
61/// \tparam N Minimum number of rounds
62/// \tparam M Maximum number of rounds
63template <unsigned int D, unsigned int N=1, unsigned int M=INT_MAX> // use INT_MAX here because enums are treated as signed ints
65{
66public:
67 /// \brief The default number of rounds for the algorithm provided as a constant.
68 CRYPTOPP_CONSTANT(DEFAULT_ROUNDS = D);
69 /// \brief The minimum number of rounds for the algorithm provided as a constant.
70 CRYPTOPP_CONSTANT(MIN_ROUNDS = N);
71 /// \brief The maximum number of rounds for the algorithm provided as a constant.
72 CRYPTOPP_CONSTANT(MAX_ROUNDS = M);
73 /// \brief The default number of rounds for the algorithm based on key length
74 /// provided by a static function.
75 /// \param keylength the size of the key, in bytes
76 /// \details keylength is unused in the default implementation.
77 CRYPTOPP_STATIC_CONSTEXPR unsigned int StaticGetDefaultRounds(size_t keylength)
78 {
79 return CRYPTOPP_UNUSED(keylength), static_cast<unsigned int>(DEFAULT_ROUNDS);
80 }
81
82protected:
83 /// \brief Validates the number of rounds for an algorithm.
84 /// \param rounds the candidate number of rounds
85 /// \param alg an Algorithm object used if the number of rounds are invalid
86 /// \throw InvalidRounds if the number of rounds are invalid
87 /// \details ThrowIfInvalidRounds() validates the number of rounds and throws if invalid.
88 inline void ThrowIfInvalidRounds(int rounds, const Algorithm *alg)
89 {
90 if (M == INT_MAX) // Coverity and result_independent_of_operands
91 {
92 if (rounds < MIN_ROUNDS)
93 throw InvalidRounds(alg ? alg->AlgorithmName() : std::string("VariableRounds"), rounds);
94 }
95 else
96 {
97 if (rounds < MIN_ROUNDS || rounds > MAX_ROUNDS)
98 throw InvalidRounds(alg ? alg->AlgorithmName() : std::string("VariableRounds"), rounds);
99 }
100 }
101
102 /// \brief Validates the number of rounds for an algorithm
103 /// \param param the candidate number of rounds
104 /// \param alg an Algorithm object used if the number of rounds are invalid
105 /// \return the number of rounds for the algorithm
106 /// \throw InvalidRounds if the number of rounds are invalid
107 /// \details GetRoundsAndThrowIfInvalid() validates the number of rounds and throws if invalid.
108 inline unsigned int GetRoundsAndThrowIfInvalid(const NameValuePairs &param, const Algorithm *alg)
109 {
110 int rounds = param.GetIntValueWithDefault("Rounds", DEFAULT_ROUNDS);
111 ThrowIfInvalidRounds(rounds, alg);
112 return static_cast<unsigned int>(rounds);
113 }
114};
115
116// ************** key length ***************
117
118/// \brief Inherited by keyed algorithms with fixed key length
119/// \tparam N Default key length, in bytes
120/// \tparam IV_REQ the \ref SimpleKeyingInterface::IV_Requirement "IV requirements"
121/// \tparam IV_L default IV length, in bytes
122/// \sa SimpleKeyingInterface
123template <unsigned int N, unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, unsigned int IV_L = 0>
125{
126public:
127 /// \brief The default key length used by the algorithm provided as a constant
128 /// \details KEYLENGTH is provided in bytes, not bits
129 CRYPTOPP_CONSTANT(KEYLENGTH=N);
130 /// \brief The minimum key length used by the algorithm provided as a constant
131 /// \details MIN_KEYLENGTH is provided in bytes, not bits
132 CRYPTOPP_CONSTANT(MIN_KEYLENGTH=N);
133 /// \brief The maximum key length used by the algorithm provided as a constant
134 /// \details MAX_KEYLENGTH is provided in bytes, not bits
135 CRYPTOPP_CONSTANT(MAX_KEYLENGTH=N);
136 /// \brief The default key length used by the algorithm provided as a constant
137 /// \details DEFAULT_KEYLENGTH is provided in bytes, not bits
138 CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=N);
139 /// \brief The default IV requirements for the algorithm provided as a constant
140 /// \details The default value is NOT_RESYNCHRONIZABLE. See IV_Requirement
141 /// in cryptlib.h for allowed values.
142 CRYPTOPP_CONSTANT(IV_REQUIREMENT = IV_REQ);
143 /// \brief The default IV length used by the algorithm provided as a constant
144 /// \details IV_LENGTH is provided in bytes, not bits. The default implementation uses 0.
145 CRYPTOPP_CONSTANT(IV_LENGTH = IV_L);
146 /// \brief The default key length for the algorithm provided by a static function.
147 /// \param keylength the size of the key, in bytes
148 /// \details The default implementation returns KEYLENGTH. keylength is unused
149 /// in the default implementation.
150 CRYPTOPP_STATIC_CONSTEXPR size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
151 {
152 return CRYPTOPP_UNUSED(keylength), static_cast<size_t>(KEYLENGTH);
153 }
154};
155
156/// \brief Inherited by keyed algorithms with variable key length
157/// \tparam D Default key length, in bytes
158/// \tparam N Minimum key length, in bytes
159/// \tparam M Maximum key length, in bytes
160/// \tparam Q Default key length multiple, in bytes. The default multiple is 1.
161/// \tparam IV_REQ the \ref SimpleKeyingInterface::IV_Requirement "IV requirements"
162/// \tparam IV_L default IV length, in bytes. The default length is 0.
163/// \sa SimpleKeyingInterface
164template <unsigned int D, unsigned int N, unsigned int M, unsigned int Q = 1, unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, unsigned int IV_L = 0>
166{
167 // Make these private to avoid Doxygen documenting them in all derived classes
169 CRYPTOPP_COMPILE_ASSERT(N % Q == 0);
170 CRYPTOPP_COMPILE_ASSERT(M % Q == 0);
174
175public:
176 /// \brief The minimum key length used by the algorithm provided as a constant
177 /// \details MIN_KEYLENGTH is provided in bytes, not bits
178 CRYPTOPP_CONSTANT(MIN_KEYLENGTH=N);
179 /// \brief The maximum key length used by the algorithm provided as a constant
180 /// \details MAX_KEYLENGTH is provided in bytes, not bits
181 CRYPTOPP_CONSTANT(MAX_KEYLENGTH=M);
182 /// \brief The default key length used by the algorithm provided as a constant
183 /// \details DEFAULT_KEYLENGTH is provided in bytes, not bits
184 CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=D);
185 /// \brief The key length multiple used by the algorithm provided as a constant
186 /// \details MAX_KEYLENGTH is provided in bytes, not bits
187 CRYPTOPP_CONSTANT(KEYLENGTH_MULTIPLE=Q);
188 /// \brief The default IV requirements for the algorithm provided as a constant
189 /// \details The default value is NOT_RESYNCHRONIZABLE. See IV_Requirement
190 /// in cryptlib.h for allowed values.
191 CRYPTOPP_CONSTANT(IV_REQUIREMENT=IV_REQ);
192 /// \brief The default initialization vector length for the algorithm provided as a constant
193 /// \details IV_LENGTH is provided in bytes, not bits. The default implementation uses 0.
194 CRYPTOPP_CONSTANT(IV_LENGTH=IV_L);
195 /// \brief Provides a valid key length for the algorithm provided by a static function.
196 /// \param keylength the size of the key, in bytes
197 /// \details If keylength is less than MIN_KEYLENGTH, then the function returns
198 /// MIN_KEYLENGTH. If keylength is greater than MAX_KEYLENGTH, then the function
199 /// returns MAX_KEYLENGTH. If keylength is a multiple of KEYLENGTH_MULTIPLE,
200 /// then keylength is returned. Otherwise, the function returns keylength rounded
201 /// \a down to the next smaller multiple of KEYLENGTH_MULTIPLE.
202 /// \details keylength is provided in bytes, not bits.
203 CRYPTOPP_STATIC_CONSTEXPR size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
204 {
205 return (keylength <= N) ? N :
206 (keylength >= M) ? M :
207 (keylength+Q-1) - (keylength+Q-1)%Q;
208 }
209};
210
211/// \brief Provides key lengths based on another class's key length
212/// \tparam T another FixedKeyLength or VariableKeyLength class
213/// \tparam IV_REQ the \ref SimpleKeyingInterface::IV_Requirement "IV requirements"
214/// \tparam IV_L default IV length, in bytes
215/// \sa SimpleKeyingInterface
216template <class T, unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, unsigned int IV_L = 0>
218{
219public:
220 /// \brief The minimum key length used by the algorithm provided as a constant
221 /// \details MIN_KEYLENGTH is provided in bytes, not bits
222 CRYPTOPP_CONSTANT(MIN_KEYLENGTH=T::MIN_KEYLENGTH);
223 /// \brief The maximum key length used by the algorithm provided as a constant
224 /// \details MIN_KEYLENGTH is provided in bytes, not bits
225 CRYPTOPP_CONSTANT(MAX_KEYLENGTH=T::MAX_KEYLENGTH);
226 /// \brief The default key length used by the algorithm provided as a constant
227 /// \details MIN_KEYLENGTH is provided in bytes, not bits
228 CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=T::DEFAULT_KEYLENGTH);
229 /// \brief The default IV requirements for the algorithm provided as a constant
230 /// \details The default value is NOT_RESYNCHRONIZABLE. See IV_Requirement
231 /// in cryptlib.h for allowed values.
232 CRYPTOPP_CONSTANT(IV_REQUIREMENT=IV_REQ);
233 /// \brief The default initialization vector length for the algorithm provided as a constant
234 /// \details IV_LENGTH is provided in bytes, not bits. The default implementation uses 0.
235 CRYPTOPP_CONSTANT(IV_LENGTH=IV_L);
236 /// \brief Provides a valid key length for the algorithm provided by a static function.
237 /// \param keylength the size of the key, in bytes
238 /// \details If keylength is less than MIN_KEYLENGTH, then the function returns
239 /// MIN_KEYLENGTH. If keylength is greater than MAX_KEYLENGTH, then the function
240 /// returns MAX_KEYLENGTH. If keylength is a multiple of KEYLENGTH_MULTIPLE,
241 /// then keylength is returned. Otherwise, the function returns keylength rounded
242 /// \a down to the next smaller multiple of KEYLENGTH_MULTIPLE.
243 /// \details keylength is provided in bytes, not bits.
244 CRYPTOPP_STATIC_CONSTEXPR size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
245 {return T::StaticGetValidKeyLength(keylength);}
246};
247
248// ************** implementation helper for SimpleKeyingInterface ***************
249
250/// \brief Provides a base implementation of SimpleKeyingInterface
251/// \tparam BASE a SimpleKeyingInterface derived class
252/// \tparam INFO a SimpleKeyingInterface derived class
253/// \details SimpleKeyingInterfaceImpl() provides a default implementation for ciphers providing a keying interface.
254/// Functions are virtual and not eligible for C++11 <tt>constexpr</tt>-ness.
255/// \sa Algorithm(), SimpleKeyingInterface()
256template <class BASE, class INFO = BASE>
257class CRYPTOPP_NO_VTABLE SimpleKeyingInterfaceImpl : public BASE
258{
259public:
260 /// \brief The minimum key length used by the algorithm
261 /// \return minimum key length used by the algorithm, in bytes
262 size_t MinKeyLength() const
263 {return INFO::MIN_KEYLENGTH;}
264
265 /// \brief The maximum key length used by the algorithm
266 /// \return maximum key length used by the algorithm, in bytes
267 size_t MaxKeyLength() const
268 {return static_cast<size_t>(INFO::MAX_KEYLENGTH);}
269
270 /// \brief The default key length used by the algorithm
271 /// \return default key length used by the algorithm, in bytes
272 size_t DefaultKeyLength() const
273 {return INFO::DEFAULT_KEYLENGTH;}
274
275 /// \brief Provides a valid key length for the algorithm
276 /// \param keylength the size of the key, in bytes
277 /// \return the valid key length, in bytes
278 /// \details keylength is provided in bytes, not bits. If keylength is less than MIN_KEYLENGTH,
279 /// then the function returns MIN_KEYLENGTH. If keylength is greater than MAX_KEYLENGTH,
280 /// then the function returns MAX_KEYLENGTH. if If keylength is a multiple of KEYLENGTH_MULTIPLE,
281 /// then keylength is returned. Otherwise, the function returns a \a lower multiple of
282 /// KEYLENGTH_MULTIPLE.
283 size_t GetValidKeyLength(size_t keylength) const {return INFO::StaticGetValidKeyLength(keylength);}
284
285 /// \brief The default IV requirements for the algorithm
286 /// \details The default value is NOT_RESYNCHRONIZABLE. See IV_Requirement
287 /// in cryptlib.h for allowed values.
289 {return static_cast<SimpleKeyingInterface::IV_Requirement>(INFO::IV_REQUIREMENT);}
290
291 /// \brief The initialization vector length for the algorithm
292 /// \details IVSize is provided in bytes, not bits. The default implementation uses
293 /// IV_LENGTH, which is 0.
294 unsigned int IVSize() const
295 {return INFO::IV_LENGTH;}
296};
297
298/// \brief Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers
299/// \tparam INFO a SimpleKeyingInterface derived class
300/// \tparam BASE a SimpleKeyingInterface derived class
301/// \details BlockCipherImpl() provides a default implementation for block ciphers using AlgorithmImpl()
302/// and SimpleKeyingInterfaceImpl(). Functions are virtual and not eligible for C++11 <tt>constexpr</tt>-ness.
303/// \sa Algorithm(), SimpleKeyingInterface(), AlgorithmImpl(), SimpleKeyingInterfaceImpl()
304template <class INFO, class BASE = BlockCipher>
305class CRYPTOPP_NO_VTABLE BlockCipherImpl : public AlgorithmImpl<SimpleKeyingInterfaceImpl<TwoBases<BASE, INFO> > >
306{
307public:
308 /// Provides the block size of the algorithm
309 /// \return the block size of the algorithm, in bytes
310 unsigned int BlockSize() const {return this->BLOCKSIZE;}
311};
312
313/// \brief Provides class member functions to key a block cipher
314/// \tparam DIR a CipherDir
315/// \tparam BASE a BlockCipherImpl derived class
316template <CipherDir DIR, class BASE>
317class BlockCipherFinal : public ClonableImpl<BlockCipherFinal<DIR, BASE>, BASE>
318{
319public:
320 /// \brief Construct a default BlockCipherFinal
321 /// \details The cipher is not keyed.
323
324 /// \brief Construct a BlockCipherFinal
325 /// \param key a byte array used to key the cipher
326 /// \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls
327 /// SimpleKeyingInterface::SetKey.
328 BlockCipherFinal(const byte *key)
329 {this->SetKey(key, this->DEFAULT_KEYLENGTH);}
330
331 /// \brief Construct a BlockCipherFinal
332 /// \param key a byte array used to key the cipher
333 /// \param length the length of the byte array
334 /// \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls
335 /// SimpleKeyingInterface::SetKey.
336 BlockCipherFinal(const byte *key, size_t length)
337 {this->SetKey(key, length);}
338
339 /// \brief Construct a BlockCipherFinal
340 /// \param key a byte array used to key the cipher
341 /// \param length the length of the byte array
342 /// \param rounds the number of rounds
343 /// \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls
344 /// SimpleKeyingInterface::SetKeyWithRounds.
345 BlockCipherFinal(const byte *key, size_t length, unsigned int rounds)
346 {this->SetKeyWithRounds(key, length, rounds);}
347
348 /// \brief Provides the direction of the cipher
349 /// \return true if DIR is ENCRYPTION, false otherwise
350 /// \sa GetCipherDirection(), IsPermutation()
351 bool IsForwardTransformation() const {return DIR == ENCRYPTION;}
352};
353
354/// \brief Provides a base implementation of Algorithm and SimpleKeyingInterface for message authentication codes
355/// \tparam INFO a SimpleKeyingInterface derived class
356/// \tparam BASE a SimpleKeyingInterface derived class
357/// \details MessageAuthenticationCodeImpl() provides a default implementation for message authentication codes
358/// using AlgorithmImpl() and SimpleKeyingInterfaceImpl(). Functions are virtual and not subject to C++11
359/// <tt>constexpr</tt>.
360/// \sa Algorithm(), SimpleKeyingInterface(), AlgorithmImpl(), SimpleKeyingInterfaceImpl()
361template <class BASE, class INFO = BASE>
362class MessageAuthenticationCodeImpl : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BASE, INFO>, INFO>
363{
364};
365
366/// \brief Provides class member functions to key a message authentication code
367/// \tparam BASE a BlockCipherImpl derived class
368/// \details A default implementation for MessageAuthenticationCode
369template <class BASE>
370class MessageAuthenticationCodeFinal : public ClonableImpl<MessageAuthenticationCodeFinal<BASE>, MessageAuthenticationCodeImpl<BASE> >
371{
372public:
373 /// \brief Construct a default MessageAuthenticationCodeFinal
374 /// \details The message authentication code is not keyed.
376 /// \brief Construct a BlockCipherFinal
377 /// \param key a byte array used to key the algorithm
378 /// \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls
379 /// SimpleKeyingInterface::SetKey.
381 {this->SetKey(key, this->DEFAULT_KEYLENGTH);}
382 /// \brief Construct a BlockCipherFinal
383 /// \param key a byte array used to key the algorithm
384 /// \param length the length of the byte array
385 /// \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls
386 /// SimpleKeyingInterface::SetKey.
387 MessageAuthenticationCodeFinal(const byte *key, size_t length)
388 {this->SetKey(key, length);}
389};
390
391// ************** documentation ***************
392
393/// \brief Provides Encryption and Decryption typedefs used by derived classes to
394/// implement a block cipher
395/// \details These objects usually should not be used directly. See CipherModeDocumentation
396/// instead. Each class derived from this one defines two types, Encryption and Decryption,
397/// both of which implement the BlockCipher interface.
399{
400 /// implements the BlockCipher interface
402 /// implements the BlockCipher interface
404};
405
406/// \brief Provides Encryption and Decryption typedefs used by derived classes to
407/// implement a symmetric cipher
408/// \details Each class derived from this one defines two types, Encryption and Decryption,
409/// both of which implement the SymmetricCipher interface. Two types of classes derive
410/// from this class: stream ciphers and block cipher modes. Stream ciphers can be used
411/// alone, cipher mode classes need to be used with a block cipher. See CipherModeDocumentation
412/// for more for information about using cipher modes and block ciphers.
414{
415 /// implements the SymmetricCipher interface
417 /// implements the SymmetricCipher interface
419};
420
421/// \brief Provides Encryption and Decryption typedefs used by derived classes to
422/// implement an authenticated encryption cipher
423/// \details Each class derived from this one defines two types, Encryption and Decryption,
424/// both of which implement the AuthenticatedSymmetricCipher interface.
426{
427 /// implements the AuthenticatedSymmetricCipher interface
429 /// implements the AuthenticatedSymmetricCipher interface
431};
432
433NAMESPACE_END
434
435#if CRYPTOPP_MSC_VERSION
436# pragma warning(pop)
437#endif
438
439// Issue 340
440#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
441# pragma GCC diagnostic pop
442#endif
443
444#endif
Interface for all crypto algorithms.
Definition: cryptlib.h:599
virtual std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: cryptlib.h:619
Base class information.
Definition: simple.h:40
Interface for authenticated encryption modes of operation.
Definition: cryptlib.h:1321
Provides class member functions to key a block cipher.
Definition: seckey.h:318
bool IsForwardTransformation() const
Provides the direction of the cipher.
Definition: seckey.h:351
BlockCipherFinal()
Construct a default BlockCipherFinal.
Definition: seckey.h:322
BlockCipherFinal(const byte *key)
Construct a BlockCipherFinal.
Definition: seckey.h:328
BlockCipherFinal(const byte *key, size_t length, unsigned int rounds)
Construct a BlockCipherFinal.
Definition: seckey.h:345
BlockCipherFinal(const byte *key, size_t length)
Construct a BlockCipherFinal.
Definition: seckey.h:336
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1283
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:306
unsigned int BlockSize() const
Provides the block size of the algorithm.
Definition: seckey.h:310
Base class for identifying algorithm.
Definition: simple.h:26
Inherited by algorithms with fixed block size.
Definition: seckey.h:41
static const int BLOCKSIZE
The block size of the algorithm provided as a constant.
Definition: seckey.h:44
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:125
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
Definition: seckey.h:132
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
Definition: seckey.h:138
static size_t StaticGetValidKeyLength(size_t keylength)
The default key length for the algorithm provided by a static function.
Definition: seckey.h:150
static const int IV_LENGTH
The default IV length used by the algorithm provided as a constant.
Definition: seckey.h:145
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
Definition: seckey.h:135
static const int IV_REQUIREMENT
The default IV requirements for the algorithm provided as a constant.
Definition: seckey.h:142
static const int KEYLENGTH
The default key length used by the algorithm provided as a constant.
Definition: seckey.h:129
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:53
static const int ROUNDS
The number of rounds for the algorithm provided as a constant.
Definition: seckey.h:56
Exception thrown when an invalid number of rounds is encountered.
Definition: simple.h:66
Provides class member functions to key a message authentication code.
Definition: seckey.h:371
MessageAuthenticationCodeFinal(const byte *key, size_t length)
Construct a BlockCipherFinal.
Definition: seckey.h:387
MessageAuthenticationCodeFinal(const byte *key)
Construct a BlockCipherFinal.
Definition: seckey.h:380
MessageAuthenticationCodeFinal()
Construct a default MessageAuthenticationCodeFinal.
Definition: seckey.h:375
Provides a base implementation of Algorithm and SimpleKeyingInterface for message authentication code...
Definition: seckey.h:363
Interface for retrieving values given their names.
Definition: cryptlib.h:322
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Definition: cryptlib.h:424
Provides key lengths based on another class's key length.
Definition: seckey.h:218
static const int IV_REQUIREMENT
The default IV requirements for the algorithm provided as a constant.
Definition: seckey.h:232
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
Definition: seckey.h:228
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
Definition: seckey.h:222
static size_t StaticGetValidKeyLength(size_t keylength)
Provides a valid key length for the algorithm provided by a static function.
Definition: seckey.h:244
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
Definition: seckey.h:225
static const int IV_LENGTH
The default initialization vector length for the algorithm provided as a constant.
Definition: seckey.h:235
IV_Requirement
Secure IVs requirements as enumerated values.
Definition: cryptlib.h:719
Provides a base implementation of SimpleKeyingInterface.
Definition: seckey.h:258
size_t DefaultKeyLength() const
The default key length used by the algorithm.
Definition: seckey.h:272
size_t GetValidKeyLength(size_t keylength) const
Provides a valid key length for the algorithm.
Definition: seckey.h:283
size_t MaxKeyLength() const
The maximum key length used by the algorithm.
Definition: seckey.h:267
unsigned int IVSize() const
The initialization vector length for the algorithm.
Definition: seckey.h:294
size_t MinKeyLength() const
The minimum key length used by the algorithm.
Definition: seckey.h:262
SimpleKeyingInterface::IV_Requirement IVRequirement() const
The default IV requirements for the algorithm.
Definition: seckey.h:288
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode.
Definition: cryptlib.h:1291
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:166
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
Definition: seckey.h:181
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
Definition: seckey.h:184
static const int KEYLENGTH_MULTIPLE
The key length multiple used by the algorithm provided as a constant.
Definition: seckey.h:187
static const int IV_LENGTH
The default initialization vector length for the algorithm provided as a constant.
Definition: seckey.h:194
static size_t StaticGetValidKeyLength(size_t keylength)
Provides a valid key length for the algorithm provided by a static function.
Definition: seckey.h:203
static const int IV_REQUIREMENT
The default IV requirements for the algorithm provided as a constant.
Definition: seckey.h:191
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
Definition: seckey.h:178
Inherited by algorithms with variable number of rounds.
Definition: seckey.h:65
static const int DEFAULT_ROUNDS
The default number of rounds for the algorithm provided as a constant.
Definition: seckey.h:68
static unsigned int StaticGetDefaultRounds(size_t keylength)
The default number of rounds for the algorithm based on key length provided by a static function.
Definition: seckey.h:77
static const int MIN_ROUNDS
The minimum number of rounds for the algorithm provided as a constant.
Definition: seckey.h:70
static const int MAX_ROUNDS
The maximum number of rounds for the algorithm provided as a constant.
Definition: seckey.h:72
Library configuration file.
#define CRYPTOPP_API
Win32 calling convention.
Definition: config_dll.h:119
Abstract base classes that provide a uniform interface to this library.
CipherDir
Specifies a direction for a cipher to operate.
Definition: cryptlib.h:123
@ ENCRYPTION
the cipher is performing encryption
Definition: cryptlib.h:125
@ DECRYPTION
the cipher is performing decryption
Definition: cryptlib.h:127
Utility functions for the Crypto++ library.
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
Definition: misc.h:151
Crypto++ library namespace.
CipherDir ReverseCipherDir(CipherDir dir)
Inverts the cipher's direction.
Definition: seckey.h:32
Classes providing basic library services.
Common C++ header files.
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
Definition: seckey.h:426
AuthenticatedSymmetricCipher Decryption
implements the AuthenticatedSymmetricCipher interface
Definition: seckey.h:430
AuthenticatedSymmetricCipher Encryption
implements the AuthenticatedSymmetricCipher interface
Definition: seckey.h:428
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition: seckey.h:399
BlockCipher Decryption
implements the BlockCipher interface
Definition: seckey.h:403
BlockCipher Encryption
implements the BlockCipher interface
Definition: seckey.h:401
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher.
Definition: seckey.h:414
SymmetricCipher Decryption
implements the SymmetricCipher interface
Definition: seckey.h:418
SymmetricCipher Encryption
implements the SymmetricCipher interface
Definition: seckey.h:416