22 #ifndef CRYPTOPP_XTS_MODE_H 23 #define CRYPTOPP_XTS_MODE_H 41 #ifndef CRYPTOPP_XTS_WIDE_BLOCK_CIPHERS 42 # define CRYPTOPP_XTS_WIDE_BLOCK_CIPHERS 0 43 #endif // CRYPTOPP_XTS_WIDE_BLOCK_CIPHERS 56 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName()
62 {
return GetBlockCipher().AlgorithmName() +
"/XTS";}
64 {
return GetBlockCipher().AlgorithmProvider();}
67 {
return GetBlockCipher().MinKeyLength()*2;}
69 {
return GetBlockCipher().MaxKeyLength()*2;}
71 {
return GetBlockCipher().DefaultKeyLength()*2;}
73 {
return 2*GetBlockCipher().GetValidKeyLength((n+1)/2);}
75 {
return keylength == GetValidKeyLength(keylength);}
80 void ThrowIfInvalidKeyLength(
size_t length);
85 {
return GetBlockCipher().BlockSize();}
94 {
return GetBlockCipher().BlockSize()*ParallelBlocks;}
96 {
return GetBlockCipher().BlockSize()+1;}
98 {
return GetBlockCipher().OptimalDataAlignment();}
107 void ThrowIfInvalidBlockSize(
size_t length);
111 void Resynchronize(
const byte *iv,
int ivLength=-1);
112 void ProcessData(
byte *outString,
const byte *inString,
size_t length);
113 size_t ProcessLastBlock(
byte *outString,
size_t outLength,
const byte *inString,
size_t inLength);
123 virtual void ResizeBuffers();
125 inline size_t ProcessLastPlainBlock(
byte *outString,
size_t outLength,
const byte *inString,
size_t inLength);
126 inline size_t ProcessLastCipherBlock(
byte *outString,
size_t outLength,
const byte *inString,
size_t inLength);
132 {
return const_cast<XTS_ModeBase*
>(
this)->AccessBlockCipher();}
134 {
return const_cast<XTS_ModeBase*
>(
this)->AccessTweakCipher();}
142 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 143 enum {ParallelBlocks = 4};
145 enum {ParallelBlocks = 12};
174 template <
class CIPHER>
184 typename CIPHER::Encryption m_tweaker;
212 template <
class CIPHER>
224 #endif // CRYPTOPP_XTS_MODE_H IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Utility functions for the Crypto++ library.
ByteOrder
Provides the byte ordering.
Classes for block cipher modes of operation.
Abstract base classes that provide a uniform interface to this library.
XTS block cipher mode of operation.
unsigned int BlockSize() const
Provides the block size of the cipher.
size_t MaxKeyLength() const
Returns largest valid key length.
Interface for one direction (encryption or decryption) of a block cipher.
Classes and functions for secure memory allocations.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
Block cipher mode of operation aggregate.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
unsigned long long word64
64-bit unsigned datatype
Block cipher mode of operation information.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Block cipher mode of operation default implementation.
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
SecBlock using AllocatorWithCleanup<byte, true> typedef.
size_t DefaultKeyLength() const
Returns default key length.
unsigned char byte
8-bit unsigned datatype
IV_Requirement
Secure IVs requirements as enumerated values.
XTS block cipher mode of operation default implementation.
unsigned int MinLastBlockSize() const
Provides the size of the last block.
bool IsValidKeyLength(size_t keylength) const
Returns whether keylength is a valid key length.
XTS block cipher mode of operation implementation.
Crypto++ library namespace.
unsigned int GetOptimalBlockSize() const
Provides the input block size most efficient for this cipher.
std::string AlgorithmName() const
Provides the name of this algorithm.
size_t MinKeyLength() const
Returns smallest valid key length.
Interface for retrieving values given their names.