Parcourir la source

Merge pull request #660 from levitte/no-BCryptGenRandom

Make the definition of LTC_WIN32_BCRYPT private
Steffen Jaeckel il y a 1 an
Parent
commit
c4b423f809
2 fichiers modifiés avec 11 ajouts et 4 suppressions
  1. 0 4
      src/headers/tomcrypt_cfg.h
  2. 11 0
      src/headers/tomcrypt_private.h

+ 0 - 4
src/headers/tomcrypt_cfg.h

@@ -312,10 +312,6 @@ typedef unsigned long ltc_mp_digit;
 #   endif
 #   endif
 #endif
 #endif
 
 
-#if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 && !defined(LTC_WIN32_BCRYPT)
-#   define LTC_WIN32_BCRYPT
-#endif
-
 /* Define `LTC_NO_NULL_TERMINATION_CHECK` in the user code
 /* Define `LTC_NO_NULL_TERMINATION_CHECK` in the user code
  * before including `tomcrypt.h` to disable this functionality.
  * before including `tomcrypt.h` to disable this functionality.
  */
  */

+ 11 - 0
src/headers/tomcrypt_private.h

@@ -682,3 +682,14 @@ int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng
 #else
 #else
    #define LTC_BYTE(x, n) (((x) >> (8 * (n))) & 255)
    #define LTC_BYTE(x, n) (((x) >> (8 * (n))) & 255)
 #endif
 #endif
+
+/*
+ * On Windows, choose whether to use CryptGenRandom() [older Windows versions]
+ * or BCryptGenRandom() [newer Windows versions].
+ * If CryptGenRandom() is desired, define LTC_NO_WIN32_BCRYPT when building.
+ */
+#if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
+   #if !defined(LTC_NO_WIN32_BCRYPT)
+      #define LTC_WIN32_BCRYPT
+   #endif
+#endif