Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40225 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37568 invoked from network); 3 Sep 2008 01:08:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2008 01:08:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=scott@macvicar.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=scott@macvicar.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain macvicar.net from 193.227.246.108 cause and error) X-PHP-List-Original-Sender: scott@macvicar.net X-Host-Fingerprint: 193.227.246.108 ip246-108-v193.static.x-ip.net Received: from [193.227.246.108] ([193.227.246.108:52978] helo=lovelace.midden.org.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/EE-33714-4A3EDB84 for ; Tue, 02 Sep 2008 21:08:53 -0400 Received: from macvicar.demon.co.uk ([80.177.111.173] helo=[192.168.1.100]) by lovelace.midden.org.uk with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1KagrX-0000Jt-1d for internals@lists.php.net; Wed, 03 Sep 2008 02:08:49 +0100 Message-ID: To: PHP Developers Mailing List Content-Type: multipart/mixed; boundary=Apple-Mail-5--568731158 Mime-Version: 1.0 (Apple Message framework v926) Date: Wed, 3 Sep 2008 02:08:40 +0100 X-Mailer: Apple Mail (2.926) X-Spam-Score: -4.1 X-Spam_Report: Spam detection software, running on the system "lovelace.midden.org.uk", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi All, Attached and uploaded [1] is a patch to add the OpenSSL random pseudo byte function, at the moment it will return FALSE if the bytes aren't considered cryptographically strong, I am however considering making this parameter controlled. [...] Content analysis details: (-4.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.3 AWL AWL: From: address is in the auto white-list Subject: OpenSSL random pseudo bytes From: scott@macvicar.net (Scott MacVicar) --Apple-Mail-5--568731158 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi All, Attached and uploaded [1] is a patch to add the OpenSSL random pseudo byte function, at the moment it will return FALSE if the bytes aren't considered cryptographically strong, I am however considering making this parameter controlled. Any objections to me applying this to 5.3? Scott -- [1] - http://whisky.macvicar.net/patches/openssl_prg.patch.txt --Apple-Mail-5--568731158 Content-Disposition: attachment; filename=openssl_prg.patch.txt Content-Type: text/plain; x-unix-mode=0644; name="openssl_prg.patch.txt" Content-Transfer-Encoding: 7bit Index: ext/openssl/openssl.c =================================================================== RCS file: /repository/php-src/ext/openssl/openssl.c,v retrieving revision 1.98.2.5.2.41.2.16 diff -u -r1.98.2.5.2.41.2.16 openssl.c --- ext/openssl/openssl.c 30 Jul 2008 11:59:05 -0000 1.98.2.5.2.41.2.16 +++ ext/openssl/openssl.c 3 Sep 2008 01:06:19 -0000 @@ -94,6 +94,7 @@ PHP_FUNCTION(openssl_decrypt); PHP_FUNCTION(openssl_dh_compute_key); +PHP_FUNCTION(openssl_random_pseudo_bytes); /* {{{ arginfo */ static @@ -394,6 +395,11 @@ ZEND_ARG_INFO(0, pub_key) ZEND_ARG_INFO(0, dh_key) ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_openssl_random_psuedo_bytes, 0) + ZEND_ARG_INFO(0, length) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ openssl_functions[] @@ -458,6 +464,7 @@ PHP_FE(openssl_dh_compute_key, arginfo_openssl_dh_compute_key) + PHP_FE(openssl_random_pseudo_bytes, arginfo_openssl_random_psuedo_bytes) PHP_FE(openssl_error_string, arginfo_openssl_error_string) {NULL, NULL, NULL} }; @@ -4742,6 +4749,30 @@ } /* }}} */ +/* {{{ proto string openssl_random_pseudo_bytes(integer length) + Returns a string of the length specified filled with random pseudo bytes */ +PHP_FUNCTION(openssl_random_pseudo_bytes) +{ + long buffer_length; + unsigned char *buffer = NULL; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &buffer_length) == FAILURE) { + return; + } + + if (buffer_length <= 0) { + RETURN_FALSE; + } + + buffer = emalloc(buffer_length); + if (RAND_pseudo_bytes(buffer, buffer_length) < 0) { + RETVAL_FALSE; + } else { + RETVAL_STRINGL((char *)buffer, buffer_length, 1); + } + efree(buffer); +} +/* }}} */ + /* * Local variables: * tab-width: 8 --Apple-Mail-5--568731158 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-5--568731158--