Browse Source

Merge pull request #103 from libtom/fix/103

Serious bug in rng_get_bytes @ MS Windows
Steffen Jaeckel 8 years ago
parent
commit
498538f6ef
1 changed files with 6 additions and 7 deletions
  1. 6 7
      src/prngs/rng_get_bytes.c

+ 6 - 7
src/prngs/rng_get_bytes.c

@@ -55,7 +55,7 @@ static unsigned long rng_nix(unsigned char *buf, unsigned long len,
 #endif /* LTC_DEVRANDOM */
 #endif /* LTC_DEVRANDOM */
 
 
 /* on ANSI C platforms with 100 < CLOCKS_PER_SEC < 10000 */
 /* on ANSI C platforms with 100 < CLOCKS_PER_SEC < 10000 */
-#if defined(CLOCKS_PER_SEC) && !defined(WINCE)
+#if defined(CLOCKS_PER_SEC) && !defined(_WIN32_WCE)
 
 
 #define ANSI_RNG
 #define ANSI_RNG
 
 
@@ -92,11 +92,11 @@ static unsigned long rng_ansic(unsigned char *buf, unsigned long len,
 #endif
 #endif
 
 
 /* Try the Microsoft CSP */
 /* Try the Microsoft CSP */
-#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
+#if defined(_WIN32) || defined(_WIN32_WCE)
 #ifndef _WIN32_WINNT
 #ifndef _WIN32_WINNT
   #define _WIN32_WINNT 0x0400
   #define _WIN32_WINNT 0x0400
 #endif
 #endif
-#ifdef WINCE
+#ifdef _WIN32_WCE
    #define UNDER_CE
    #define UNDER_CE
    #define ARM
    #define ARM
 #endif
 #endif
@@ -141,11 +141,10 @@ unsigned long rng_get_bytes(unsigned char *out, unsigned long outlen,
 
 
    LTC_ARGCHK(out != NULL);
    LTC_ARGCHK(out != NULL);
 
 
-#if defined(LTC_DEVRANDOM)
-   x = rng_nix(out, outlen, callback);   if (x != 0) { return x; }
-#endif
-#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
+#if defined(_WIN32) || defined(_WIN32_WCE)
    x = rng_win32(out, outlen, callback); if (x != 0) { return x; }
    x = rng_win32(out, outlen, callback); if (x != 0) { return x; }
+#elif defined(LTC_DEVRANDOM)
+   x = rng_nix(out, outlen, callback);   if (x != 0) { return x; }
 #endif
 #endif
 #ifdef ANSI_RNG
 #ifdef ANSI_RNG
    x = rng_ansic(out, outlen, callback); if (x != 0) { return x; }
    x = rng_ansic(out, outlen, callback); if (x != 0) { return x; }