Skip to content

Commit

Permalink
Make the definition of LTC_WIN32_BCRYPT private
Browse files Browse the repository at this point in the history
1. It's internal anyway, so doesn't quite need to be reflected in a
   public header file.
2. This makes it easy for someone build this library to choose not
   to use BCryptGenRandom() by simply definining LTC_NO_WIN32_BCRYPT,
   which was hard to reflect in an unmodified public header file.

Alternative to libtom#653
  • Loading branch information
levitte committed Aug 22, 2024
1 parent 427ce33 commit 00708c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/headers/tomcrypt_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,6 @@ typedef unsigned long ltc_mp_digit;
# 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
* before including `tomcrypt.h` to disable this functionality.
*/
Expand Down
11 changes: 11 additions & 0 deletions src/headers/tomcrypt_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,14 @@ int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng
#else
#define LTC_BYTE(x, n) (((x) >> (8 * (n))) & 255)
#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

0 comments on commit 00708c8

Please sign in to comment.