summaryrefslogtreecommitdiff
path: root/cipher/arcfour.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2015-05-03 17:06:56 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2015-05-14 10:18:06 +0300
commitc46b015bedba7ce0db68929bd33a86a54ab3d919 (patch)
tree412ff5dd1f1a421331684d5f9b6bf51f3c38d99c /cipher/arcfour.c
parentee8fc4edcb3466b03246c8720b90731bf274ff1d (diff)
downloadlibgcrypt-c46b015bedba7ce0db68929bd33a86a54ab3d919.tar.gz
Enable AMD64 arcfour implementation on WIN64
* cipher/arcfour-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/arcfour.c (USE_AMD64_ASM): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (do_encrypt, do_decrypt) [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS]: Use assembly block to call AMD64 assembly function. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/arcfour.c')
-rw-r--r--cipher/arcfour.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/cipher/arcfour.c b/cipher/arcfour.c
index 27537bfd..44e8ef46 100644
--- a/cipher/arcfour.c
+++ b/cipher/arcfour.c
@@ -33,7 +33,8 @@
/* USE_AMD64_ASM indicates whether to use AMD64 assembly code. */
#undef USE_AMD64_ASM
-#if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
+#if defined(__x86_64__) && (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \
+ defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS))
# define USE_AMD64_ASM 1
#endif
@@ -53,7 +54,21 @@ static void
encrypt_stream (void *context,
byte *outbuf, const byte *inbuf, size_t length)
{
+#ifdef HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS
+ const void *fn = _gcry_arcfour_amd64;
+ /* Call SystemV ABI function without storing non-volatile XMM registers,
+ * as target function does not use vector instruction sets. */
+ asm volatile ("callq *%0\n\t"
+ : "+a" (fn),
+ "+D" (context),
+ "+S" (length),
+ "+d" (inbuf),
+ "+c" (outbuf)
+ :
+ : "cc", "memory", "r8", "r9", "r10", "r11");
+#else
_gcry_arcfour_amd64 (context, length, inbuf, outbuf );
+#endif
}
#else /*!USE_AMD64_ASM*/