diff options
-rw-r--r-- | cipher/arcfour-amd64.S | 13 | ||||
-rw-r--r-- | cipher/arcfour.c | 17 |
2 files changed, 26 insertions, 4 deletions
diff --git a/cipher/arcfour-amd64.S b/cipher/arcfour-amd64.S index 8b8031a1..2e52ea00 100644 --- a/cipher/arcfour-amd64.S +++ b/cipher/arcfour-amd64.S @@ -15,12 +15,19 @@ #ifdef __x86_64__ #include <config.h> -#if defined(USE_ARCFOUR) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) +#if defined(USE_ARCFOUR) && (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \ + defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) + +#ifdef HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS +# define ELF(...) __VA_ARGS__ +#else +# define ELF(...) /*_*/ +#endif .text .align 16 .globl _gcry_arcfour_amd64 -.type _gcry_arcfour_amd64,@function +ELF(.type _gcry_arcfour_amd64,@function) _gcry_arcfour_amd64: push %rbp push %rbx @@ -91,7 +98,7 @@ _gcry_arcfour_amd64: pop %rbp ret .L__gcry_arcfour_amd64_end: -.size _gcry_arcfour_amd64,.L__gcry_arcfour_amd64_end-_gcry_arcfour_amd64 +ELF(.size _gcry_arcfour_amd64,.L__gcry_arcfour_amd64_end-_gcry_arcfour_amd64) #endif #endif 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*/ |