Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RandomBytes uses deprecated API (CryptAcquireContext) in Windows (use BCryptGenRandom) #524

Open
DogeProtocol opened this issue Nov 19, 2023 · 2 comments

Comments

@DogeProtocol
Copy link

The RandomBytes implementation for Windows uses CryptAcquireContext/CryptGenRandom which has been deprecated for years and has been claimed to have security risks. Microsoft has also specified in it's documentation that this API may be removed from newer version of Windows. (details below)

https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontexta
https://en.wikipedia.org/wiki/CryptGenRandom

BCryptGenRandom is the recommended option as per Microsoft
https://learn.microsoft.com/en-us/windows/win32/seccng/cng-portal
https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom

An example implementation at (not production tested):
https://github.com/DogeProtocol/hybrid-pqc/blob/main/random/randombytes.c

@thomwiggers
Copy link
Member

We're using https://github.com/dsprenkels/randombytes/, which is where this should probably be discussed instead.

@thomwiggers thomwiggers changed the title RandomBytes uses insecure and deprecated API (CryptAcquireContext) in Windows (use BCryptGenRandom) RandomBytes uses deprecated API (CryptAcquireContext) in Windows (use BCryptGenRandom) Nov 22, 2023
@thomwiggers
Copy link
Member

I don't think any known security problems exist in the currently supported versions of Windows, so I'm removing "insecure" from the title of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants