Use ProcessPrng in RNG_SystemRNG in freebl on Windows
Categories
(NSS :: Libraries, enhancement, P2)
Tracking
(nss 3.126)
| Tracking | Status | |
|---|---|---|
| nss | --- | 3.126 |
People
(Reporter: bobowen, Assigned: bobowen)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
RNG_SystemRNG currently uses RtlGenRandom.
This is bound to advapi32!SystemFunction036, which just forwards to cryptbase!SystemFunction036, which in turn just wraps bcryptprimitives!ProcessPrng.
RtlGenRandom is deprecated.
If we load and call ProcessPrng (which is available win8+) directly from bcryptprimitives.dll, we can also avoid loading cryptbase.dll.
We would still need a fallback to RtlGenRandom to maintain compatibility with Windows 7 and XP.
Rust and Chromium have already switched to using ProcessPrng instead of RtlGenRandom.
Updated•3 months ago
|
| Assignee | ||
Comment 1•2 months ago
|
||
| Assignee | ||
Comment 2•2 months ago
|
||
SystemFunction036 (RtlGenRandom) is deprecated. In advapi32.dll it is a
forwarded export to CRYPTBASE.SystemFunction036, which then calls ProcessPrng
from bcryptprimitives.dll, so calling it loads cryptbase.dll unnecessarily.
ProcessPrng is also one of the replacement APIs suggested by the RtlGenRandom
documentation. On older Windows where ProcessPrng is unavailable, RtlGenRandom
is retained as a fallback.
Also fixed:
- PORT_SetError(SEC_ERROR_NEED_RANDOM) is now called on RNG failure as stated by
the contract in secrng.h - RtlGenRandom takes ULONG (32-bit) while RNG_SystemRNG takes size_t, the call
is now guarded to avoid silent truncation on 64-bit builds.
Pushed by jschanck@mozilla.com:
https://hg.mozilla.org/projects/nss/rev/da9968085283
Use ProcessPrng in RNG_SystemRNG in freebl on Windows. r=nss-reviewers,jschanck
Updated•1 month ago
|
Description
•