summaryrefslogtreecommitdiff
path: root/xts.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-10-13 16:17:37 -0400
committerJeffrey Walton <noloader@gmail.com>2019-10-13 16:17:37 -0400
commit8e8e95cea204319d99380cbedd0159746876355a (patch)
tree1bf4e060c569cf89352179b81af4284836e7616d /xts.h
parentc9b8452d570ce0d5f883c249b942518ef509fc18 (diff)
downloadcryptopp-git-8e8e95cea204319d99380cbedd0159746876355a.tar.gz
Make XTS mode parallelizable (GH #891)
On CoffeeLake performance increased from 3.4 cpb to 1.75 cpb. On Core2Duo performance increased from 27 cpb to 19 cpb.
Diffstat (limited to 'xts.h')
-rw-r--r--xts.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/xts.h b/xts.h
index 6559dcc7..8b4234fe 100644
--- a/xts.h
+++ b/xts.h
@@ -49,6 +49,8 @@ NAMESPACE_BEGIN(CryptoPP)
class CRYPTOPP_NO_VTABLE XTS_ModeBase : public BlockOrientedCipherModeBase
{
public:
+ virtual ~XTS_ModeBase() {}
+
std::string AlgorithmName() const
{return GetBlockCipher().AlgorithmName() + "/XTS";}
std::string AlgorithmProvider() const
@@ -70,6 +72,8 @@ public:
/// \return the block size of the cipher, in bytes
unsigned int BlockSize() const
{return GetBlockCipher().BlockSize();}
+ unsigned int GetOptimalBlockSize() const
+ {return GetBlockCipher().BlockSize()*ParallelBlocks;}
unsigned int MinLastBlockSize() const
{return GetBlockCipher().BlockSize()+1;}
unsigned int OptimalDataAlignment() const
@@ -102,7 +106,10 @@ protected:
const BlockCipher& GetTweakCipher() const
{return const_cast<XTS_ModeBase*>(this)->AccessTweakCipher();}
- SecByteBlock m_workspace;
+ SecByteBlock m_xregister;
+ SecByteBlock m_xworkspace;
+
+ enum {ParallelBlocks = 4};
};
/// \brief XTS block cipher mode of operation implementation details
@@ -112,7 +119,7 @@ template <class CIPHER>
class CRYPTOPP_NO_VTABLE XTS_Final : public XTS_ModeBase
{
public:
- static const char* CRYPTOPP_API StaticAlgorithmName()
+ CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName()
{return "XTS";}
protected: