-
-
Notifications
You must be signed in to change notification settings - Fork 707
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
Make unpredictableSeed
use CryptGenRandom
(CryptoAPI) on Windows
#10624
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request, @0xEAB! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#10624" |
a3b6342
to
499bfa0
Compare
20c2a61
to
345d936
Compare
std/random.d
Outdated
import core.sys.windows.wincrypt : | ||
CryptAcquireContext, | ||
CryptGenRandom, | ||
CryptReleaseContext, | ||
CRYPT_VERIFYCONTEXT, | ||
MS_STRONG_PROV, | ||
PROV_RSA_FULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blame D-Scanner for this monstrosity :)
345d936
to
9a3cdea
Compare
I was pretty surprised that DRuntime didn't already have BCrypt bindings. It shouldn't be much work for me to add them. What do you think? |
Yes please. |
Will do. EDIT: found it |
This patch changes
unpredictableSeed
to callCryptGenRandom
on Windows.Analogous to #10623 (Linux).
On the one hand, the legacy CryptoAPI might be deprecated, on the other hand using it does not introduce a new DLL dependency.
advapi32
is already required bystd.registry
and Phobos is linked against as seen in the currentMakefile
.Using the more modern CNG (
BCryptGenRandom
) would not only introduce a new dependency, but also require us to add the corresponding bindings to druntime. I figured that wouldn’t be worth the effort for now.