rand: use BCryptGenRandom() in UWP builds#20983
Closed
vszakats wants to merge 2 commits intocurl:masterfrom
Closed
rand: use BCryptGenRandom() in UWP builds#20983vszakats wants to merge 2 commits intocurl:masterfrom
BCryptGenRandom() in UWP builds#20983vszakats wants to merge 2 commits intocurl:masterfrom
Conversation
BCryptGenRandom() in UWP builds
72fe4fb to
b1ae914
Compare
CMAKE_SYSTEM_VERSION is only effective for MSVC, and we also need to
set this for autotools, so just stick with _WIN32_WINNT.
Necessary to enable BCryptGenRandom() in mingw-w64 headers since mingw-w64 v6.0.
```
D:/a/curl/curl/lib/rand.c:49:6: error: implicit declaration of function 'BCryptGenRandom' [-Wimplicit-function-declaration]
49 | if(BCryptGenRandom(NULL, entropy, (ULONG)length,
| ^~~~~~~~~~~~~~~
D:/a/curl/curl/lib/rand.c:49:6: error: nested extern declaration of 'BCryptGenRandom' [-Werror=nested-externs]
D:/a/curl/curl/lib/rand.c:50:22: error: 'BCRYPT_USE_SYSTEM_PREFERRED_RNG' undeclared (first use in this function)
50 | BCRYPT_USE_SYSTEM_PREFERRED_RNG) != STATUS_SUCCESS)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/a/curl/curl/lib/rand.c:50:22: note: each undeclared identifier is reported only once for each function it appears in
D:/a/curl/curl/lib/rand.c:42:26: error: 'NTSTATUS' undeclared (first use in this function); did you mean 'LSTATUS'?
42 | #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
| ^~~~~~~~
D:/a/curl/curl/lib/rand.c:50:58: note: in expansion of macro 'STATUS_SUCCESS'
50 | BCRYPT_USE_SYSTEM_PREFERRED_RNG) != STATUS_SUCCESS)
| ^~~~~~~~~~~~~~
D:/a/curl/curl/lib/rand.c:42:35: error: expected ')' before numeric constant
42 | #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
| ~ ^~~~~~~~~~~
D:/a/curl/curl/lib/rand.c:50:58: note: in expansion of macro 'STATUS_SUCCESS'
50 | BCRYPT_USE_SYSTEM_PREFERRED_RNG) != STATUS_SUCCESS)
| ^~~~~~~~~~~~~~
cc1.exe: all warnings being treated as errors
```
https://github.com/curl/curl/actions/runs/23246552140/job/67576489473?pr=20983
BCryptGenRandom() in UWP buildsBCryptGenRandom() in UWP builds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also:
CI build, to enable the
BCryptGenRandom()prototype in v6+ SDKheaders.
Ref: https://learn.microsoft.com/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
Issue raised by Codex Security
https://github.com/curl/curl/pull/20983/files?w=1