6 #ifndef CRYPTOPP_SECKEY_H 7 #define CRYPTOPP_SECKEY_H 14 #if CRYPTOPP_MSC_VERSION 15 # pragma warning(push) 16 # pragma warning(disable: 4189) 20 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 21 # pragma GCC diagnostic push 22 # pragma GCC diagnostic ignored "-Wconversion" 23 # pragma GCC diagnostic ignored "-Wsign-conversion" 39 template <
unsigned int N>
52 template <
unsigned int R>
65 template <
unsigned int D,
unsigned int N=1,
unsigned int M=INT_MAX>
81 return CRYPTOPP_UNUSED(keylength),
static_cast<unsigned int>(DEFAULT_ROUNDS);
94 if (rounds < MIN_ROUNDS)
99 if (rounds < MIN_ROUNDS || rounds > MAX_ROUNDS)
113 ThrowIfInvalidRounds(rounds, alg);
114 return (
unsigned int)rounds;
126 template <
unsigned int N,
unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE,
unsigned int IV_L = 0>
168 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>
209 return (keylength <= N) ? N :
210 (keylength >= M) ? M :
211 (keylength+
Q-1) - (keylength+
Q-1)%
Q;
221 template <
class T,
unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE,
unsigned int IV_L = 0>
250 {
return T::StaticGetValidKeyLength(keylength);}
262 template <
class BASE,
class INFO = BASE>
269 {
return INFO::MIN_KEYLENGTH;}
274 {
return (
size_t)INFO::MAX_KEYLENGTH;}
279 {
return INFO::DEFAULT_KEYLENGTH;}
289 size_t GetValidKeyLength(
size_t keylength)
const {
return INFO::StaticGetValidKeyLength(keylength);}
300 {
return INFO::IV_LENGTH;}
310 template <
class INFO,
class BASE = BlockCipher>
316 unsigned int BlockSize()
const {
return this->BLOCKSIZE;}
323 template <CipherDir DIR,
class BASE>
336 {this->SetKey(key, this->DEFAULT_KEYLENGTH);}
344 {this->SetKey(key, length);}
353 {this->SetKeyWithRounds(key, length, rounds);}
369 template <
class BASE,
class INFO = BASE>
378 template <
class BASE>
390 {this->SetKey(key, this->DEFAULT_KEYLENGTH);}
397 {this->SetKey(key, length);}
447 #if CRYPTOPP_MSC_VERSION 448 # pragma warning(pop) 452 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 453 # pragma GCC diagnostic pop the cipher is performing decryption
Inherited by keyed algorithms with fixed key length.
Classes providing basic library services.
Utility functions for the Crypto++ library.
#define CRYPTOPP_STATIC_CONSTEXPR
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
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.
Provides a base implementation of SimpleKeyingInterface.
#define NAMESPACE_BEGIN(x)
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.
void ThrowIfInvalidRounds(int rounds, const Algorithm *alg)
Validates the number of rounds for an algorithm.
Provides class member functions to key a message authentication code.
BlockCipherFinal(const byte *key)
Construct a BlockCipherFinal.
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.
BlockCipher Encryption
implements the BlockCipher interface
Inherited by algorithms with variable number of rounds.
#define CRYPTOPP_COMPILE_ASSERT(assertion)
BlockCipherFinal()
Construct a default BlockCipherFinal.
Exception thrown when an invalid number of rounds is encountered.
unsigned int GetRoundsAndThrowIfInvalid(const NameValuePairs ¶m, const Algorithm *alg)
Validates the number of rounds for an algorithm.
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
size_t DefaultKeyLength() const
The default key length used by the algorithm.
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.
#define CRYPTOPP_CONSTANT(x)
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.
#define CRYPTOPP_NO_VTABLE
Interface for all crypto algorithms.
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher...
AuthenticatedSymmetricCipher Encryption
implements the AuthenticatedSymmetricCipher interface
IV_Requirement
Secure IVs requirements as enumerated values.
#define CRYPTOPP_UNUSED(x)
BlockCipherFinal(const byte *key, size_t length, unsigned int rounds)
Construct a BlockCipherFinal.
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
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.
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.