Re: [TLS] DTLS Key Separation PR

Eric Rescorla <ekr@rtfm.com> Thu, 10 October 2019 12:38 UTC

Return-Path: <ekr@rtfm.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 4462C1200E5 for <tls@ietfa.amsl.com>; Thu, 10 Oct 2019 05:38:11 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.896
X-Spam-Level:
X-Spam-Status: No, score=-1.896 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=rtfm-com.20150623.gappssmtp.com
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 zb8ZKfsH_ea7 for <tls@ietfa.amsl.com>; Thu, 10 Oct 2019 05:38:08 -0700 (PDT)
Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) (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 A9493120113 for <tls@ietf.org>; Thu, 10 Oct 2019 05:38:07 -0700 (PDT)
Received: by mail-lj1-x22d.google.com with SMTP id d1so5984813ljl.13 for <tls@ietf.org>; Thu, 10 Oct 2019 05:38:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rtfm-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jrPG+wuOSqDOV49gyjgFkQ9y4X9Bif/1IWdzGQaCG84=; b=QJhCThjX67kb5gGTUCy9X/KoKNyjDZwIzZFymvxo59ZERYvDB1THehpobPZDYTkFAf mpRzIOIS70i+GBv9ctJiRwQfPJ9cPc8FR/C2VkFp3yDPLU0HhY5Ez9TW0GXdM6alOf7E Jg4wGqU7dOZUk10rE352/PN3gAZpLHkHbdcp5y8fIdZ9xp2qheQP2KvmitaVzG+AgfXz 2t2/wAs6nYJTCkDoQL0jdCEk/gMjMB5zyczSO0CIBrqFzBjkb8yzdKh8FIeV4KrKt8s6 WfGlmhTC9/JjkwZJVNL+rxZsbfNSK4D5EC2yZqTw6MWTBUwCrpGwP4r8Z5eRpYOIMnDC 2kPw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jrPG+wuOSqDOV49gyjgFkQ9y4X9Bif/1IWdzGQaCG84=; b=q33l0Ab2ZxW7i/Wv2eUMqrDisrlJ2RyV/VWhGjiGwIxrKoxvvs0Db9mzVCh4Yadajz /AuUGn8UBoOb9XUuvU6pDA+WkXDOWOUJiYPM7HF8Sve/cbrVDCX6h4t9KCty9pF1rtg2 2Y2XGvU9gfoDlg2QqkgYi0UMsSaDumIgMpJBJRdlGtxvP/8dZHqUoY7Miraf53/s+mrv il1Jj93ScUCYUmRNFXrneVdJoW8Wq4OuTPWhR6yL7jUdCoXI+fAtKDtfjx8Ov2qN8bWc Pik/98NtG+7/LEbJrVRzt45LerwOl2XAR+OCp0RjVnheXfJk/BfMd5YgDqUhgJhZWDcE V9qQ==
X-Gm-Message-State: APjAAAV4gSc9ljN4cdtn2/WEDmoSqJAmRbFEZ2dwNj6RLMRViBxrjewO 95Azb6owYzRNYV3DsqzTk1PHKpeGObs6QjtGRXHoeqdmWfE=
X-Google-Smtp-Source: APXvYqxzTF3toK98/rS6u8r7AewPPMPOx/qh0LUhI9i7ZhmA3kHpklkOuKc8JffuoBkrkT1RPoAM1eryM2CBi62hMJo=
X-Received: by 2002:a05:651c:1031:: with SMTP id w17mr6228478ljm.38.1570711085748; Thu, 10 Oct 2019 05:38:05 -0700 (PDT)
MIME-Version: 1.0
References: <CABcZeBMDDyuTQ72sk2UNqpUMk+aHaskrJjSyQkUqt1HZFgnNGw@mail.gmail.com> <69c7cfbd-fe9f-40fa-b92b-e4b65fa6cb5d@www.fastmail.com>
In-Reply-To: <69c7cfbd-fe9f-40fa-b92b-e4b65fa6cb5d@www.fastmail.com>
From: Eric Rescorla <ekr@rtfm.com>
Date: Thu, 10 Oct 2019 05:37:29 -0700
Message-ID: <CABcZeBPRMTEYC2b1Z94uDPXy6Y5tPTTjK7yzWff4Eze1wtgfpQ@mail.gmail.com>
To: Martin Thomson <mt@lowentropy.net>
Cc: "<tls@ietf.org>" <tls@ietf.org>
Content-Type: multipart/alternative; boundary="0000000000004faa6505948dac57"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/d-LVgXFPn5dHdCiarSxgMq1KKgQ>
Subject: Re: [TLS] DTLS Key Separation PR
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.29
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: <https://mailarchive.ietf.org/arch/browse/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, 10 Oct 2019 12:38:11 -0000

On Wed, Oct 9, 2019 at 7:01 PM Martin Thomson <mt@lowentropy.net> wrote:

> tl;dr keep the space.
>
> I had a little trouble reproducing the 12 from RFC 8446, so I
> double-checked.
>
> ....
>
> Working from the base for SHA-256:
>
> The last block of SHA-256 is rounded up to 448 bits (56 bytes), less one
> to allow for padding.  Therefore we have 55 bytes to use without having to
> run two blocks through SHA-256.
>
> HMAC-Hash = H(K XOR opad || H(K XOR ipad || text))
>
> Here `K XOR ipad` is the 32 bytes output size of SHA-256, so we are down
> to 23 bytes for text before it adds a block.
>

In HMAC the key consumes an entire input block, so that you are guaranteed
a compression function cycle before the data is added:

1) append zeros to the end of K to create a B byte string
        (e.g., if K is of length 20 bytes and B=64, then K will be
         appended with 44 zero bytes 0x00)
    (2) XOR (bitwise exclusive-OR) the B byte string computed in step
        (1) with ipad

https://tools.ietf.org/rfcmarkup?doc=2104#section-2

This shifts everything to the right 32 bytes, which, because context
is 32 bytes, gets us back to 12, I think, though I haven't re-worked
through it.

Here's Ilari's original analysis, if that's helpful:
https://mailarchive.ietf.org/arch/msg/tls/n_TFape7L4HHoKLxGo8CkimZziI

-Ekr






> HKDF-Expand =  HMAC-Hash(PRK, info | 0x01)
>
> This takes one more.  Down to 22.
>
> HKDF-Expand-Label passes info in the form of:
>
>        struct {
>            uint16 length = Length;
>            opaque label<7..255> = "tls13 " + Label;
>            opaque context<0..255> = Context;
>        } HkdfLabel;
>
> which has a minimal overhead of 2 + 1 + len("tls13 ") + 1 = 10.  So we get
> 12.
>
> "c ap traffic" is 12 bytes long, so yeah it *looks* like we're stuck if we
> care about not adding too many extra hash iterations.
>
> ....
>
> But if you look at the key schedule, we always provide a context for those
> cases we use "c ap traffic".  Those will always spill over into the next
> iteration as Context is 32 bytes.  So for those cases, we have a whole 32
> bytes extra to play with.  The only cases with an empty Context are
> "derived" and "res binder"|"ext binder".  Those max out at 10, so we seem
> to have two whole bytes of wiggle room.
>
> You can safely add the space.
>
> On Wed, Oct 2, 2019, at 08:40, Eric Rescorla wrote:
> > Hi folks,
> >
> > As discussed in Montreal, I've prepared a PR to give us DTLS/TLS key
> separation.
> >
> > See:
> > https://github.com/tlswg/dtls13-spec/pull/99
> >
> > Sadly. we didn't have enough space for "dtls13 " so I went for "dtls13"
> >
> > -Ekr
> >
> > _______________________________________________
> > TLS mailing list
> > TLS@ietf.org
> > https://www.ietf.org/mailman/listinfo/tls
> >
>
> _______________________________________________
> TLS mailing list
> TLS@ietf.org
> https://www.ietf.org/mailman/listinfo/tls
>