Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98256 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11850 invoked from network); 8 Feb 2017 09:17:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2017 09:17:17 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:36966] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 00/70-33872-A12EA985 for ; Wed, 08 Feb 2017 04:17:16 -0500 Received: (qmail 109764 invoked by uid 89); 8 Feb 2017 09:17:10 -0000 Received: from unknown (HELO mail-qk0-f182.google.com) (yohgaki@ohgaki.net@209.85.220.182) by 0 with ESMTPA; 8 Feb 2017 09:17:10 -0000 Received: by mail-qk0-f182.google.com with SMTP id u25so115351249qki.2 for ; Wed, 08 Feb 2017 01:17:09 -0800 (PST) X-Gm-Message-State: AMke39mEEduN8jxXT2j4a6ispg5NOcivUoCte0FvSiUin9CZR6Sn8WueBY8GCYfZ/QyFx4vNsSOvtpozCTaq2Q== X-Received: by 10.55.19.66 with SMTP id d63mr18199218qkh.73.1486545423933; Wed, 08 Feb 2017 01:17:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.19.232 with HTTP; Wed, 8 Feb 2017 01:16:23 -0800 (PST) In-Reply-To: References: Date: Wed, 8 Feb 2017 18:16:23 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Scott Arciszewski Cc: "internals@lists.php.net" , Andrey Andreev , Nikita Popov Content-Type: multipart/alternative; boundary=001a114018d8efad6a05480153b1 Subject: Re: [PHP-DEV] hash_hkdf() signature From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a114018d8efad6a05480153b1 Content-Type: text/plain; charset=UTF-8 Hi Scott, On Wed, Feb 8, 2017 at 5:22 AM, Scott Arciszewski wrote: > > One such real-world use case: Defuse v1 used HKDF without a salt. > > https://github.com/defuse/php-encryption/blob/ > b87737b2eec06b13f025cabea847338fa203d1b4/Crypto.php#L157-L170 > https://github.com/defuse/php-encryption/blob/ > b87737b2eec06b13f025cabea847338fa203d1b4/Crypto.php#L358 > > In version 2, we included a 32-byte random salt for each encryption, which > was stored next to the AES-256-CTR nonce in the ciphertext. (Both the nonce > and HKDF-salt, as well as the version information header, are covered by > the HMAC of the ciphertext.) > > The end result: Instead of having to worry about birthday collisions after > you've seen 2^64 AES outputs (because 128-bit randomly generated nonce), > now you need 2^192 before you have a useful collision. > > Although the RFC itself says that salts are optional, the argument to make > them required in PHP's implementation has merit. The only downside is: If > you're integrating with an implementation that doesn't require salts, and > the application doesn't use salts, you're out of luck. Is that enough of a > downside to dismiss an argument for better security? Maybe. > There are applications that do not require salt. In this case, all users has to do is $salt = NULL to omit $salt. Current signature has $length as the first optional parameter which would be set to "0" in many cases if not most. i.e. Just deriving new key from strong $ikm would not be typical. Requiring "$salt = NULL" to omit salt would not hurt API use much compare to current signature that requires "$length = 0" for most cases, I suppose. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a114018d8efad6a05480153b1--