Re: [Cfrg] [TLS] NIST crypto group and HKDF (and therefore TLS 1.3)

"Blumenthal, Uri - 0553 - MITLL" <uri@ll.mit.edu> Sun, 17 May 2020 05:55 UTC

Return-Path: <prvs=2406509d9f=uri@ll.mit.edu>
X-Original-To: cfrg@ietfa.amsl.com
Delivered-To: cfrg@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 12DD53A0D90 for <cfrg@ietfa.amsl.com>; Sat, 16 May 2020 22:55:04 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.005
X-Spam-Level:
X-Spam-Status: No, score=0.005 tagged_above=-999 required=5 tests=[MIME_QP_LONG_LINE=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ztyg-zaFool2 for <cfrg@ietfa.amsl.com>; Sat, 16 May 2020 22:55:00 -0700 (PDT)
Received: from llmx2.ll.mit.edu (LLMX2.LL.MIT.EDU [129.55.12.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id CAD593A0D91 for <cfrg@ietf.org>; Sat, 16 May 2020 22:54:59 -0700 (PDT)
Received: from LLE2K16-MBX03.mitll.ad.local (LLE2K16-MBX03.mitll.ad.local) by llmx2.ll.mit.edu (unknown) with ESMTPS id 04H5stft040143; Sun, 17 May 2020 01:54:55 -0400
From: "Blumenthal, Uri - 0553 - MITLL" <uri@ll.mit.edu>
To: Hugo Krawczyk <hugo@ee.technion.ac.il>, "Dang, Quynh H. (Fed)" <quynh.dang@nist.gov>
CC: "cfrg@ietf.org" <cfrg@ietf.org>
Thread-Topic: [Cfrg] [TLS] NIST crypto group and HKDF (and therefore TLS 1.3)
Thread-Index: AQHWKM8GOuKZQPWunkG5m0pxBcxVp6il95OAgAB+sICAAA3rAIABZhuA///E4ACABB6XgA==
Date: Sun, 17 May 2020 05:54:54 +0000
Message-ID: <4ADC83F4-A499-4087-92E2-7E403E2D933A@ll.mit.edu>
References: <BY5PR09MB475561E56BE81B75DE9908F4F3BE0@BY5PR09MB4755.namprd09.prod.outlook.com> <24CF244F-83C8-4771-9E37-B851DC5013BC@ll.mit.edu> <CADi0yUOOMjQhQoqKSHPkPtEWO0J6PC0p_JtQ_K1eLWyNXs-_sg@mail.gmail.com> <C1F5C430-C382-4045-8A1E-CCC621A64306@ll.mit.edu> <CADi0yUO_ETqyERFG=L0L_Dmh1sOwa1t-ryHcaQNvxfh22WEN+Q@mail.gmail.com> <BY5PR09MB47554F85238CC16DB6566354F3BF0@BY5PR09MB4755.namprd09.prod.outlook.com> <CADi0yUNTBiYHECsbqj6Q=x8OEr5NyBjrTWqT8xn8O8GryvANJA@mail.gmail.com> <E0EF208D-AC06-4993-884F-7ED71CD647CE@ll.mit.edu>
In-Reply-To: <E0EF208D-AC06-4993-884F-7ED71CD647CE@ll.mit.edu>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
user-agent: Microsoft-MacOutlook/16.36.20041300
x-originating-ip: [172.25.1.90]
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg="sha256"; boundary="B_3672525293_1444375900"
MIME-Version: 1.0
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-17_01:2020-05-15, 2020-05-17 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2004280000 definitions=main-2005170052
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/H8k7o9CpQ-piVuDjeg2-qqWedQU>
Subject: Re: [Cfrg] [TLS] NIST crypto group and HKDF (and therefore TLS 1.3)
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Crypto Forum Research Group <cfrg.irtf.org>
List-Unsubscribe: <https://www.irtf.org/mailman/options/cfrg>, <mailto:cfrg-request@irtf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cfrg/>
List-Post: <mailto:cfrg@irtf.org>
List-Help: <mailto:cfrg-request@irtf.org?subject=help>
List-Subscribe: <https://www.irtf.org/mailman/listinfo/cfrg>, <mailto:cfrg-request@irtf.org?subject=subscribe>
X-List-Received-Date: Sun, 17 May 2020 05:55:04 -0000

After some private discussion with Hugo and analyzing my use case, it appears that I won’t need to reverse the HKDF inputs after all.


To recap my use case: I have an HSM with pre-loaded/pre-shared symmetric keys (of good quality). 

I need to:
  a. derive new symmetric keys from those pre-shared, using non-secret non-random input
  b. derive new symmetric keys from the output of ephemeral (asymmetric) Key Exchange

HSM doesn't directly support KDF of any kind, but supports HMAC. So my best hope for KDF is HKDF that I construct manually from the HSM-provided primitive (HMAC).

For (a) I can construct HKDF by manually invoking (this description is a simplification) HSM HMAC(key=pre-shared-key, data=my-non-random-data). That would be compliant with RFC 5869 because I'm deriving from a strong key - therefore it's OK to skip HKDF-Extract step and proceed directly to HKDF-Extract (all the HKDF security proofs apply).

For (b) I construct HKDF by manually invoking HSM HMAC(key=pre-shared-key, data=EDH-output) - with more invocations, of course, but that's the essence. In the HKDF-Extract step I'm replacing random salt (or salt of all zeroes) with a strong secret - which is even better than using random salt. Again, all the security proofs apply.

If my pre-shared keys weren't strong, the above would not work wrt. the current KHDF security assumptions & proofs.

TNX!





From: Cfrg <cfrg-bounces@irtf.org> on behalf of Uri Blumenthal <uri@ll.mit.edu>

Date: Thursday, May 14, 2020 at 11:01

To: Hugo Krawczyk <hugo@ee.technion.ac.il>, "Dang, Quynh H. (Fed)" <quynh.dang@nist.gov>

Cc: "cfrg@ietf.org" <cfrg@ietf.org>

Subject: Re: [Cfrg] [TLS] NIST crypto group and HKDF (and therefore TLS 1.3)



When the IKM is longer than 1 block, it gets hashed iteratively by the compression function in Merkle-Damgard fashion (the hash function). Then, this hashed result is padded to become a full block, then Xor with opad and ipad (making input blocks are "independent"/different blocks/keys.  One of these Xored values is hashed with the salt, then its result and the other Xored value get hashed one more time by the iterative MD-hash function. 



I dont understand why any extraction property that you get from the traditional extraction gets lost by this alternative method. 



The only way I know to justify this step in general is to assume the underlying hash function is a RO which is general is not, due to extension attacks. 



Can you please explain: what is the significance of extension attacks in this context? 

KDF is not a MAC. And while it’s nice to have a construction as generic as possible – sometimes it helps to narrow the applicability scope, because the generic version may be too limiting for that specific use case.



This would make the analysis fully dependent on RO while the analysis of HKDF can use less stringent modeling depending on particular cases.



Thank you. One conclusion I draw form this is – since extension attacks do not seem to apply/matter for the Key Derivation, it is reasonably safe to model the entire hash function as RO. Therefore, the proposed option appears to be safe.



For me, it is less important to stay generic than to be able to employ currently-available commercial HSM. For that use case, modeling hash function (even SHA-2) as RO seems OK.



I don't know how you do that if the only input to the function is an initial hash value of the IKM.



When the IKM is not more than an input block, then each of  the 2 Xored values gets processed by 1 compression function call which is modeled as a RO. I dont understand why this alternative method losses some extraction property from the traditional extraction function.



When the key is no longer than hash block then you would need to assume what the compression function is a PRF when keyed via a non-uniform key, essentially assuming what you need to prove.  



You can go ahead and use the reverse construction as an ad-hoc construction. However, if you want a detailed analysis such as in the case of HKDF , which is careful about lowering cryptographic assumptions, builds on the Merkle Damgard iterations (that are the basis of HMAC as PRF), is based on rich statistical extraction literature of 30+ years,  justifies the use of the function for many different settings (reflected very well in the use of HKDF in practical protocol, cf. TLS 1.3), and provides usage guidance, then I am not sure you can do it with the ad-hoc construction.



At the risk of repeating myself: while I appreciate what you’re explaining here, in my case staying with the lowest theoretic-proven cryptographic assumptions makes stuff undeployable in practice. 



I really recommend you read the paper.  As I said at the beginning of this thread, I don't want to convert this into an exposition on HKDF. For that I wrote a full paper



I think I said that I have read that paper (I suspect that Quynh did too), and (in my case) found it targeting a different audience. No offence meant – but if it were more readable, I wouldn’t have to ask my questions here.