CryptGenRandom is deprecated #14089

pull fingera wants to merge 1 commits into bitcoin:master from fingera:2-crypto-api-deprecated changing 7 files +40 −20
  1. fingera commented at 8:31 am on August 28, 2018: contributor
  2. fanquake added the label Windows on Aug 28, 2018
  3. in src/random.cpp:12 in 16f6607058 outdated
     8@@ -9,8 +9,16 @@
     9 #include <support/cleanse.h>
    10 #ifdef WIN32
    11 #include <compat.h> // for Windows API
    12-#include <wincrypt.h>
    13+#if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0601
    14+#include <bcrypt.h>
    


    laanwj commented at 8:37 am on August 28, 2018:
    so with this, it will still use the deprecated function with mingw? (which is used for the distributed binaries)
  4. in src/random.cpp:14 in 16f6607058 outdated
     8@@ -9,8 +9,16 @@
     9 #include <support/cleanse.h>
    10 #ifdef WIN32
    11 #include <compat.h> // for Windows API
    12-#include <wincrypt.h>
    13+#if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0601
    14+#include <bcrypt.h>
    15+#pragma comment(lib, "bcrypt.lib")
    


    ken2812221 commented at 9:00 am on August 28, 2018:
    You should add this into build_msvc/*/*.vcxproj and configure.ac instead of adding random library into source code. Once you update configure.ac, the #if defined(_MSC_VER)..#endif thing could be removed.
  5. in src/random.cpp:12 in 16f6607058 outdated
     8@@ -9,8 +9,16 @@
     9 #include <support/cleanse.h>
    10 #ifdef WIN32
    11 #include <compat.h> // for Windows API
    12-#include <wincrypt.h>
    13+#if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0601
    


    ken2812221 commented at 9:05 am on August 28, 2018:
    checking _WIN32_WINNT is not necessary. The min version required to run Bitcoin Core is Vista which is the same as the required min version of BCryptGenRandom
  6. fingera force-pushed on Aug 29, 2018
  7. fingera force-pushed on Aug 29, 2018
  8. fingera force-pushed on Aug 29, 2018
  9. fingera commented at 5:39 am on August 29, 2018: contributor
    thankyou, now the minimum system is windows vista
  10. ken2812221 commented at 7:19 am on August 29, 2018: contributor
    Concept ACK
  11. laanwj commented at 12:42 pm on August 29, 2018: member

    utACK on superficial code changes

    however, as random generation is critical to wallet security, someone with actual knowledge of windows random APIs should review this

  12. NicolasDorier commented at 4:36 pm on August 29, 2018: contributor
    I would be inclined to NACK, new version of .NET still depend on advapi32.dll CryptGenRandom for secure RNG. I would be more confident to use when microsoft eat their dog food.
  13. fingera commented at 6:20 am on August 30, 2018: contributor

    Windows Vista: The random number generator is based on the hash-based random number generator specified in the FIPS 186-2 standard. Windows 8: Beginning with Windows 8, the RNG algorithm supports FIPS 186-3. Keys less than or equal to 1024 bits adhere to FIPS 186-2 and keys greater than 1024 to FIPS 186-3. https://docs.microsoft.com/zh-cn/windows/desktop/SecCNG/cng-algorithm-identifiers#BCRYPT_RNG_ALGORITHM

    ok, maybe switch to bcrypt after many years?

  14. luke-jr commented at 1:10 pm on August 30, 2018: member
    Could do both?
  15. fingera commented at 1:49 am on August 31, 2018: contributor

    bitcoin random source: // First source: OpenSSL’s RNG // Second source: OS RNG // Third source: HW RNG, if available.

    OpenSSL’s RNG already append CryptGenRandom(Compile Target < Win7) OS RNG improve it, so OS RNG use new BCryptGenRandom :)

  16. sipa commented at 3:06 am on August 31, 2018: member
    We will in the near future probably remove OpenSSL as a randomness source.
  17. fingera commented at 4:51 am on August 31, 2018: contributor
    Remove randomness source must be very carefull. Can I do it? What to do now?
  18. sipa commented at 4:56 am on August 31, 2018: member

    No, we’re still relying on some of its features that need to be implemented differently first.

    I’m just pointing out that OpenSSL using some API already is not a reason to not also use it ourselves.

  19. fingera commented at 4:59 am on August 31, 2018: contributor
    Add both os source now? Or wait for Microsoft’s new API to accept more tests
  20. fingera force-pushed on Aug 31, 2018
  21. add randomness source 1e8f80d76f
  22. fingera force-pushed on Aug 31, 2018
  23. laanwj commented at 8:42 am on August 31, 2018: member
    I’m closing this for now. We can do this at some point in the future, but I agree with @NicolasDorier that it’s not relevant now.
  24. laanwj closed this on Aug 31, 2018

  25. fingera commented at 9:02 am on August 31, 2018: contributor
    ok, please read 14116
  26. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-05 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me