From 60cc37630fa8bb080b10d9916c78fe2f4dd845ec Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 26 Jul 2022 14:31:56 +0200 Subject: [PATCH] Drop Windows specific implementation of openssl_random_pseudo_bytes() Despite commit 69c3f8c[1] claiming otherwise, there is no need for any Windows specific implementation here. Users can use random_bytes(), if they desire so. [1] Closes GH-9153. --- ext/openssl/openssl.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index e8752f5d3a7..7fa6664e183 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -7652,15 +7652,6 @@ PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long buffer_le } buffer = zend_string_alloc(buffer_length, 0); -#ifdef PHP_WIN32 - /* random/urandom equivalent on Windows */ - if (php_win32_get_random_bytes((unsigned char*)(buffer)->val, (size_t) buffer_length) == FAILURE){ - zend_string_release_ex(buffer, 0); - zend_throw_exception(zend_ce_exception, "Error reading from source device", 0); - return NULL; - } -#else - PHP_OPENSSL_CHECK_LONG_TO_INT_NULL_RETURN(buffer_length, length); PHP_OPENSSL_RAND_ADD_TIME(); if (RAND_bytes((unsigned char*)ZSTR_VAL(buffer), (int)buffer_length) <= 0) { @@ -7670,7 +7661,7 @@ PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long buffer_le } else { php_openssl_store_errors(); } -#endif + return buffer; }