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