6#ifndef CRYPTOPP_SECKEY_H
7#define CRYPTOPP_SECKEY_H
15#if CRYPTOPP_MSC_VERSION
17# pragma warning(disable: 4189 4296)
21#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
22# pragma GCC diagnostic push
23# pragma GCC diagnostic ignored "-Wconversion"
24# pragma GCC diagnostic ignored "-Wsign-conversion"
39template <
unsigned int N>
51template <
unsigned int R>
63template <
unsigned int D,
unsigned int N=1,
unsigned int M=INT_MAX>
79 return CRYPTOPP_UNUSED(keylength),
static_cast<unsigned int>(
DEFAULT_ROUNDS);
88 inline void ThrowIfInvalidRounds(
int rounds,
const Algorithm *alg)
97 if (rounds < MIN_ROUNDS || rounds >
MAX_ROUNDS)
111 ThrowIfInvalidRounds(rounds, alg);
112 return static_cast<unsigned int>(rounds);
123template <
unsigned int N,
unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE,
unsigned int IV_L = 0>
152 return CRYPTOPP_UNUSED(keylength),
static_cast<size_t>(
KEYLENGTH);
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>
205 return (keylength <= N) ? N :
206 (keylength >= M) ? M :
207 (keylength+Q-1) - (keylength+Q-1)%Q;
216template <
class T,
unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE,
unsigned int IV_L = 0>
245 {
return T::StaticGetValidKeyLength(keylength);}
256template <
class BASE,
class INFO = BASE>
263 {
return INFO::MIN_KEYLENGTH;}
268 {
return static_cast<size_t>(INFO::MAX_KEYLENGTH);}
273 {
return INFO::DEFAULT_KEYLENGTH;}
283 size_t GetValidKeyLength(
size_t keylength)
const {
return INFO::StaticGetValidKeyLength(keylength);}
295 {
return INFO::IV_LENGTH;}
304template <
class INFO,
class BASE = BlockCipher>
310 unsigned int BlockSize()
const {
return this->BLOCKSIZE;}
316template <CipherDir DIR,
class BASE>
329 {this->SetKey(key, this->DEFAULT_KEYLENGTH);}
337 {this->SetKey(key, length);}
346 {this->SetKeyWithRounds(key, length, rounds);}
361template <
class BASE,
class INFO = BASE>
381 {this->SetKey(key, this->DEFAULT_KEYLENGTH);}
388 {this->SetKey(key, length);}
435#if CRYPTOPP_MSC_VERSION
440#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
441# pragma GCC diagnostic pop
Interface for all crypto algorithms.
virtual std::string AlgorithmName() const
Provides the name of this algorithm.
Interface for authenticated encryption modes of operation.
Provides class member functions to key a block cipher.
bool IsForwardTransformation() const
Provides the direction of the cipher.
BlockCipherFinal()
Construct a default BlockCipherFinal.
BlockCipherFinal(const byte *key)
Construct a BlockCipherFinal.
BlockCipherFinal(const byte *key, size_t length, unsigned int rounds)
Construct a BlockCipherFinal.
BlockCipherFinal(const byte *key, size_t length)
Construct a BlockCipherFinal.
Interface for one direction (encryption or decryption) of a block cipher.
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
unsigned int BlockSize() const
Provides the block size of the algorithm.
Base class for identifying algorithm.
Inherited by algorithms with fixed block size.
static const int BLOCKSIZE
The block size of the algorithm provided as a constant.
Inherited by keyed algorithms with fixed key length.
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
static size_t StaticGetValidKeyLength(size_t keylength)
The default key length for the algorithm provided by a static function.
static const int IV_LENGTH
The default IV length used by the algorithm provided as a constant.
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
static const int IV_REQUIREMENT
The default IV requirements for the algorithm provided as a constant.
static const int KEYLENGTH
The default key length used by the algorithm provided as a constant.
Inherited by algorithms with fixed number of rounds.
static const int ROUNDS
The number of rounds for the algorithm provided as a constant.
Exception thrown when an invalid number of rounds is encountered.
Provides class member functions to key a message authentication code.
MessageAuthenticationCodeFinal(const byte *key, size_t length)
Construct a BlockCipherFinal.
MessageAuthenticationCodeFinal(const byte *key)
Construct a BlockCipherFinal.
MessageAuthenticationCodeFinal()
Construct a default MessageAuthenticationCodeFinal.
Provides a base implementation of Algorithm and SimpleKeyingInterface for message authentication code...
Interface for retrieving values given their names.
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Provides key lengths based on another class's 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.
static const int MIN_KEYLENGTH
The minimum key length used by 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.
static const int IV_LENGTH
The default initialization vector length for the algorithm provided as a constant.
IV_Requirement
Secure IVs requirements as enumerated values.
Provides a base implementation of SimpleKeyingInterface.
size_t DefaultKeyLength() const
The default key length used by the algorithm.
size_t GetValidKeyLength(size_t keylength) const
Provides a valid key length for the algorithm.
size_t MaxKeyLength() const
The maximum key length used by the algorithm.
unsigned int IVSize() const
The initialization vector length for the algorithm.
size_t MinKeyLength() const
The minimum key length used by the algorithm.
SimpleKeyingInterface::IV_Requirement IVRequirement() const
The default IV requirements for the algorithm.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode.
Inherited by keyed algorithms with variable key length.
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
static const int KEYLENGTH_MULTIPLE
The key length multiple used by the algorithm provided as a constant.
static const int IV_LENGTH
The default initialization vector length 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 IV_REQUIREMENT
The default IV requirements for the algorithm provided as a constant.
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
Inherited by algorithms with variable number of rounds.
static const int DEFAULT_ROUNDS
The default number of rounds for the algorithm provided as a constant.
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 MIN_ROUNDS
The minimum number of rounds for the algorithm provided as a constant.
static const int MAX_ROUNDS
The maximum number of rounds for the algorithm provided as a constant.
Library configuration file.
#define CRYPTOPP_API
Win32 calling convention.
Abstract base classes that provide a uniform interface to this library.
CipherDir
Specifies a direction for a cipher to operate.
@ ENCRYPTION
the cipher is performing encryption
@ DECRYPTION
the cipher is performing decryption
Utility functions for the Crypto++ library.
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
Crypto++ library namespace.
CipherDir ReverseCipherDir(CipherDir dir)
Inverts the cipher's direction.
Classes providing basic library services.
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
AuthenticatedSymmetricCipher Decryption
implements the AuthenticatedSymmetricCipher interface
AuthenticatedSymmetricCipher Encryption
implements the AuthenticatedSymmetricCipher interface
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
BlockCipher Decryption
implements the BlockCipher interface
BlockCipher Encryption
implements the BlockCipher interface
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher.
SymmetricCipher Decryption
implements the SymmetricCipher interface
SymmetricCipher Encryption
implements the SymmetricCipher interface