Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60883 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85373 invoked from network); 18 Jun 2012 18:04:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2012 18:04:37 -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 209.85.216.47 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.47 mail-qa0-f47.google.com Received: from [209.85.216.47] ([209.85.216.47:52749] helo=mail-qa0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/F5-50426-4BD6FDF4 for ; Mon, 18 Jun 2012 14:04:36 -0400 Received: by qabg1 with SMTP id g1so1517028qab.13 for ; Mon, 18 Jun 2012 11:04:33 -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; bh=5qpsqmVInw84MoyFRpo4oJXWLTczPo4rBxU/9JdT1rk=; b=qTziB44FT5I7vAzqS2pErjFgHk0utvaeJ8ZMZT6/Me8wm3EIYnME9TZLH7zmZNcmeJ vQ3SIi5iSgbOVmG2f4EYWjvjG7VQl3lzgl286k+wnnssk77HmV5QoGEd7b+9WxMkobKY 5tTlA2pZFcAtmx0P4T58RQzPrilN52C411bN+o1LS5k6f6hKDXFGsQIzZO9pSwNAdlia sK5U0fzzBkYRgY8XubeDqpBk7olKsyArVkYi0im0jwgwmI37/gAuedNR7eFPN4s0Vmtu cQuGzdDkSnmWCBu+rDCGvoFMfolMrKMgvP7hii0VpmCUpTJUXkl6aLJM6mi+I3O6Iax0 N87Q== MIME-Version: 1.0 Received: by 10.224.179.6 with SMTP id bo6mr11187419qab.17.1340042673808; Mon, 18 Jun 2012 11:04:33 -0700 (PDT) Received: by 10.229.232.11 with HTTP; Mon, 18 Jun 2012 11:04:33 -0700 (PDT) In-Reply-To: References: <8714BC2A-45E2-4303-9769-8399AF316159@gmail.com> <3B162E01-67F6-4684-ACE7-40CAF73E9DC3@gmail.com> Date: Mon, 18 Jun 2012 14:04:33 -0400 Message-ID: To: Enrico Zimuel Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Adding a simple API for secure password hashing? From: ircmaxell@gmail.com (Anthony Ferrara) Enrico > I like your idea to offer a wrapper of crypt() with a better API > (actually I used this approach in the ZF2 project: > https://github.com/zendframework/zf2/blob/master/library/Zend/Crypt/Password/Bcrypt.php). Yeah, crypt() is really nice, and offers a lot of good things out of the box. It's just the salt generation and error handling that are a pita... > I think we should also support the user's salt as option and generate > a random salt if not provided. Yeah, that could be good. The only part we'd need to be careful of is error checking the salt (correct length, correct format, etc). But in general I like the idea... > For the random generation I suggest to use as first option the > openssl_random_pseudo_bytes() that is considered more secure compared > with mcrypt_create_iv($size, MCRYPT_DEV_URANDOM). Well, the point wasn't to make a CS secure salt. We've already had discussions on that (it's not needed, and can harm the system to try to use CS salts). All salts need to be is unique (statistically unique is usually good enough). If people really want to use a CS salt, they should pass one in as the user-generated salt. But I'd really like to voice my opposition to having this function default to CS secure salt generation... > I just wrote that changes here: https://gist.github.com/2949592 Looks good to me otherwise. I expanded my original gist a bit to add in the ability to register your own algorithm: https://gist.github.com/2949382 That way, existing projects that use things like PHPASS can register their own handler, and move towards this (let the fallback happen in password_validate instead of in user code). If we're going to go with this option (the series of functions), what do you think of putting them under spl: \SPL\password_create() \SPL\password_validate() \SPL\password_register_algo() \SPL\password_create_salt() Instead of doing it class based as was originally suggested? The reason for namespacing is that password_validate is used in the wild (not by many: http://www.koders.com/default.aspx?s=%22password_validate%28%22&search.x=0&search.y=0&la=PHP&li=*&scope= ) Anthony