dsprenkels / randombytes

A portable C library for generating cypto-secure random bytes
MIT License
96 stars 37 forks source link

Add BCryptGenRandom for WINVER >= 0x0600 #43

Open raidenluikang opened 1 year ago

raidenluikang commented 1 year ago

For Windows Vista and newer versions available bcrypt.h and BCryptGenRandom - which recommend in newer os.

Could add it ?

And add more macro for detection Windows, for ex., boost predef uses these macros:

_WIN32 _WIN64 __WIN32__ __TOS_WIN__ __WINDOWS__

dsprenkels commented 1 year ago

Thank you for the heads-up! I agree that this should indeed happen.

Reference material:

Steps:

@raidenluikang I am going to open an separate issue for the extra requested macro detection, if you're all right with that.

DogeProtocol commented 9 months ago

We came up with an implementation (lines 82 to 125)

BCryptGenRandom and fallback to CryptAcquireContext

https://github.com/DogeProtocol/hybrid-pqc/blob/main/random/randombytes.c

DogeProtocol commented 9 months ago

CryptAcquireContext is deprecated and will be removed from new versions of Windows as per Microsoft documentation