]> granicus.if.org Git - php/commitdiff
- fix bug #55169, mcrypt_create_iv always fails to gather sufficient random data
authorPierre Joye <pajoye@php.net>
Sun, 10 Jul 2011 14:36:32 +0000 (14:36 +0000)
committerPierre Joye <pajoye@php.net>
Sun, 10 Jul 2011 14:36:32 +0000 (14:36 +0000)
win32/winutil.c

index dae01584a94e2fa42672b05d0273709a7a5e9e42..f3043f50aae129ebdf8fc198e0494c54742095f8 100644 (file)
@@ -87,7 +87,7 @@ 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, CRYPT_MACHINE_KEYSET)) {
+               if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
                        /* Could mean that the key container does not exist, let try 
                                 again by asking for a new one */
                        if (GetLastError() == NTE_BAD_KEYSET) {
@@ -97,6 +97,8 @@ PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) {  /* {{{
                                        has_crypto_ctx = 0;
                                }
                        }
+               } else {
+                       has_crypto_ctx = 1;
                }
        }