summaryrefslogtreecommitdiff
path: root/misc.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2022-01-12 10:26:25 -0500
committerJeffrey Walton <noloader@gmail.com>2022-01-12 10:26:25 -0500
commit8f7304b61edb9738a292d7203c6c05165ce1ba1c (patch)
treee9359720bf1533a867aa5e0430133566c723cec8 /misc.h
parent230c558a4b6cf1208cab72bbee1307ca771e8ada (diff)
downloadcryptopp-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.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/misc.h b/misc.h
index 87cc877d..cc0accc8 100644
--- a/misc.h
+++ b/misc.h
@@ -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.