Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89016 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80783 invoked from network); 30 Oct 2015 10:57:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2015 10:57:39 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wm0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:38866] helo=mail-wm0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/31-05497-12D43365 for ; Fri, 30 Oct 2015 05:57:38 -0500 Received: by wmeg8 with SMTP id g8so8921206wme.1 for ; Fri, 30 Oct 2015 03:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=cqS+7EJOhj5efCodKZ/EoRhJ3uquxM7BCCZtpa5Hdn0=; b=xUmuADXHymthdP4Aj1gxagxw46AtcRmOK4QoEpYiKVSMek1UA8n7R6IyS2XyGFZeCY 3KCd0IHYD61NQowq359RGHk/NWdcrsAYQVeExlNDUFYRX1LtHPm967FSu3krVy1bpnEf 3kLqrD0Pg/DScj21HRzfNSnkCMjeoSQnMGnUJTQbGDdJVStOW2/TU5E4fqtV3ZD2TMOX 4r39SUnunaOxMK5vrELrNz39zeBrqMQYZb0dLf2B5QWbS6kWUeqV1RmfuiMaxnuORXhS 70WE7tm9rWfKkAydtwPMQk9f958fW+7le9QLpGntp1YMQS4jy/XRoVJ04ePsgwxBKEUg E3OQ== MIME-Version: 1.0 X-Received: by 10.28.218.72 with SMTP id r69mr2683987wmg.98.1446202654735; Fri, 30 Oct 2015 03:57:34 -0700 (PDT) Received: by 10.28.226.134 with HTTP; Fri, 30 Oct 2015 03:57:34 -0700 (PDT) In-Reply-To: <0d0b01d10b7f$5ecf4890$1c6dd9b0$@belski.net> References: <0d0b01d10b7f$5ecf4890$1c6dd9b0$@belski.net> Date: Fri, 30 Oct 2015 11:57:34 +0100 Message-ID: To: Anatol Belski Cc: "internals@lists.php.net" , Kalle Sommer Nielsen Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Password_hash salt generation refactor From: ircmaxell@gmail.com (Anthony Ferrara) All, On Tue, Oct 20, 2015 at 11:35 PM, Anatol Belski wro= te: > Hi Anthony, > >> -----Original Message----- >> From: Anthony Ferrara [mailto:ircmaxell@gmail.com] >> Sent: Monday, October 19, 2015 1:00 AM >> To: internals@lists.php.net >> Subject: [PHP-DEV] Password_hash salt generation refactor >> >> All, >> >> With PHP 7 comes random_bytes and random_int. This duplicates some of >> the logic internally that password_hash uses to generate its salt. >> >> I would like to refactor this to unify generation. I've opened a PR agai= nst >> master: https://github.com/php/php-src/pull/1585 >> >> I don't feel comfortable pulling against 7 this far into RC status. >> Perhaps wait until after it goes gold? Or should this target 7.1? It's n= ot a big >> deal in either direction. Though it does add a side-effect, where if it = can't >> gather enough entropy it will throw an exception and return failure (whe= re >> prior it would simply make a "best effort". >> >> Thoughts? >> > As much as it could be an improvement of the password_hash(), one would b= etter avoid any behavior change at this stage. I was thinking about it and = came to an idea that maybe could work for 7.0 - one should just make php_ra= ndom_bytes() that side effect free. > > Could php_random_bytes() be extended with a flag that would tell exceptio= ns to pass? Or maybe exceptions could be moved out from the php_random_byte= s() and thrown directly in the new functions that was undergoing the RFC bu= t not password_hash() ? I'd be actually for the second variant. > > That ways FAILURE would be returned, but a decision about what to do abou= t 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. Thanks Anthony