Re: [TLS] HSM-friendly Key Computation

Eric Rescorla <ekr@rtfm.com> Thu, 23 April 2015 09:54 UTC

Return-Path: <ekr@rtfm.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 8FBA11A905C for <tls@ietfa.amsl.com>; Thu, 23 Apr 2015 02:54:47 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.977
X-Spam-Level:
X-Spam-Status: No, score=-1.977 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, 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 iNuDCS_mygJb for <tls@ietfa.amsl.com>; Thu, 23 Apr 2015 02:54:45 -0700 (PDT)
Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) (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 A48B91A9083 for <tls@ietf.org>; Thu, 23 Apr 2015 02:54:44 -0700 (PDT)
Received: by wgin8 with SMTP id n8so12648044wgi.0 for <tls@ietf.org>; Thu, 23 Apr 2015 02:54:43 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=KB8JI9jy+ytu55QDfBHFwL2sx/q3v+5Uch7IVlYlmh4=; b=XKCiR7BIvSwNklbrZN4SH4c2Dwo4U1c3MrKeYjyxd1EI3jwA3L1DKChMR9qKLLBbYn oCKB2wOr8GX68dglIuuUJsraCYnjI2BKfUMuJ4DnzgUeSV4ctnziyF4wFjUumiu3SRW7 IGkYXr8aPgn6OKAMNmOTB/IDL1qAf2zP9WCFp0F0FhtCbUGK10XAvvFMvwf2tAC9C/4s 1cxprp9Vu8W7Sb2I4pz/nTJFUhbBBBxSQRMpOi3VGOiAB2sAr7ZyHtTsulqsW11l/4ld a2s3q9kqyhQGEmxJyE3HAX0KL/70mwUzM9BHW1lzlx0zIHu3Y5VcUkxkh31egTJb59i1 Y1vQ==
X-Gm-Message-State: ALoCoQmMZFKtTmdepfOZmeUI0G2wbLV+rKkSPk38uNcc5FUg0xW6FpVn+RZeb8ODV78fQJ9vi4Sk
X-Received: by 10.194.173.226 with SMTP id bn2mr3823960wjc.148.1429782883421; Thu, 23 Apr 2015 02:54:43 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.27.205.87 with HTTP; Thu, 23 Apr 2015 02:54:02 -0700 (PDT)
In-Reply-To: <20150423084201.GA21246@LK-Perkele-VII>
References: <0694C3DB-FB87-42A2-BCC4-CC0F761E9A03@vigilsec.com> <9A043F3CF02CD34C8E74AC1594475C73AB000B0C@uxcn10-tdc05.UoA.auckland.ac.nz> <5533F8D6.9070500@nthpermutation.com> <20150420064243.GA7322@LK-Perkele-VII> <CANeU+ZAL6oT6tP7OcL_8j6kp4oZB9V89R-0PrCdv-N27qVb0HQ@mail.gmail.com> <20150420163755.GA15511@LK-Perkele-VII> <5537D43A.9080802@REDHAT.COM> <20150422173526.GA14496@LK-Perkele-VII> <CABcZeBPN33DM_C0sAmCTFCTdNrcQ7y7eEBcZgPe+2f1EaxtXzA@mail.gmail.com> <55381302.5030307@nthpermutation.com> <20150423084201.GA21246@LK-Perkele-VII>
From: Eric Rescorla <ekr@rtfm.com>
Date: Thu, 23 Apr 2015 05:54:02 -0400
Message-ID: <CABcZeBMcy_C0TWgOfw6480ZV28GTfEsgABf5b9-hKPbRGkTCMQ@mail.gmail.com>
To: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Content-Type: multipart/alternative; boundary="089e013c66a0df69df0514614450"
Archived-At: <http://mailarchive.ietf.org/arch/msg/tls/aTiojXTOi20Te4ImZATiYhSTEb4>
Cc: "tls@ietf.org" <tls@ietf.org>
Subject: Re: [TLS] HSM-friendly Key Computation
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 09:54:47 -0000

On Thu, Apr 23, 2015 at 4:42 AM, Ilari Liusvaara <
ilari.liusvaara@elisanet.fi> wrote:

> On Wed, Apr 22, 2015 at 05:30:42PM -0400, Michael StJohns wrote:
> > On 4/22/2015 1:37 PM, Eric Rescorla wrote:
> > >If we're using HKDF-Extract, can we just key off different labels?
> > >
> > >-Ekr
> > >
> >
> > Basically, no.
> >
> > What you want to do is specify as part of the mixins (e.g. 'info' - e.g.
> the
> > collection of label and context)  a set of fields that describe 1) how
> the
> > key stream is going to be broken up (eg. lengths of the sub keys), 2)
> what
> > algorithms will use each of the parts of the key stream, and 3) whether
> or
> > not those parts are allowed to be exported/extracted.
>
> In TLS 1.2 P_hash (which underlies TLS PRF), the corresponding field is
> seed,
> right?
>
> So inside that (or whatever the equivalent), serialize:
> - Label
> - Lengths, types and exportable flags of subkeys
> - Context
>
> ?
>
> Properly serializing that would avoid the well-known TLS 1.2 screwup in
> PRF defintion (which got copied to "dh based key exchange" draft).
>

Can elaborate on this?

The DH-based key exchange draft uses HKDF and uses separate
labels for each use of HKDF-Expand so that (for instance) exporters
and key generation have different labels.



> Also, it occurs to me that if PRF has salt input (like HKDF), one should
> stick something non-secret but variable there (e.g. client random, or
> suitable handshake hash, or something).


Based on talking to Hugo, my understanding is that the best way
to do this is by incorporating the handshake hash at the HKDF-Expand
stage, as in:

client_write_key = HKDF-Expand(Secret, "client write key" + session_hash,
                                 SecurityParameters.enc_key_length)


Some outputs share a (key,salt)
> pair. Keys should be combined by serialization.


If you're referring to how we combine (say) the static DH and the ephemeral
DH, what we had discussed was running K1 through HKDF-Extract to
generate PRK1 and then using PRK1 as the salt for HKDF-Extract on
PRK2. I.e.,

   PRK1 = HKDF-Extract(0, K1)
   PRK2 = HKDF-Extract(0, K2)

-Ekr