VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto/misc.h
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-01-02 17:56:29 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-01-03 00:15:08 +0100
commit6e1f5cfe4b50918db677f2646446c63c87f70547 (patch)
treefe01a76a87c48d2403225a742fadeacbec7f2825 /src/Crypto/misc.h
parent5872be28a243acb3b5aafdf13248e07d30471893 (diff)
downloadVeraCrypt-6e1f5cfe4b50918db677f2646446c63c87f70547.tar.gz
VeraCrypt-6e1f5cfe4b50918db677f2646446c63c87f70547.zip
Windows: use compiler intrinsic for some functions used in cryptographic primitives to ensure maximum performance.
Diffstat (limited to 'src/Crypto/misc.h')
-rw-r--r--src/Crypto/misc.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Crypto/misc.h b/src/Crypto/misc.h
index 7b702ec2..78044491 100644
--- a/src/Crypto/misc.h
+++ b/src/Crypto/misc.h
@@ -33,8 +33,13 @@
#define CRYPTOPP_FAST_ROTATE(x) 0
#endif
+#if defined( _MSC_VER ) && ( _MSC_VER > 800 )
+#pragma intrinsic(memcpy,memset)
+#endif
+
#if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
// Intel C++ Compiler 10.0 calls a function instead of using the rotate instruction when using these instructions
+#pragma intrinsic(_rotr,_rotl,_rotr64,_rotl64)
#define rotr32(x,n) _rotr(x, n)
#define rotl32(x,n) _rotl(x, n)
@@ -62,8 +67,10 @@
#else
#define bswap_32(x) (rotl32((((x) & 0xFF00FF00) >> 8) | (((x) & 0x00FF00FF) << 8), 16U))
#endif
+#ifndef TC_NO_COMPILER_INT64
#define bswap_64(x) rotl64(((((((value & LL(0xFF00FF00FF00FF00)) >> 8) | ((value & LL(0x00FF00FF00FF00FF)) << 8)) & LL(0xFFFF0000FFFF0000)) >> 16) | (((((value & LL(0xFF00FF00FF00FF00)) >> 8) | ((value & LL(0x00FF00FF00FF00FF)) << 8)) & LL(0x0000FFFF0000FFFF)) << 16)), 32U)
#endif
+#endif
VC_INLINE uint32 ByteReverseWord32 (uint32 value)
{
@@ -86,6 +93,8 @@ VC_INLINE uint32 ByteReverseWord32 (uint32 value)
#endif
}
+#ifndef TC_NO_COMPILER_INT64
+
VC_INLINE uint64 ByteReverseWord64(uint64 value)
{
#if defined(__GNUC__) && defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(__x86_64__)
@@ -110,6 +119,7 @@ VC_INLINE void CorrectEndianess(uint64 *out, const uint64 *in, size_t byteCount)
out[i] = ByteReverseWord64(in[i]);
}
+#endif
#ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
#define GetAlignmentOf(T) 1