Re: svn: /php/php-src/ branches/PHP_5_4/ext/openssl/openssl.c trunk/ext/openssl/openssl.c
| From: | Hannes Magnusson | Date: | Mon, 12 Sep 2011 10:08:35 +0000 |
| Subject: | Re: svn: /php/php-src/ branches/PHP_5_4/ext/openssl/openssl.c trunk/ext/openssl/openssl.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-66435@lists.php.net to get a copy of this message | ||
On Sun, Jul 10, 2011 at 16:59, Pierre Joye <pajoye@php.net> wrote:
> pajoye Sun, 10 Jul 2011 14:59:33 +0000
>
> Revision:
> http://svn.php.net/viewvc?view=revision&revision=313112
>
> Log:
> - use php_win32_get_random_bytes instead of over slow and partially wrong openssl's
> version
>
> Changed paths:
> U php/php-src/branches/PHP_5_4/ext/openssl/openssl.c
> U php/php-src/trunk/ext/openssl/openssl.c
>
> Modified: php/php-src/branches/PHP_5_4/ext/openssl/openssl.c
> ===================================================================
> --- php/php-src/branches/PHP_5_4/ext/openssl/openssl.c 2011-07-10 14:37:12 UTC (rev 313111)
> +++ php/php-src/branches/PHP_5_4/ext/openssl/openssl.c 2011-07-10 14:59:33 UTC (rev 313112)
> @@ -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 @@
>
> 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);
>
> Modified: php/php-src/trunk/ext/openssl/openssl.c
> ===================================================================
> --- php/php-src/trunk/ext/openssl/openssl.c 2011-07-10 14:37:12 UTC (rev 313111)
> +++ php/php-src/trunk/ext/openssl/openssl.c 2011-07-10 14:59:33 UTC (rev 313112)
> @@ -4920,10 +4920,19 @@
>
> 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);
>
>
You don't need win32/winutil.h in trunk?
-Hannes