6 #ifndef CRYPTOPP_SECKEY_H
7 #define CRYPTOPP_SECKEY_H
11 #if CRYPTOPP_MSC_VERSION
12 # pragma warning(push)
13 # pragma warning(disable: 4189)
20 NAMESPACE_BEGIN(CryptoPP)
33 template <
unsigned int N>
46 template <
unsigned int R>
59 template <
unsigned int D,
unsigned int N=1,
unsigned int M=INT_MAX>
77 #if defined(CRYPTOPP_CXX11_CONSTEXPR)
78 return CRYPTOPP_UNUSED(keylength),
static_cast<unsigned int>(
DEFAULT_ROUNDS);
80 CRYPTOPP_UNUSED(keylength);
91 inline void ThrowIfInvalidRounds(
int rounds,
const Algorithm *alg)
100 if (rounds < MIN_ROUNDS || rounds >
MAX_ROUNDS)
114 ThrowIfInvalidRounds(rounds, alg);
115 return (
unsigned int)rounds;
127 template <
unsigned int N,
unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE,
unsigned int IV_L = 0>
158 #if defined(CRYPTOPP_CXX11_CONSTEXPR)
159 return CRYPTOPP_UNUSED(keylength),
static_cast<size_t>(
KEYLENGTH);
161 CRYPTOPP_UNUSED(keylength);
176 template <
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>
236 template <
class T,
unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE,
unsigned int IV_L = 0>
265 {
return T::StaticGetValidKeyLength(keylength);}
277 template <
class BASE,
class INFO = BASE>
284 {
return INFO::MIN_KEYLENGTH;}
289 {
return (
size_t)INFO::MAX_KEYLENGTH;}
294 {
return INFO::DEFAULT_KEYLENGTH;}
304 size_t GetValidKeyLength(
size_t keylength)
const {
return INFO::StaticGetValidKeyLength(keylength);}
315 {
return INFO::IV_LENGTH;}
325 template <
class INFO,
class BASE = BlockCipher>
331 unsigned int BlockSize()
const {
return this->BLOCKSIZE;}
338 template <CipherDir DIR,
class BASE>
351 {this->SetKey(key, this->DEFAULT_KEYLENGTH);}
359 {this->SetKey(key, length);}
368 {this->SetKeyWithRounds(key, length, rounds);}
384 template <
class BASE,
class INFO = BASE>
393 template <
class BASE>
405 {this->SetKey(key, this->DEFAULT_KEYLENGTH);}
412 {this->SetKey(key, length);}
462 #if CRYPTOPP_MSC_VERSION
463 # pragma warning(pop)
static const int KEYLENGTH_MULTIPLE
The key length multiple used by the algorithm provided as a constant.
static const int DEFAULT_ROUNDS
The default number of rounds for the algorithm provided as a constant.
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
the cipher is performing decryption
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
Inherited by keyed algorithms with fixed key length.
static const int IV_REQUIREMENT
The default IV requirements for the algorithm provided as a constant.
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
Classes providing basic library services.
Utility functions for the Crypto++ library.
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
static const int IV_LENGTH
The default initialization vector length for the algorithm provided as a constant.
MessageAuthenticationCodeFinal(const byte *key, size_t length)
Construct a BlockCipherFinal.
Interface for one direction (encryption or decryption) of a stream cipher or block cipher mode with a...
Base class for identifying alogorithm.
static const int KEYLENGTH
The default key length used by the algorithm provided as a constant.
static const int MAX_ROUNDS
The maximum number of rounds for the algorithm provided as a constant.
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
Provides a base implementation of SimpleKeyingInterface.
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
CipherDir
Specifies a direction for a cipher to operate.
Abstract base classes that provide a uniform interface to this library.
unsigned int BlockSize() const
Provides the block size of the algorithm.
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
Library configuration file.
Provides class member functions to key a message authentication code.
BlockCipherFinal(const byte *key)
Construct a BlockCipherFinal.
static const int IV_REQUIREMENT
The default IV requirements for the algorithm provided as a constant.
static size_t StaticGetValidKeyLength(size_t keylength)
Provides a valid key length for the algorithm provided by a static function.
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
BlockCipher Decryption
implements the BlockCipher interface
Interface for one direction (encryption or decryption) of a block cipher.
the cipher is performing encryption
Inherited by algorithms with fixed block size.
static size_t StaticGetValidKeyLength(size_t keylength)
The default key length for the algorithm provided by a static function.
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
BlockCipher Encryption
implements the BlockCipher interface
static const int IV_LENGTH
The default initialization vector length for the algorithm provided as a constant.
Inherited by algorithms with variable number of rounds.
int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
BlockCipherFinal()
Construct a default BlockCipherFinal.
Exception thrown when an invalid number of rounds is encountered.
size_t DefaultKeyLength() const
The default key length used by the algorithm.
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Provides class member functions to key a block cipher.
virtual std::string AlgorithmName() const
Provides the name of this algorithm.
Provides a base implementation of Algorithm and SimpleKeyingInterface for message authentication code...
MessageAuthenticationCodeFinal(const byte *key)
Construct a BlockCipherFinal.
bool IsForwardTransformation() const
Provides the direction of the cipher.
size_t GetValidKeyLength(size_t keylength) const
Provides a valid key length for the algorithm.
Provides key lengths based on another class's key length.
Inherited by algorithms with fixed number of rounds.
CipherDir ReverseCipherDir(CipherDir dir)
Inverts the cipher's direction.
SymmetricCipher Decryption
implements the SymmetricCipher interface
Inherited by keyed algorithms with variable key length.
Interface for all crypto algorithms.
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher...
static const int IV_REQUIREMENT
The default IV requirements for the algorithm provided as a constant.
AuthenticatedSymmetricCipher Encryption
implements the AuthenticatedSymmetricCipher interface
static const int MIN_ROUNDS
The minimum number of rounds for the algorithm provided as a constant.
IV_Requirement
Secure IVs requirements as enumerated values.
static const int ROUNDS
The number of rounds for the algorithm provided as a constant.
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
BlockCipherFinal(const byte *key, size_t length, unsigned int rounds)
Construct a BlockCipherFinal.
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
static size_t StaticGetValidKeyLength(size_t keylength)
Provides a valid key length for the algorithm provided by a static function.
static const int BLOCKSIZE
The block size of the algorithm provided as a constant.
AuthenticatedSymmetricCipher Decryption
implements the AuthenticatedSymmetricCipher interface
SimpleKeyingInterface::IV_Requirement IVRequirement() const
The default IV requirements for the algorithm.
BlockCipherFinal(const byte *key, size_t length)
Construct a BlockCipherFinal.
unsigned int IVSize() const
The default initialization vector length for the algorithm.
static unsigned int StaticGetDefaultRounds(size_t keylength)
The default number of rounds for the algorithm based on key length provided by a static function...
static const int IV_LENGTH
The default IV length used by the algorithm provided as a constant.
size_t MaxKeyLength() const
The maximum key length used by the algorithm.
SymmetricCipher Encryption
implements the SymmetricCipher interface
size_t MinKeyLength() const
The minimum key length used by the algorithm.
MessageAuthenticationCodeFinal()
Construct a default MessageAuthenticationCodeFinal.
Interface for retrieving values given their names.
Base class for identifying alogorithm.