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
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};
174template <
class CIPHER>
184 typename CIPHER::Encryption m_tweaker;
212template <
class CIPHER>
SecBlock using AllocatorWithCleanup<byte, true> typedef.
Interface for one direction (encryption or decryption) of a block cipher.
Block cipher mode of operation default implementation.
Block cipher mode of operation aggregate.
Interface for retrieving values given their names.
IV_Requirement
Secure IVs requirements as enumerated values.
XTS block cipher mode of operation implementation.
XTS block cipher mode of operation default implementation.
unsigned int MinLastBlockSize() const
Provides the size of the last block.
size_t DefaultKeyLength() const
Returns default key length.
bool IsValidKeyLength(size_t keylength) const
Returns whether keylength is a valid key length.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
static const char * StaticAlgorithmName()
The algorithm name.
size_t MaxKeyLength() const
Returns largest valid key length.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
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.
std::string AlgorithmName() const
Provides the name of this algorithm.
size_t MinKeyLength() const
Returns smallest valid key length.
unsigned long long word64
64-bit unsigned datatype
Abstract base classes that provide a uniform interface to this library.
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
ByteOrder
Provides the byte ordering.
@ BIG_ENDIAN_ORDER
byte order is big-endian
Utility functions for the Crypto++ library.
Classes for block cipher modes of operation.
Crypto++ library namespace.
Classes and functions for secure memory allocations.
Block cipher mode of operation information.
XTS block cipher mode of operation.