Re: [TLS] HSM-friendly Key Computation

Michael StJohns <msj@nthpermutation.com> Thu, 23 April 2015 19:02 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 C5E8B1A0004 for <tls@ietfa.amsl.com>; Thu, 23 Apr 2015 12:02:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.6
X-Spam-Level:
X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, 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 4TSKwgf80E1K for <tls@ietfa.amsl.com>; Thu, 23 Apr 2015 12:02:42 -0700 (PDT)
Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com [209.85.192.169]) (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 A066E1A0039 for <tls@ietf.org>; Thu, 23 Apr 2015 12:01:27 -0700 (PDT)
Received: by pdbqd1 with SMTP id qd1so26036135pdb.2 for <tls@ietf.org>; Thu, 23 Apr 2015 12:01:27 -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 :content-transfer-encoding; bh=MwCtVO4mt0Ul6mOXC0rR8AwFb7OEa1c8k+jr7y21rlQ=; b=WRkub0YdDVmDuh5tUsYIDLoDDpLJkj0hLIj66AXu8ybSQY/jVIw6wzxG/t1EcjqPY6 sazDVblGqXYvSirfyfnik7dZINDanREuLYRgpZGM/b7UblRlPPpf9t0OYwKZtKBgu+gf ARqK9QFAnPZA/NeL0ibgCKTbDcxtvlIPavULVlX289MmVWNXr1TrW4zFBehWt9sp8f6B b4gV9yknA9q8K+cQP+17T0fc0Upi9/YPh66js9hs20uAFeQSJ3tr0SpgkJ7V/Bdnlf6K aDd9drYGoErggWT6DrmWHbC3lfJeUWZyL/BBruXoOWpruUOj4OtcgQVk7LpykF9dMEHC iIPA==
X-Gm-Message-State: ALoCoQlZx4WwzpKyYWU2t+al/d1Lsbqz3QevHfehi57WMalRHjA3eqovys+mOsxfkZt23NLxHUcH
X-Received: by 10.66.150.196 with SMTP id uk4mr8082160pab.54.1429815687306; Thu, 23 Apr 2015 12:01:27 -0700 (PDT)
Received: from [10.90.197.114] (soi.silverspringnet.com. [74.121.22.10]) by mx.google.com with ESMTPSA id cy5sm8825004pdb.85.2015.04.23.12.01.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 12:01:26 -0700 (PDT)
Message-ID: <55394191.1050203@nthpermutation.com>
Date: Thu, 23 Apr 2015 15:01:37 -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: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
References: <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> <55392D3D.1020101@nthpermutation.com> <20150423175244.GA26942@LK-Perkele-VII>
In-Reply-To: <20150423175244.GA26942@LK-Perkele-VII>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Archived-At: <http://mailarchive.ietf.org/arch/msg/tls/38sMi6mYPz3SPAhR2B_J4eDWuIU>
Cc: 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 19:02:43 -0000

On 4/23/2015 1:52 PM, Ilari Liusvaara wrote:
> On Thu, Apr 23, 2015 at 01:34:53PM -0400, Michael StJohns wrote:
>> On 4/23/2015 4:42 AM, Ilari Liusvaara wrote:
>>> On Wed, Apr 22, 2015 at 05:30:42PM -0400, Michael StJohns wrote:
>>>
>>> One possible structure in TLS notation:
>>>
>>> struct prf_output
>>> {
>>>       /*
>>>       0x0000 => For key derivation
>>>       0x0001 => For AEAD keying
>>>       0x8002 => For AEAD IV
>>>       0x8003 => For octet string (exporters, unique)
>>>       */
>>>       uint16 type;
>>>       uint16 length;  /* In bytes. */
>>> };
>> I ended up with a bit larger set of key types:
>>
>> Master Secret (can only be used with KDFs)
> Right.
>
>> AES-CMAC
> Not used anywhere (insufficient security).

For this and the comment below..... I'm not just thinking about TLS.  
And I am thinking about how to retrofit this to TLS1.2 which doesn't 
require this to be an AEAD function.  And then there's the composed AEAD 
suites (e.g. AES-CBC with AES-CMAC wrapped as an AEAD function).   So 
while they may not be used by TLS directly, I want to get code points 
for all the possibilities.
>
>> AES-AEAD
> Is there ment to be XXX-AEAD for different encryption algorithms?
> Do AES-CCM and AES-GCM share a key type? What about AES-CCM8?

Generally yes for xxx-aead having different types per algorithm. Because 
you don't want to (for example) be able to use material for both AES and 
say GOST.   For modes, AEAD modes are mostly supersets or combinations 
of non-AEAD modes and there's an attempt to enforce "releasability only 
after verification" type policies on the CCM and GCM modes.   It would 
be good to have different codes for CCM and GCM (or even other modes), 
but I don't know that adds markedly to security.
>
>> AES-ENCRYPT
> Not used. Encryption always pairs with authentication (AEAD).

See above - one of the questions is how does a composed AEAD suite 
derive subkeys.  Generically it seems to be "split the stream wherever 
you want" and as noted, that has a few problems.
>
>> HMAC-SHA1
> A NULL cipher key? That one wouldn't be directly used for anything else.

For TLS1.2 and before, being able to tag that you're deriving an 
integrity key...  ditto for below.
>
>> HMAC-SHA2
> NULL cipher keys are per algorithm?
>
>> GENERIC-DATA (different that PKCS11 generic secret - could be IV material
>> for example).
> This is "octet string" above (except IVs are "AEAD IV").

Not quite. (<begin pedantic mode>  :-) )

One of the problems we have is a lack of common language.  And IV is one 
of those that's very slippery.

TLS - incorrectly - called what's being produced by the master secret 
expansion an "IV".   What it actually was was the "first IV" of the 
session for cipher suites that included  CBC as a mode and a "session 
nonce" for suites with counter based ciphers.

An IV is the common data injected by both sender and receiver to ensure 
that the same data doesn't encrypt the same way if identical data 
happens to occur in the plaintext stream multiple times.  For counter 
based ciphers, the IV is used with the block counter to form the block 
nonce(s) that (is/are) encrypted to form the XOR key stream.

An counter-based IV  (e.g. for CTR, CCM and GCM) is generally composed 
of the concatenation of the session nonce (or as we've been discussing a 
fixed length of zeros) plus a per-message value (and we've been 
discussing always using the message sequence number as that per-message 
value).

Due to the way TLS is constructed, what comes out of the master secret 
expansion can only be a "first IV" or a session nonce.  It would be 
possible to change this so an expansion is done with each message (e.g. 
same master secret, different mixins such as the sequence number) to 
generate a true per-message IV, but that's expensive and provides little 
security benefit.

</pedantic mode>

>
>> as a starting point.
> Depending on view, you also need special type for exporter secret, since
> it behaves somewhat unlike others.

I think the easiest way to accomplish this is to use a flag saying 
whether or not its exportable (generally removable from an HSM) that 
gets mixed in.  That way you have the common language of what you want 
to generate and then only have to decide on handling criteria.


>
>> It turns out that you want to subdivide AES AEAD uses from non AEAD AES
>> functions because you don't want to be able to use AES-CTR to get around the
>> AES-CCM and GCM "don't let the data come out unless its been verified"
>> policy.
> As said, encryption always pairs with authentication.
>
>
>
> -Ilari
>
>