diff -rup origsrc/rng-tools-5/configure.ac src/rng-tools-5/configure.ac --- origsrc/rng-tools-5/configure.ac 2014-08-12 10:33:32.064585400 +0200 +++ src/rng-tools-5/configure.ac 2014-08-12 11:18:44.431782000 +0200 @@ -56,6 +56,8 @@ dnl ------------------------------------ dnl Checks for optional library functions dnl ------------------------------------- +AC_SEARCH_LIBS([argp_parse],[argp]) + dnl ------------------------------------- dnl Check for libgcrypt support dnl ------------------------------------- diff -rup origsrc/rng-tools-5/rdrand_asm.S src/rng-tools-5/rdrand_asm.S --- origsrc/rng-tools-5/rdrand_asm.S 2014-08-13 10:16:08.499091900 +0200 +++ src/rng-tools-5/rdrand_asm.S 2014-08-13 10:12:40.745403500 +0200 @@ -20,20 +20,43 @@ #if defined(__i386__) || defined(__x86_64__) -#define ENTRY(x) \ - .balign 64 ; \ - .globl x ; \ -x: +#if defined __CYGWIN__ +# if defined __x86_64__ +# define MS_x86_64_ABI +# else +# define SYMBOL(name) _ ## name +# endif +#else +# define ELF_DEBUG_INFO +#endif +#if !defined SYMBOL +# define SYMBOL(name) name +#endif + +#define ENTRY(x) \ + .balign 64 ; \ + .globl SYMBOL(x) ; \ +SYMBOL(x): +#if defined ELF_DEBUG_INFO #define ENDPROC(x) \ .size x, .-x ; \ .type x, @function +#else +#define ENDPROC(x) +#endif #define RDRAND_RETRY_LIMIT 10 #ifdef __x86_64__ ENTRY(x86_rdrand_bytes) +#if defined MS_x86_64_ABI + push %rdi + push %rsi + mov %rcx, %rdi + mov %rdx, %rsi +#endif mov %esi, %eax 1: mov $RDRAND_RETRY_LIMIT, %ecx @@ -46,6 +69,10 @@ ENTRY(x86_rdrand_bytes) ja 1b 4: sub %esi, %eax +#if defined MS_x86_64_ABI + pop %rsi + pop %rdi +#endif ret 3: dec %ecx @@ -55,6 +82,14 @@ ENTRY(x86_rdrand_bytes) ENDPROC(x86_rdrand_bytes) ENTRY(x86_rdseed_or_rdrand_bytes) +#if defined MS_x86_64_ABI + push %rdi + push %rsi + mov %rcx, %rdi + mov %rdx, %rsi + mov %r8, %rdx + mov %r9, %rcx +#endif mov (%rsi), %r8d /* RDSEED count */ mov (%rcx), %r9d /* RDRAND count */ 1: @@ -69,6 +104,10 @@ ENTRY(x86_rdseed_or_rdrand_bytes) 4: sub %r8d, (%rsi) sub %r9d, (%rcx) +#if defined MS_x86_64_ABI + pop %rsi + pop %rdi +#endif ret 3: .byte 0x48,0x0f,0xc7,0xf0 /* rdrand %rax */ @@ -191,6 +230,12 @@ ENTRY(x86_aes_mangle) movl 12(%ebp), %edx push %esi #endif +#if defined MS_x86_64_ABI + push %rdi + push %rsi + mov %rcx, %rdi + mov %rdx, %rsi +#endif movl $512, CTR3 /* Number of rounds */ movdqa (0*16)(PTR1), %xmm0 @@ -283,6 +328,10 @@ offset = offset + 16 pop %esi pop %ebp #endif +#if defined MS_x86_64_ABI + pop %rsi + pop %rdi +#endif ret ENDPROC(x86_aes_mangle) @@ -295,6 +344,11 @@ ENTRY(x86_aes_expand_key) mov %esp, %ebp movl 8(%ebp), %eax #endif +#if defined MS_x86_64_ABI + push %rdi + push %rsi + mov %rcx, %rdi +#endif SETPTR(aes_round_keys, PTR1) movdqu (PTR0), %xmm0 @@ -325,6 +379,10 @@ ENTRY(x86_aes_expand_key) #ifdef __i386__ pop %ebp #endif +#if defined MS_x86_64_ABI + pop %rsi + pop %rdi +#endif ret 1: @@ -347,12 +405,16 @@ ENDPROC(x86_aes_expand_key) .balign 64 aes_round_keys: .space 11*16 +#if defined ELF_DEBUG_INFO .size aes_round_keys, .-aes_round_keys +#endif /* ELF_DEBUG_INFO */ #endif /* i386 or x86_64 */ +#if defined ELF_DEBUG_INFO /* * This is necessary to keep the whole executable * from needing a writable stack. */ .section .note.GNU-stack,"",%progbits +#endif /* ELF_DEBUG_INFO */ diff -rup origsrc/rng-tools-5/rngd_linux.c src/rng-tools-5/rngd_linux.c --- origsrc/rng-tools-5/rngd_linux.c 2012-08-06 19:04:12.000000000 +0200 +++ src/rng-tools-5/rngd_linux.c 2014-08-09 15:09:21.081616358 +0200 @@ -39,8 +39,10 @@ #include #include #include +#ifndef __CYGWIN__ #include #include +#endif #include #include "rngd.h" @@ -130,11 +132,19 @@ void random_add_entropy(void *buf, size_ entropy.size = size; memcpy(entropy.data, buf, size); +#ifdef __CYGWIN__ + if (write(random_fd, entropy.data, size) != size) { + message(LOG_DAEMON|LOG_ERR, "Add Entropy failed: %s\n", + strerror(errno)); + exit(1); + } +#else if (ioctl(random_fd, RNDADDENTROPY, &entropy) != 0) { message(LOG_DAEMON|LOG_ERR, "RNDADDENTROPY failed: %s\n", strerror(errno)); exit(1); } +#endif } void random_sleep(void)