Crypto++
5.6.5
Free C++ class library of cryptographic schemes
|
Interface for algorithms that take byte strings as keys. More...
Public Types | |
enum | IV_Requirement { UNIQUE_IV = 0, RANDOM_IV, UNPREDICTABLE_RANDOM_IV, INTERNALLY_GENERATED_IV, NOT_RESYNCHRONIZABLE } |
Secure IVs requirements as enumerated values. More... | |
Public Member Functions | |
virtual size_t | MinKeyLength () const =0 |
Returns smallest valid key length in bytes. | |
virtual size_t | MaxKeyLength () const =0 |
Returns largest valid key length in bytes. | |
virtual size_t | DefaultKeyLength () const =0 |
Returns default (recommended) key length in bytes. | |
virtual size_t | GetValidKeyLength (size_t n) const =0 |
virtual bool | IsValidKeyLength (size_t keylength) const |
Returns whether keylength is a valid key length. More... | |
virtual void | SetKey (const byte *key, size_t length, const NameValuePairs ¶ms=g_nullNameValuePairs) |
Sets or reset the key of this object. More... | |
void | SetKeyWithRounds (const byte *key, size_t length, int rounds) |
Sets or reset the key of this object. More... | |
void | SetKeyWithIV (const byte *key, size_t length, const byte *iv, size_t ivLength) |
Sets or reset the key of this object. More... | |
void | SetKeyWithIV (const byte *key, size_t length, const byte *iv) |
Sets or reset the key of this object. More... | |
virtual IV_Requirement | IVRequirement () const =0 |
Minimal requirement for secure IVs. More... | |
bool | IsResynchronizable () const |
Determines if the object can be resynchronized. More... | |
bool | CanUseRandomIVs () const |
Determines if the object can use random IVs. More... | |
bool | CanUsePredictableIVs () const |
Determines if the object can use random but possibly predictable IVs. More... | |
bool | CanUseStructuredIVs () const |
Determines if the object can use structured IVs. More... | |
virtual unsigned int | IVSize () const |
Returns length of the IV accepted by this object. More... | |
unsigned int | DefaultIVLength () const |
Provides the default size of an IV. More... | |
virtual unsigned int | MinIVLength () const |
Provides the minimum size of an IV. More... | |
virtual unsigned int | MaxIVLength () const |
Provides the maximum size of an IV. More... | |
virtual void | Resynchronize (const byte *iv, int ivLength=-1) |
Resynchronize with an IV. More... | |
virtual void | GetNextIV (RandomNumberGenerator &rng, byte *iv) |
Retrieves a secure IV for the next message. More... | |
Interface for algorithms that take byte strings as keys.
Definition at line 529 of file cryptlib.h.
Secure IVs requirements as enumerated values.
Provides secure IV requirements as a monotomically increasing enumerated values. Requirements can be compared using less than (<) and greater than (>). For example, UNIQUE_IV < RANDOM_IV
and UNPREDICTABLE_RANDOM_IV > RANDOM_IV
.
Definition at line 595 of file cryptlib.h.
|
pure virtual |
n | the desired keylength |
min(n, GetMaxKeyLength())
Implemented in SimpleKeyingInterfaceImpl< TTMAC_Base, TTMAC_Base >, SimpleKeyingInterfaceImpl< HMAC_Base, HMAC< T > >, SimpleKeyingInterfaceImpl< DMAC_Base< T >, DMAC_Base< T > >, SimpleKeyingInterfaceImpl< CMAC_Base, CMAC< T > >, SimpleKeyingInterfaceImpl< VMAC_Base, SameKeyLengthAs< T_BlockCipher, SimpleKeyingInterface::UNIQUE_IV, T_BlockCipher::BLOCKSIZE > >, SimpleKeyingInterfaceImpl< BlockCipher, BTEA_Info >, SimpleKeyingInterfaceImpl< CBC_MAC_Base, CBC_MAC< T > >, SimpleKeyingInterfaceImpl< CMAC_Base, CMAC< T_BlockCipher > >, SimpleKeyingInterfaceImpl< MessageAuthenticationCode, BLAKE2_Info< T_64bit > >, CipherModeBase, GCM_Base, CCM_Base, and EAX_Base.
|
inlinevirtual |
Returns whether keylength is a valid key length.
keylength | the requested keylength |
Internally the function calls GetValidKeyLength()
Reimplemented in CipherModeBase, GCM_Base, CCM_Base, and EAX_Base.
Definition at line 550 of file cryptlib.h.
|
virtual |
Sets or reset the key of this object.
key | the key to use when keying the object |
length | the size of the key, in bytes |
params | additional initialization parameters that cannot be passed directly through the constructor |
Reimplemented in ECB_OneWay, and AuthenticatedSymmetricCipherBase.
Definition at line 97 of file cryptlib.cpp.
void SimpleKeyingInterface::SetKeyWithRounds | ( | const byte * | key, |
size_t | length, | ||
int | rounds | ||
) |
Sets or reset the key of this object.
key | the key to use when keying the object |
length | the size of the key, in bytes |
rounds | the number of rounds to apply the transformation function, if applicable |
SetKeyWithRounds() calls SetKey() with a NameValuePairs object that only specifies rounds. rounds is an integer parameter, and -1
means use the default number of rounds.
Definition at line 103 of file cryptlib.cpp.
void SimpleKeyingInterface::SetKeyWithIV | ( | const byte * | key, |
size_t | length, | ||
const byte * | iv, | ||
size_t | ivLength | ||
) |
Sets or reset the key of this object.
key | the key to use when keying the object |
length | the size of the key, in bytes |
iv | the intiialization vector to use when keying the object |
ivLength | the size of the iv, in bytes |
SetKeyWithIV() calls SetKey() with a NameValuePairs that only specifies IV. The IV is a byte buffer with size ivLength. ivLength is an integer parameter, and -1
means use IVSize().
Definition at line 108 of file cryptlib.cpp.
|
inline |
Sets or reset the key of this object.
key | the key to use when keying the object |
length | the size of the key, in bytes |
iv | the intiialization vector to use when keying the object |
SetKeyWithIV() calls SetKey() with a NameValuePairs() object that only specifies iv. iv is a byte buffer, and it must have a size IVSize().
Definition at line 587 of file cryptlib.h.
|
pure virtual |
Minimal requirement for secure IVs.
Implemented in SimpleKeyingInterfaceImpl< TTMAC_Base, TTMAC_Base >, SimpleKeyingInterfaceImpl< HMAC_Base, HMAC< T > >, SimpleKeyingInterfaceImpl< DMAC_Base< T >, DMAC_Base< T > >, SimpleKeyingInterfaceImpl< CMAC_Base, CMAC< T > >, SimpleKeyingInterfaceImpl< VMAC_Base, SameKeyLengthAs< T_BlockCipher, SimpleKeyingInterface::UNIQUE_IV, T_BlockCipher::BLOCKSIZE > >, SimpleKeyingInterfaceImpl< BlockCipher, BTEA_Info >, SimpleKeyingInterfaceImpl< CBC_MAC_Base, CBC_MAC< T > >, SimpleKeyingInterfaceImpl< CMAC_Base, CMAC< T_BlockCipher > >, SimpleKeyingInterfaceImpl< MessageAuthenticationCode, BLAKE2_Info< T_64bit > >, CBC_ModeBase, ECB_OneWay, CTR_ModePolicy, OFB_ModePolicy, CFB_ModePolicy, CipherModeBase, GCM_Base, CCM_Base, and EAX_Base.
|
inline |
Determines if the object can be resynchronized.
CanUseStructuredIVs()==true
, an IV of all 0's will be assumed. Definition at line 616 of file cryptlib.h.
|
inline |
Determines if the object can use random IVs.
Definition at line 620 of file cryptlib.h.
|
inline |
Determines if the object can use random but possibly predictable IVs.
Definition at line 625 of file cryptlib.h.
|
inline |
Determines if the object can use structured IVs.
CanUseStructuredIVs() indicates whether the object can use structured IVs; for example a counter (in addition to ones returned by GetNextIV).
Definition at line 631 of file cryptlib.h.
|
inlinevirtual |
Returns length of the IV accepted by this object.
NotImplemented() | if the object does not support resynchronization |
The default implementation throws NotImplemented
Reimplemented in SimpleKeyingInterfaceImpl< TTMAC_Base, TTMAC_Base >, SimpleKeyingInterfaceImpl< HMAC_Base, HMAC< T > >, SimpleKeyingInterfaceImpl< DMAC_Base< T >, DMAC_Base< T > >, SimpleKeyingInterfaceImpl< CMAC_Base, CMAC< T > >, SimpleKeyingInterfaceImpl< VMAC_Base, SameKeyLengthAs< T_BlockCipher, SimpleKeyingInterface::UNIQUE_IV, T_BlockCipher::BLOCKSIZE > >, SimpleKeyingInterfaceImpl< BlockCipher, BTEA_Info >, SimpleKeyingInterfaceImpl< CBC_MAC_Base, CBC_MAC< T > >, SimpleKeyingInterfaceImpl< CMAC_Base, CMAC< T_BlockCipher > >, SimpleKeyingInterfaceImpl< MessageAuthenticationCode, BLAKE2_Info< T_64bit > >, CipherModeBase, GCM_Base, CCM_Base, EAX_Base, and VMAC_Base.
Definition at line 637 of file cryptlib.h.
|
inline |
Provides the default size of an IV.
Definition at line 642 of file cryptlib.h.
|
inlinevirtual |
Provides the minimum size of an IV.
NotImplemented() | if the object does not support resynchronization |
Reimplemented in GCM_Base, CCM_Base, EAX_Base, and VMAC_Base.
Definition at line 647 of file cryptlib.h.
|
inlinevirtual |
Provides the maximum size of an IV.
NotImplemented() | if the object does not support resynchronization |
Reimplemented in GCM_Base, CCM_Base, and EAX_Base.
Definition at line 652 of file cryptlib.h.
|
inlinevirtual |
Resynchronize with an IV.
iv | the initialization vector |
ivLength | the size of the initialization vector, in bytes |
Resynchronize() resynchronizes with an IV provided by the caller. ivLength=-1
means use IVSize().
NotImplemented() | if the object does not support resynchronization |
Reimplemented in AdditiveCipherTemplate< AbstractPolicyHolder< AdditiveCipherAbstractPolicy, CTR_ModePolicy > >, BlockOrientedCipherModeBase, AuthenticatedSymmetricCipherBase, and VMAC_Base.
Definition at line 659 of file cryptlib.h.
|
virtual |
Retrieves a secure IV for the next message.
rng | a RandomNumberGenerator to produce keying material |
iv | a block of bytes to receive the IV |
The IV must be at least IVSize() in length.
This method should be called after you finish encrypting one message and are ready to start the next one. After calling it, you must call SetKey() or Resynchronize(). before using this object again.
Internally, the base class implementation calls RandomNumberGenerator's GenerateBlock()
Reimplemented in VMAC_Base.
Definition at line 173 of file cryptlib.cpp.