mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
- Bug #55169, improve fix, allow non interactive user, hash-like ops only usage
This commit is contained in:
parent
01607c4137
commit
96b5e69889
@ -87,11 +87,14 @@ PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) { /* {{{
|
||||
#endif
|
||||
|
||||
if (has_crypto_ctx == 0) {
|
||||
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
|
||||
/* CRYPT_VERIFYCONTEXT > only hashing&co-like use, no need to acces prv keys */
|
||||
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET|CRYPT_VERIFYCONTEXT )) {
|
||||
/* Could mean that the key container does not exist, let try
|
||||
again by asking for a new one */
|
||||
again by asking for a new one. If it fails here, it surely means that the user running
|
||||
this process does not have the permission(s) to use this container.
|
||||
*/
|
||||
if (GetLastError() == NTE_BAD_KEYSET) {
|
||||
if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
|
||||
if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET | CRYPT_MACHINE_KEYSET | CRYPT_VERIFYCONTEXT )) {
|
||||
has_crypto_ctx = 1;
|
||||
} else {
|
||||
has_crypto_ctx = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user