Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98156 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11897 invoked from network); 3 Feb 2017 23:56:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2017 23:56:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.174 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.213.174 mail-yb0-f174.google.com Received: from [209.85.213.174] ([209.85.213.174:36308] helo=mail-yb0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/DA-38491-1C815985 for ; Fri, 03 Feb 2017 18:56:50 -0500 Received: by mail-yb0-f174.google.com with SMTP id 123so10777738ybe.3 for ; Fri, 03 Feb 2017 15:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=W/n3Bk7RQDPt4DRuEtMawQJySd5eRQdN0rUl5FXqK3Y=; b=vRDoH/nGgDwYpuVX53+gA+ckdtgaRdVDFBDLfrM6/CQIJ0TG6KejsXD10p9n0EZxLO kvasXfDAGGkwLXrfvbR13kFI+b1yYI23hrMlNJKaD9LKWpOUwWq7+09Q9IEXZjcP8q2L v5OVMWbCOorCXAZ9og5cFcigaIG9lvLfjV/Fo8KjvCOd0m+aHE5jGPomKvYYuKgZYSti x6k5HbSbF5SVlnw4QApJmYHPZzDcrUXcqQpakfDDKmjNDecnEo3jY+wFuoXCSZ1b4wjL 8sCOUFXlM7+nHJ9QKnlJHYwwv/qTMxPY+kqQ40t1YDmlgArlfp5E96m4Yew+Hsdrjwk0 fmQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=W/n3Bk7RQDPt4DRuEtMawQJySd5eRQdN0rUl5FXqK3Y=; b=LqcDFvcMj7lsX+wJ8uJMIF1Npd6uFNXP87VmMNJb8jNWg+NDenRaf0mrujHJgLHOZR DN3vXGLLkb+nEBVbp1n3kGuRlNqQytACP+tbuf/uZlGVCZ25YQIiR6BgrI2gwNUHgvrw xx3j/OBsBTYjTqRKeM3XCNkYKm336w8OiASNV1EviDaKS01l53y5TOo5sw0FAto9eFHN MDQ4d6AHx/yGXMQRW7TrZnsKmmbstA+iZrbp2YwGORXb30VbS9cwC0mmerAVO6AjLRrH 4qBnv+IeTMTnOUHKfCJszzI2ubeuds6VIioF5uSrJRqhaxGVwgvwpTWatGSIegjeBJHg 8ntA== X-Gm-Message-State: AIkVDXJUd87dzqF0bT+pdbAAGHLLFHgH2iRMe7mz5fLfXBKSvBTLjR904XpZDjmGDg0W3+T3hvoB6ox3ggQXkQ== X-Received: by 10.37.173.1 with SMTP id y1mr7796001ybi.140.1486166207304; Fri, 03 Feb 2017 15:56:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.80.215 with HTTP; Fri, 3 Feb 2017 15:56:46 -0800 (PST) In-Reply-To: References: Date: Sat, 4 Feb 2017 00:56:46 +0100 Message-ID: To: Yasuo Ohgaki Cc: Andrey Andreev , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f403045dc5d2dd1b070547a9083c Subject: Re: [PHP-DEV] [Discussion] HKDF From: nikita.ppv@gmail.com (Nikita Popov) --f403045dc5d2dd1b070547a9083c Content-Type: text/plain; charset=UTF-8 On Sat, Feb 4, 2017 at 12:01 AM, Yasuo Ohgaki wrote: > Hi all, > > On Tue, Jan 17, 2017 at 4:01 PM, Yasuo Ohgaki wrote: > > > On Mon, Jan 16, 2017 at 8:16 PM, Andrey Andreev > wrote: > > > >> > >> On Mon, Jan 16, 2017 at 3:47 AM, Yasuo Ohgaki > wrote: > >> > >>> Nice function, I like it. > >>> Modified patch is committed to master > >>> http://git.php.net/?p=php-src.git;a=commitdiff;h=4bf7ef08061 > >>> 720586cb0a2f410720e26719d97f3 > >>> > >>> I have 2 improvement ideas. > >>> > >>> > >>> > >>> 1) Make salt parameter required. > >>> > >>> Current hash_hkdf() has this signature. > >>> > >>> proto string hash_hkdf(string algo, string ikm [, int length = 0, > string > >>> info = '', string salt = '']) > >>> > >>> I posted inline comment to PR so that make hkdf stronger, but it seems > >>> it was overlooked. > >>> > >>> RFC 5869 Section 3.1 states > >>> > >>> HKDF is defined to operate with and without random salt. This is > >>> done to accommodate applications where a salt value is not > available. > >>> We stress, however, that the use of salt adds significantly to the > >>> strength of HKDF, ensuring independence between different uses of > the > >>> hash function, supporting "source-independent" extraction, and > >>> strengthening the analytical results that back the HKDF design. > >>> > >>> > >>> *SNIP > >>> > >>> It is worth noting that, while not the typical case, some > >>> applications may even have a secret salt value available for use; in > >>> such a case, HKDF provides an even stronger security guarantee. > >>> > >>> > >>> > >> There's no comment from you on the PR, inline or not, but I can assure > >> you this was not overlooked. > >> > > > > I did inline comment. Nikita remembered at least. > > It seems I didn't get notification email, though. > > > > If it is static and known - it is not random. On the other hand, if you > >> wanted to generate it on the fly - it would be unusable as the output > >> wouldn't be reproducible > >> Section 3.1 of RC 5869 that you quoted above is advice for application > >> developers; it is NOT a description of how the function should be > >> implemented as a primitive. > >> > > > > It is only for general dictionary not to work. > > I don't mind at all not to have static hard coded salt. > > Let's not have it. > > > > 1. Warn obsolete hash function usage. e.g. md2() > >>> > >>> > >> I'd be in favor of such a warning, but only if 1) we're talking about > ALL > >> of ext/hash and not just this function; and 2) it's just an E_WARNING > and > >> doesn't actually block the functionality, for BC reasons. > >> > > > > > >> > >>> 2. When new hash function is added and blacklist update is > >>> forgotten, whitelist mitigate it. > >>> (We are better to have .phpt for it to notify problem to new hash > >>> function author) > >>> > >>> > >> This is a 2-edged sword that can also restrict usage of newly introduced > >> but *more secure* hashes - I don't think it's a good idea. > >> > > > > > >> > >>> 3. Raise E_RECOVEREABLE _ERROR for blacklisted hashes. > >>> Note: Blacklisted hash usage results in returning FALSE. This may > >>> result in very weak encryption/etc with @ operator, for example. > >>> > >>> > >> Depends on what you mean ... For non-cryptographic hashes - meh, I don't > >> care; for those that are considered obsolete - no thanks. > >> > > > > Letting not to use invalid hashes (E_RECOVERABLE_ERROR) make sense > because > > it is new function. > > > > As time goes by, we may have additional blacklisted hashes. hash_hkdf() > > returns FALSE for bad hashes and the return value must never be used as > > key. Since the return value must never be used, users must update code > > regardless of raised error type. > > > > Therefore, E_RECOVERABLE _ERROR makes sense. It prevents sloppy error > > event fix like '@hash_hkdf()' also. > > > > More secure hash must be listed in the whitelist. > > Properly written .phpt will help new hash function authors to notice not > > updated whitelist/blacklist. > > > > I'm not going to add whitelist since it could be handled in other places. > > i.e. Nikita's post. Let's forget about whitelisting. > > > > Issue is error type for blacklist error. Do you still think > > E_RECOVERABLE_ERROR is better? > > > >> > > > >> > >> > >>> > >>> > >>> Comments are appreciated. > >>> If there is no comment, I'll work on these improvements hopefully soon. > >>> > >>> > >> This is not the first time you go ahead with your ideas like that ... > >> There have been BC breaks in ext/session because of this approach, and I > >> remember at least one instance of an RM having to revert your frivolous > >> commits. > >> Please don't do that. > >> > > > > I don't aware of ext/session issue, but there was uniqid() issue. > > > > uniqid()'s entropy discussion was spoiled by totally wrong FUD and patch > > was reverted. > > I restarted the discussion recently and uniqid() will have proper entropy > > for it soon because nobody objects use of better PRNG this time. > > > > Anyway, I wrote why we should make "salt" a required parameter in reply > to > > NIkita's post. If you still think it should not, please explain the > reason > > why. > > > > > Did everyone understand why I propose salt as required parameter and > specify optional salt explicitly? > > HKDF w/o salt is OK, but with salt, it's much stronger than w/o it. > In addition, most use case with PHP is something like as follows: > > 1. Get password hash for the user > 2. Generate new key with 1 using HKDF > 3. Use key produced by 2 for encryption/etc > > If there is no salt in 2, simple SQL injection will allow attackers to > decrypt all of encrypted users data. > Note: Salt should be stored other place. e.g. In config file, other db, > etc. > > I'll prepare patch if there is no more comments. > You are free to prepare a patch, but your patch will not get merged. Your blatant disregard of any and all feedback you receive on your proposals is beginning to get on my nerves. This has played out again and again, most recently in the thread on mt_rand() seeding. Here again, you make a suggestion, you get two responses, both telling you that your suggestion is not acceptable, and what conclusion do you draw from this? Why, of course, let's land it anyway! If people stop replying to your mails, the reason is not that they have been convinced by your arguments. The reason is that they have realized the pointlessness of the debate. Regards, Nikita --f403045dc5d2dd1b070547a9083c--