Crypto++ 8.9
Free C++ class library of cryptographic schemes
|
XTS block cipher mode of operation default implementation. More...
#include <xts.h>
Public Member Functions | |
std::string | AlgorithmName () const |
Provides the name of this algorithm. | |
std::string | AlgorithmProvider () const |
Retrieve the provider of this algorithm. | |
size_t | MinKeyLength () const |
Returns smallest valid key length. | |
size_t | MaxKeyLength () const |
Returns largest valid key length. | |
size_t | DefaultKeyLength () const |
Returns default key length. | |
size_t | GetValidKeyLength (size_t n) const |
Returns a valid key length for the algorithm. | |
bool | IsValidKeyLength (size_t keylength) const |
Returns whether keylength is a valid key length. | |
void | ThrowIfInvalidKeyLength (size_t length) |
Validates the key length. | |
unsigned int | BlockSize () const |
Provides the block size of the cipher. | |
unsigned int | GetOptimalBlockSize () const |
Provides the input block size most efficient for this cipher. | |
unsigned int | MinLastBlockSize () const |
Provides the size of the last block. | |
unsigned int | OptimalDataAlignment () const |
Provides input and output data alignment for optimal performance. | |
void | ThrowIfInvalidBlockSize (size_t length) |
Validates the block size. | |
void | SetKey (const byte *key, size_t length, const NameValuePairs ¶ms=g_nullNameValuePairs) |
Sets or reset the key of this object. | |
IV_Requirement | IVRequirement () const |
Minimal requirement for secure IVs. | |
void | Resynchronize (const byte *iv, int ivLength=-1) |
Resynchronize with an IV. | |
void | ProcessData (byte *outString, const byte *inString, size_t length) |
Encrypt or decrypt an array of bytes. | |
size_t | ProcessLastBlock (byte *outString, size_t outLength, const byte *inString, size_t inLength) |
Encrypt or decrypt the last block of data. | |
void | Resynchronize (word64 sector, ByteOrder order=BIG_ENDIAN_ORDER) |
Resynchronize the cipher. | |
Public Member Functions inherited from BlockOrientedCipherModeBase | |
void | UncheckedSetKey (const byte *key, unsigned int length, const NameValuePairs ¶ms) |
Sets the key for this object without performing parameter validation. | |
unsigned int | MandatoryBlockSize () const |
Provides the mandatory block size of the cipher. | |
bool | IsRandomAccess () const |
Determines whether the cipher supports random access. | |
bool | IsSelfInverting () const |
Determines whether the cipher is self-inverting. | |
bool | IsForwardTransformation () const |
Determines if the cipher is being operated in its forward direction. | |
Public Member Functions inherited from CipherModeBase | |
unsigned int | IVSize () const |
Returns length of the IV accepted by this object. | |
void | SetCipher (BlockCipher &cipher) |
Set external block cipher. | |
void | SetCipherWithIV (BlockCipher &cipher, const byte *iv, int feedbackSize=0) |
Set external block cipher and IV. | |
Public Member Functions inherited from SimpleKeyingInterface | |
void | SetKeyWithRounds (const byte *key, size_t length, int rounds) |
Sets or reset the key of this object. | |
void | SetKeyWithIV (const byte *key, size_t length, const byte *iv, size_t ivLength) |
Sets or reset the key of this object. | |
void | SetKeyWithIV (const byte *key, size_t length, const byte *iv) |
Sets or reset the key of this object. | |
bool | IsResynchronizable () const |
Determines if the object can be resynchronized. | |
bool | CanUseRandomIVs () const |
Determines if the object can use random IVs. | |
bool | CanUsePredictableIVs () const |
Determines if the object can use random but possibly predictable IVs. | |
bool | CanUseStructuredIVs () const |
Determines if the object can use structured IVs. | |
unsigned int | DefaultIVLength () const |
Provides the default size of an IV. | |
virtual unsigned int | MinIVLength () const |
Provides the minimum size of an IV. | |
virtual unsigned int | MaxIVLength () const |
Provides the maximum size of an IV. | |
virtual void | GetNextIV (RandomNumberGenerator &rng, byte *iv) |
Retrieves a secure IV for the next message. | |
Public Member Functions inherited from StreamTransformation | |
StreamTransformation & | Ref () |
Provides a reference to this object. | |
virtual unsigned int | OptimalBlockSize () const |
Provides the input block size most efficient for this cipher. | |
virtual unsigned int | GetOptimalBlockSizeUsed () const |
Provides the number of bytes used in the current block when processing at optimal block size. | |
virtual bool | IsLastBlockSpecial () const |
Determines if the last block receives special processing. | |
void | ProcessString (byte *inoutString, size_t length) |
Encrypt or decrypt a string of bytes. | |
void | ProcessString (byte *outString, const byte *inString, size_t length) |
Encrypt or decrypt a string of bytes. | |
byte | ProcessByte (byte input) |
Encrypt or decrypt a byte. | |
virtual void | Seek (lword pos) |
Seek to an absolute position. | |
Public Member Functions inherited from Algorithm | |
Algorithm (bool checkSelfTestStatus=true) | |
Interface for all crypto algorithms. | |
Public Member Functions inherited from Clonable | |
virtual Clonable * | Clone () const |
Copies this object. | |
Static Public Member Functions | |
static const char * | StaticAlgorithmName () |
The algorithm name. | |
Additional Inherited Members | |
Public Types inherited from SimpleKeyingInterface | |
enum | IV_Requirement { UNIQUE_IV = 0 , RANDOM_IV , UNPREDICTABLE_RANDOM_IV , INTERNALLY_GENERATED_IV , NOT_RESYNCHRONIZABLE } |
Secure IVs requirements as enumerated values. More... | |
XTS block cipher mode of operation default implementation.
|
inlinestatic |
|
inlinevirtual |
Provides the name of this algorithm.
The standard algorithm name can be a name like AES
or AES/GCM
. Some algorithms do not have standard names yet. For example, there is no standard algorithm name for Shoup's ECIES.
Reimplemented from Algorithm.
|
inlinevirtual |
Retrieve the provider of this algorithm.
The algorithm provider can be a name like "C++", "SSE", "NEON", "AESNI", "ARMv8" and "Power8". C++ is standard C++ code. Other labels, like SSE, usually indicate a specialized implementation using instructions from a higher instruction set architecture (ISA). Future labels may include external hardware like a hardware security module (HSM).
Generally speaking Wei Dai's original IA-32 ASM code falls under "SSE2". Labels like "SSSE3" and "SSE4.1" follow after Wei's code and use intrinsics instead of ASM.
Algorithms which combine different instructions or ISAs provide the dominant one. For example on x86 AES/GCM
returns "AESNI" rather than "CLMUL" or "AES+SSE4.1" or "AES+CLMUL" or "AES+SSE4.1+CLMUL".
Reimplemented from CipherModeBase.
|
inlinevirtual |
Returns smallest valid key length.
Reimplemented from CipherModeBase.
|
inlinevirtual |
Returns largest valid key length.
Reimplemented from CipherModeBase.
|
inlinevirtual |
Returns default key length.
Reimplemented from CipherModeBase.
|
inlinevirtual |
Returns a valid key length for the algorithm.
keylength | the size of the key, in bytes |
keylength is provided in bytes, not bits. If keylength is less than MIN_KEYLENGTH, then the function returns MIN_KEYLENGTH. If keylength is greater than MAX_KEYLENGTH, then the function returns MAX_KEYLENGTH. if If keylength is a multiple of KEYLENGTH_MULTIPLE, then keylength is returned. Otherwise, the function returns a lower multiple of KEYLENGTH_MULTIPLE.
Reimplemented from CipherModeBase.
|
inlinevirtual |
Returns whether keylength is a valid key length.
keylength | the requested keylength |
Internally the function calls GetValidKeyLength()
Reimplemented from CipherModeBase.
void XTS_ModeBase::ThrowIfInvalidKeyLength | ( | size_t | length | ) |
Validates the key length.
length | the size of the keying material, in bytes |
InvalidKeyLength | if the key length is invalid |
|
inline |
|
inline |
Provides the input block size most efficient for this cipher.
The base class implementation returns MandatoryBlockSize().
n * OptimalBlockSize() - GetOptimalBlockSizeUsed()
for any n > 0
.
|
inlinevirtual |
Provides the size of the last block.
MinLastBlockSize() returns the minimum size of the last block. 0 indicates the last block is not special.
MandatoryBlockSize() enlists one of two behaviors. First, if MandatoryBlockSize() returns 1, then the cipher can be streamed and ProcessData() is called with the tail bytes. Second, if MandatoryBlockSize() returns non-0, then the string of bytes is padded to MandatoryBlockSize() according to the padding mode. Then, ProcessData() is called with the padded string of bytes.
Some authenticated encryption modes are not expressed well with MandatoryBlockSize() and MinLastBlockSize(). For example, AES/OCB uses 16-byte blocks (MandatoryBlockSize = 16) and the last block requires special processing (MinLastBlockSize = 0). However, 0 is a valid last block size for OCB and the special processing is custom padding, and not standard PKCS padding. In response an unambiguous IsLastBlockSpecial() was added.
Reimplemented from StreamTransformation.
|
inlinevirtual |
Provides input and output data alignment for optimal performance.
Reimplemented from CipherModeBase.
void XTS_ModeBase::ThrowIfInvalidBlockSize | ( | size_t | length | ) |
Validates the block size.
length | the block size of the cipher, in bytes |
InvalidArgument | if the block size is invalid |
If CRYPTOPP_XTS_WIDE_BLOCK_CIPHERS
is 0, then CIPHER must be a 16-byte block cipher. If CRYPTOPP_XTS_WIDE_BLOCK_CIPHERS
is non-zero then CIPHER can be 16, 32, 64, or 128-byte block cipher.
|
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 to configure this object |
Reimplemented from SimpleKeyingInterface.
|
inlinevirtual |
Minimal requirement for secure IVs.
Implements CipherModeBase.
|
virtual |
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 from BlockOrientedCipherModeBase.
Encrypt or decrypt an array of bytes.
outString | the output byte buffer |
inString | the input byte buffer |
length | the size of the input and output byte buffers, in bytes |
ProcessData is called with a string of bytes whose size depends on MandatoryBlockSize. Either inString == outString
, or they must not overlap.
Implements StreamTransformation.
|
virtual |
Encrypt or decrypt the last block of data.
outString | the output byte buffer |
outLength | the size of the output byte buffer, in bytes |
inString | the input byte buffer |
inLength | the size of the input byte buffer, in bytes |
ProcessLastBlock is used when the last block of data is special and requires handling by the cipher. The current implementation provides an output buffer with a size inLength+2*MandatoryBlockSize()
. The return value allows the cipher to expand cipher text during encryption or shrink plain text during decryption.
This member function is used by CBC-CTS and OCB modes.
Reimplemented from StreamTransformation.
void XTS_ModeBase::Resynchronize | ( | word64 | sector, |
ByteOrder | order = BIG_ENDIAN_ORDER ) |
Resynchronize the cipher.
sector | a 64-bit sector number |
order | the endian order the word should be written |
The Resynchronize() overload was provided for API compatibility with the IEEE P1619 paper.