Re: [TLS] confirming the room’s consensus: adopt HKDF PRF for TLS 1.3

Michael StJohns <msj@nthpermutation.com> Thu, 23 April 2015 17:25 UTC

Return-Path: <msj@nthpermutation.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id ADDBD1ACDCA for <tls@ietfa.amsl.com>; Thu, 23 Apr 2015 10:25:51 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.299
X-Spam-Level:
X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, MIME_8BIT_HEADER=0.3, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
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 InW0K4gdJXh7 for <tls@ietfa.amsl.com>; Thu, 23 Apr 2015 10:25:49 -0700 (PDT)
Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 607791ABB1A for <tls@ietf.org>; Thu, 23 Apr 2015 10:25:39 -0700 (PDT)
Received: by pabtp1 with SMTP id tp1so23550087pab.2 for <tls@ietf.org>; Thu, 23 Apr 2015 10:25:39 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=iil8uJMT5pzNWnGHcAgp+Td+RjJyJ8PejtgSWhIPBrE=; b=XBX55gmsSLVnROCpCUZ/SkM8hSR9P/FtGKm6N2kYy6hlwj+oouQY+XM6PdNPhIg5CL WamZaFm+Fotz7/tBjY9nKM5cVHtJlcWStL2DArjefYeshpNmDp0+EZ9DZPWEnSLrEw+U EVhMV6BfeBXpNniCpHhkbOVtTN/RVlQ4NO7fSiCz9K3BUO1qoUD2WfVO+e73lrgWFc/o B8/8rSN56biRB3Nf4gr81h3rawo+vgVyAT+aS7ZIrgXEW5AbkvqsatjQ0GcgU+ee/kd5 xrqhTl2ukpR6eZ2BAwjs4segOELOnqz5osLFj03xMKujWRQZLGwhRQ0YjW8JlNvYKFbN /Ibw==
X-Gm-Message-State: ALoCoQlqTsxDoiBNyN3lhsUNer4uUqYa2lillsfmcCg1Q61dvIlFIuSUsoQjGkuIk1+TkTILqVoZ
X-Received: by 10.68.65.106 with SMTP id w10mr7086914pbs.75.1429809939072; Thu, 23 Apr 2015 10:25:39 -0700 (PDT)
Received: from [10.90.197.114] (soi.silverspringnet.com. [74.121.22.10]) by mx.google.com with ESMTPSA id by13sm8688898pdb.37.2015.04.23.10.25.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 10:25:38 -0700 (PDT)
Message-ID: <55392B08.6020304@nthpermutation.com>
Date: Thu, 23 Apr 2015 13:25:28 -0400
From: Michael StJohns <msj@nthpermutation.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
MIME-Version: 1.0
To: Watson Ladd <watsonbladd@gmail.com>
References: <4A5C6D8F-6A28-4374-AF1F-3B202738FB1D@ieca.com> <551DDD4E.5070509@nthpermutation.com> <F7F3EB83-FEA2-477C-8810-38C49B71C977@ieca.com> <551E290D.7020207@nthpermutation.com> <55381768.8010402@nthpermutation.com> <CACsn0cm5A50dP4JDKq9R0XdB83hyzPPLQHAMnUcXFb+DCSwV7g@mail.gmail.com>
In-Reply-To: <CACsn0cm5A50dP4JDKq9R0XdB83hyzPPLQHAMnUcXFb+DCSwV7g@mail.gmail.com>
Content-Type: multipart/alternative; boundary="------------060602050604080805030104"
Archived-At: <http://mailarchive.ietf.org/arch/msg/tls/-oBOu4wLxK7Qyx0d7HzpdZhm0G8>
Cc: tls@ietf.org
Subject: Re: [TLS] =?utf-8?q?confirming_the_room=E2=80=99s_consensus=3A_adopt_?= =?utf-8?q?HKDF_PRF_for_TLS_1=2E3?=
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/tls/>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 23 Apr 2015 17:25:51 -0000

Inline

On 4/22/2015 6:00 PM, Watson Ladd wrote:
>
>
> On Apr 22, 2015 2:49 PM, "Michael StJohns" <msj@nthpermutation.com 
> <mailto:msj@nthpermutation.com>> wrote:
> >
> > I'm top posting my own post....
> >
> >
> > Sean et al:
> >
> > After spending a bit more time looking at things from the view point 
> of HSMs and cryptographic isolation, I'm now of the opinion that HKDF 
> shouldn't be specified.
> >
> > The specific issue is the difference between HDKF step 2 and the 
> SP800-108 expansion functions.   Cryptographically, these 
> specifications are close to identical except for the inclusion of a 
> mandatory length term in the mixin values. Without this term, a key 
> stream produced from the same mixins (e.g. same label, randoms etc) 
> for the same master key will be identical regardless of the length of 
> the output key(s).
> >
> > E.g. if one call to the KDF has a target key of AES128 and another 
> call to the KDF using the same master key and mixins has a target key 
> of a single octet HMAC key, the first octet of the AES key will be 
> identical to that single octet HMAC key. Using this construct with 
> increasingly longer HMAC keys (thanks to HMAC's impedance matching 
> function) will eventually reveal each and every byte of the AES key.
>
> What if the first call for the HMAC key is 128 bits, and we use a 
> broken variant?
>
> Your example demonstrates why the sane data shouldn't be used for two 
> different purposes. In fact, it's not clear to me that we can make an 
> HSM friendly design without telling the HSM which derived values are 
> exportable and which not.
>

You are exactly correct.  This needs to be part of the derivation 
information mixins.
>
> If we ensured that no value derived by HKDF ever is not used as an 
> encryption key, this would solve the problem at the cost of some pain 
> with channel binding. But this would be a very large change.
>


Not quite.  There are two things you have to be able to enforce:

1) that the same key can't be used with a KDF and a MAC function. (Since 
the underlying function for the KDF is generally a MAC function, and the 
MAC function is public data where the KDF is private....).   That 
requires strong key typing at the time the key is created along with a 
mechanism that can prevent "master keys" from being used as "integrity 
keys" (and trivially doing the same crypto functions as a MAC function 
and extracting the key stream that way).

and

2) That the same (parts of the) key expansion key stream can't be used 
for different purposes.   So I need to mix in the target types and 
lengths for the key material being produced and I ideally include 
information about whether or not the key material is extractable.

So say I'm generating a master secret from a master secret (e.g. 
pre-master to master).  I include in the KDF mixins an indication that 
the key material being produced is for a single master secret of length 
N.  If I decide instead to produce symmetric operational key material 
(e.g. AES, HMAC, CMAC), then I change the mixins to indicate 2 AES-CCM 
keys of length 128 that are non-extractable (for example)  The key 
expansion stream for the first call is completely disjoint from that 
produced by the second call and an HSM can use the mixin values to set 
its own policy bits.  But those mixins have to be well known and 
standardized.


By the way It turns out that you *can* safely derive both public and non 
public data from a key stream, but not with the current definitions.

What you do is just add an exportable public data type as a mixin 
constant.   So you do


KDF (masterKey, "generic derive", 3 items, [AES-CCM, AES-CCM, 
RANDOM_DATA], [16, 16, 32], [0,0,EXPORTABLE])

....

KDF (Key masterKey, byte[] label, int itemcount, int[] keytypes, int[] 
keyLengths, int[] flags, Key[] keys)


The info section marshalls the three different "key requests" as a 
concatention of 10 integers (count plus 3*3) and and adds that to the 
context or "info" passed in on each pass of the key expansion. All of 
these values passed in provide enforceable policy for the HSM, but 
result in a complete change in the underlying key stream if even one bit 
changes.

Mike






> >
> > In an HSM, there is no way to differentiate these two different KDF 
> calls for legitimacy.
>

"no currently implemented way to differentiate" is closer to the truth.  
We can actually make the math work to cryptographically isolate these 
two cases in a meaningful way.

> >
> > If the KDF mixes in the length of the to be output key material, 
> then any change in the length of the requested key changes the entire 
> key stream.
> >
> > I see three different approaches to fix this - 1) specify the 
> SP800-56C with SP800-108 HMAC, 2) add the length term to the HKDF RFC 
> and republish it, 3) ensure one or more length terms are included in 
> the "info" for ALL KDF calls for TLS and document why.
> >
> >
> > Mike
> >
> >
> >
> >
> >
>