Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89023 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5726 invoked from network); 1 Nov 2015 16:03:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Nov 2015 16:03:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=fsb@thefsb.org; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=fsb@thefsb.org; sender-id=pass Received-SPF: pass (pb1.pair.com: domain thefsb.org designates 173.203.187.67 as permitted sender) X-PHP-List-Original-Sender: fsb@thefsb.org X-Host-Fingerprint: 173.203.187.67 smtp67.iad3a.emailsrvr.com Linux 2.6 Received: from [173.203.187.67] ([173.203.187.67:46177] helo=smtp67.iad3a.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/E6-13635-4C736365 for ; Sun, 01 Nov 2015 11:03:17 -0500 Received: from smtp17.relay.iad3a.emailsrvr.com (localhost.localdomain [127.0.0.1]) by smtp17.relay.iad3a.emailsrvr.com (SMTP Server) with ESMTP id BF176180257; Sun, 1 Nov 2015 11:03:13 -0500 (EST) Received: by smtp17.relay.iad3a.emailsrvr.com (Authenticated sender: fsb-AT-thefsb.org) with ESMTPSA id 78B0B1801CB; Sun, 1 Nov 2015 11:03:13 -0500 (EST) X-Sender-Id: fsb@thefsb.org Received: from yossy.local (c-73-4-147-142.hsd1.ma.comcast.net [73.4.147.142]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:587 (trex/5.5.4); Sun, 01 Nov 2015 11:03:13 -0500 To: Anatol Belski , 'Anthony Ferrara' References: <0d0b01d10b7f$5ecf4890$1c6dd9b0$@belski.net> <02c401d11341$dc3d9380$94b8ba80$@belski.net> Cc: internals@lists.php.net, 'Kalle Sommer Nielsen' Message-ID: <563637AB.5050203@thefsb.org> Date: Sun, 1 Nov 2015 11:02:51 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <02c401d11341$dc3d9380$94b8ba80$@belski.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Password_hash salt generation refactor From: fsb@thefsb.org (Tom Worster) On 10/30/15 2:36 PM, Anatol Belski wrote: > Hi Anthony, > >> -----Original Message----- >> From: Anthony Ferrara [mailto:ircmaxell@gmail.com] >> Sent: Friday, October 30, 2015 11:58 AM >> All, >> >> On Tue, Oct 20, 2015 at 11:35 PM, Anatol Belski >> wrote: >>> Could php_random_bytes() be extended with a flag that would tell exceptions >> to pass? Or maybe exceptions could be moved out from the >> php_random_bytes() and thrown directly in the new functions that was >> undergoing the RFC but not password_hash() ? I'd be actually for the second >> variant. >>> >>> That ways FAILURE would be returned, but a decision about what to do about >> it would be made outside. IMHO it were also useful as the API is intended to be >> exported. So for the cases where php_random_bytes() came to use as a library >> function outside immediate PHP userspace (for example in SAPI), it should not >> throw exceptions from itself. >>> >>> Do this suggestions sound eligible? >> >> >> I have created a PR for this: https://github.com/php/php-src/pull/1614 >> >> It changes the public API of the internal php_random_bytes function to have a >> third "should_throw" parameter, as well as defining two macros: >> php_random_bytes_throw(dest, len) and php_random_bytes_silent(dest, len). >> >> If this looks acceptable, it can be pulled into 7.0, and then the move for >> password_hash can be done at a later date. >> > IMHO this looks fine for 7.0. The API is new and was not exported, so no ABI breach and no behavior change when used for internal refactoring. This change to php_random_bytes() should make it easier to migrate various old stuff (e.g. Leigh proposed sessions) to the new source, and I like it for that. But silenced failure should probably not be used for anything new and it would be good if a developer refactoring an old API would comment how the new code processes FAILURE together with a justification. Could comments be included in this PR to encourage it? As it stands, this change allows hazardous use without mentioning it. Tom