diff options
| author | Pierre Joye <pajoye@php.net> | 2011-07-10 14:59:33 +0000 |
|---|---|---|
| committer | Pierre Joye <pajoye@php.net> | 2011-07-10 14:59:33 +0000 |
| commit | 5fb257074253f2439ddeb6d789bfca39d4937a9e (patch) | |
| tree | 1c1583234fade553abeb9373108a4bbb0f553e56 | |
| parent | 4276fd63b58823bff85a8a412a451b96dbb89374 (diff) | |
| download | php-git-5fb257074253f2439ddeb6d789bfca39d4937a9e.tar.gz | |
- use php_win32_get_random_bytes instead of over slow and partially wrong openssl's version
| -rw-r--r-- | ext/openssl/openssl.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index a36a523bff..06473744b3 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -36,6 +36,10 @@ #include "ext/standard/md5.h" #include "ext/standard/base64.h" +#if PHP_WIN32 +# include "win32/winutil.h" +#endif + /* OpenSSL includes */ #include <openssl/evp.h> #include <openssl/x509.h> @@ -4920,10 +4924,19 @@ PHP_FUNCTION(openssl_random_pseudo_bytes) buffer = emalloc(buffer_length + 1); +#ifdef PHP_WIN32 + strong_result = 1; + /* random/urandom equivalent on Windows */ + if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE){ + efree(buffer); + RETURN_FALSE; + } +#else if ((strong_result = RAND_pseudo_bytes(buffer, buffer_length)) < 0) { efree(buffer); RETURN_FALSE; } +#endif buffer[buffer_length] = 0; RETVAL_STRINGL((char *)buffer, buffer_length, 0); |
