diff options
| author | Chris Denton <chris@chrisdenton.dev> | 2023-02-14 19:32:32 +0000 | 
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2023-03-03 09:32:47 -0800 | 
| commit | a5417512316b68f5d97150b429f56dc2334a528c (patch) | |
| tree | 1e1b20e55f013972a5d788ca6154b970110f1ad5 /library/std/src/sys/windows/c.rs | |
| parent | 40cb3f0e00ae2d5d8285ecdc58d52a14979d8f17 (diff) | |
| download | rust-a5417512316b68f5d97150b429f56dc2334a528c.tar.gz rust-a5417512316b68f5d97150b429f56dc2334a528c.zip  | |
Revert to using `RtlGenRandom`
This is required due to `BCryptGenRandom` failing to load the necessary dll on some systems. (cherry picked from commit dfd0afb991d4bfbd6fdf86adb631e428c185ac89)
Diffstat (limited to 'library/std/src/sys/windows/c.rs')
| -rw-r--r-- | library/std/src/sys/windows/c.rs | 13 | 
1 files changed, 4 insertions, 9 deletions
diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index 81461de4f72..f58dcf1287b 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -295,8 +295,6 @@ pub fn nt_success(status: NTSTATUS) -> bool { status >= 0 } -// "RNG\0" -pub const BCRYPT_RNG_ALGORITHM: &[u16] = &[b'R' as u16, b'N' as u16, b'G' as u16, 0]; pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD = 0x00000002; #[repr(C)] @@ -834,6 +832,10 @@ if #[cfg(not(target_vendor = "uwp"))] { #[link(name = "advapi32")] extern "system" { + // Forbidden when targeting UWP + #[link_name = "SystemFunction036"] + pub fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: ULONG) -> BOOLEAN; + // Allowed but unused by UWP pub fn OpenProcessToken( ProcessHandle: HANDLE, @@ -1258,13 +1260,6 @@ extern "system" { cbBuffer: ULONG, dwFlags: ULONG, ) -> NTSTATUS; - pub fn BCryptOpenAlgorithmProvider( - phalgorithm: *mut BCRYPT_ALG_HANDLE, - pszAlgId: LPCWSTR, - pszimplementation: LPCWSTR, - dwflags: ULONG, - ) -> NTSTATUS; - pub fn BCryptCloseAlgorithmProvider(hAlgorithm: BCRYPT_ALG_HANDLE, dwFlags: ULONG) -> NTSTATUS; } // Functions that aren't available on every version of Windows that we support,  | 
