diff options
author | Jeffrey Walton <noloader@gmail.com> | 2022-01-12 10:26:25 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2022-01-12 10:26:25 -0500 |
commit | 8f7304b61edb9738a292d7203c6c05165ce1ba1c (patch) | |
tree | e9359720bf1533a867aa5e0430133566c723cec8 /misc.h | |
parent | 230c558a4b6cf1208cab72bbee1307ca771e8ada (diff) | |
download | cryptopp-git-8f7304b61edb9738a292d7203c6c05165ce1ba1c.tar.gz |
Add ByteReverse(word128 value)
This speeds up XTS mode on x86_64 by 0.11 cpb
Diffstat (limited to 'misc.h')
-rw-r--r-- | misc.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -2089,6 +2089,19 @@ inline word64 ByteReverse(word64 value) #endif
}
+#if defined(CRYPTOPP_WORD128_AVAILABLE)
+/// \brief Reverses bytes in a 128-bit value
+/// \param value the 128-bit value to reverse
+/// \details ByteReverse calls bswap if available. Otherwise the function uses
+/// a combination of rotates on the word128.
+/// \since Crypto++ 8.7
+inline word128 ByteReverse(word128 value)
+{
+ // TODO: speed this up
+ return (word128(ByteReverse(word64(value))) << 64) | ByteReverse(word64(value>>64));
+}
+#endif
+
/// \brief Reverses bits in a 8-bit value
/// \param value the 8-bit value to reverse
/// \details BitReverse performs a combination of shifts on the byte.
|