Re: [TLS] Issue #964: Shortened HKDF labels

Eric Rescorla <ekr@rtfm.com> Mon, 24 April 2017 23:21 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 DB01213195F for <tls@ietfa.amsl.com>; Mon, 24 Apr 2017 16:21:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 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] 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 s57PvXc-hwVq for <tls@ietfa.amsl.com>; Mon, 24 Apr 2017 16:21:55 -0700 (PDT)
Received: from mail-yb0-x22b.google.com (mail-yb0-x22b.google.com [IPv6:2607:f8b0:4002:c09::22b]) (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 7A4E013195A for <tls@ietf.org>; Mon, 24 Apr 2017 16:21:54 -0700 (PDT)
Received: by mail-yb0-x22b.google.com with SMTP id 6so62584203ybq.2 for <tls@ietf.org>; Mon, 24 Apr 2017 16:21:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rtfm-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=IAhLV/ahzz9VcuOjv6tWjBOu/rR3+zY6F6eqswRkC54=; b=vbBmqE1a8CzIMBqrKAmcM0pKA4lLuksdK/HJm7NJBdjSQdiDNeLYeYmv6Ih5nqxw8Q DSU7NyyDcXmftqEr48bcXtpHO7+/2mjH1hZ9D/nW2ck7D6p/E3UfWwkH8w9WAQbGbgmN 6R2Zlynj5Vkc4LYsgJm1EPTAtWqR3OUmXQd5V6orfzkFh1+ZQzxc2IGG7YkSSTXPSlbX 5Akfs/o0NdgRbhjeKvwSPB34kaGi+QRYw7yg06Jzj/SeHhO5dB0N7rN1Wo1LsO8uKX4u 9/zD5RqsOHGV2H/kpaAYeBQhqI/ipDoOgJi9h0ACCby4OBfE1oLMDWsGjefoyssSYLtD 60XQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=IAhLV/ahzz9VcuOjv6tWjBOu/rR3+zY6F6eqswRkC54=; b=mqk1NpCv8+gK/oYWg4yLJnZ2mh34lWMkf3AgLkxahjyZA9jRF1RPHqTxal2ttDtQkK QR/HK8oLNJW/NcpVHyjXGdlZbVhf4gQGtP3Ze/HZY4c+YEfSDl5RXwHZ7qwEiViZWVEQ dESKOBPRZC7ymxcGWcgv+EiVSyDZzMpr0JqRMdYbTsD7UV5iEftmDMHCw/oxL2BfQ1wP NZyEdR2LqnGDoZRecoIbVPoL7QbjBwq2kdqprie5jtwXJmKj0+L0gL3fN41L/EABFWM0 4tH2Kwsb6aNR7RLaH92Z6wRWVorxnm66xNomdpKgb4JZ0fngLWASw1hhtn3dT7mKLurG XtvA==
X-Gm-Message-State: AN3rC/4mbs+iH4IvhyqLVAJs0XhBSH6AmeaBFzUzmAlnI/jHe/OofHab sY15IOzqgsQzQd2PhwAIe5PeADq/WJd3
X-Received: by 10.37.78.195 with SMTP id c186mr6703853ybb.180.1493076113682; Mon, 24 Apr 2017 16:21:53 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.129.113.7 with HTTP; Mon, 24 Apr 2017 16:21:13 -0700 (PDT)
In-Reply-To: <CABcZeBMriYeFZO5OJnBZvDbhw57V0F5_SBXwvcq8FAXTASa9Bw@mail.gmail.com>
References: <CABcZeBP_0d+14_3SQ3sk+knytxpo4yxq5eYwGn++GC8H9BpUfw@mail.gmail.com> <20170424152422.GA18543@LK-Perkele-V2.elisa-laajakaista.fi> <CABcZeBOoFRwwKO7SqjgcVGMU2UneUiaNXGr4GRO=80C3tsxo-w@mail.gmail.com> <20170424161619.GA18783@LK-Perkele-V2.elisa-laajakaista.fi> <CABcZeBMriYeFZO5OJnBZvDbhw57V0F5_SBXwvcq8FAXTASa9Bw@mail.gmail.com>
From: Eric Rescorla <ekr@rtfm.com>
Date: Mon, 24 Apr 2017 16:21:13 -0700
Message-ID: <CABcZeBO0pcysQuFPXoA44+LxGbOhRVC73UMHC7K6J2DTfB5gVA@mail.gmail.com>
To: Ilari Liusvaara <ilariliusvaara@welho.com>
Cc: "tls@ietf.org" <tls@ietf.org>
Content-Type: multipart/alternative; boundary="001a113e88fa611371054df1dfd5"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/98wv43fD4-HnoTwIOonbKQWS3A8>
Subject: Re: [TLS] Issue #964: Shortened HKDF labels
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.22
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: Mon, 24 Apr 2017 23:21:57 -0000

Based on Ilari's comments, it seems like we just lost 9 bytes, and the TLS
1.3, label was 9 bytes, so these cancel each other out and we have a total
of 18 bytes to work with, including the label.

Hence, the following proposal for the complete label, where the longest
string is 18 bytes.

16 tls13 ext binder    #  was external psk binder key
16 tls13 res binder    #  was resumption psk binder key
17 tls13 c e traffic    #  was client early traffic secret
18 tls13 e exp master    #  was early exporter master secret
18 tls13 c hs traffic    #  was client handshake traffic secret
18 tls13 s hs traffic    #  was server handshake traffic secret
18 tls13 c ap traffic    #  was client application traffic secret
18 tls13 s ap traffic    #  was server application traffic secret
16 tls13 exp master    #  was exporter master secret
16 tls13 res master    #  was resumption master secret
9 tls13 key    #  was key
8 tls13 iv    #  was iv
14 tls13 finished    #  was finished
17 tls13 traffic upd    #  was application traffic secret
14 tls13 exporter    #  was exporter
13 tls13 derived    #  was derived

Further bikeshedding?

-Ekr


On Mon, Apr 24, 2017 at 9:39 AM, Eric Rescorla <ekr@rtfm.com> wrote:

> Nice catch.
>
> 9 bytes seems a bit cramped. What I suggest here is that we remove the
> "TLS 1.3, ", as it was just there by analogy to the handshake context and
> then we are back to having 18 bytes.
>
> If people feel like we should have some "TLS" prefix, I think "TLS " would
> be enough, giving us 1 bytes.
>
> -Ekr
>
>
>
> On Mon, Apr 24, 2017 at 9:16 AM, Ilari Liusvaara <ilariliusvaara@welho.com
> > wrote:
>
>> On Mon, Apr 24, 2017 at 08:28:33AM -0700, Eric Rescorla wrote:
>> > On Mon, Apr 24, 2017 at 8:24 AM, Ilari Liusvaara <
>> ilariliusvaara@welho.com>
>> > wrote:
>> >
>> > > On Mon, Apr 24, 2017 at 05:56:58AM -0700, Eric Rescorla wrote:
>> > > > https://github.com/tlswg/tls13-spec/issues/964
>> > > >
>> > > > Here is a proposed set of new labels, which, while slightly less
>> clear,
>> > > all
>> > > > fit
>> > > > into the 18 byte limit which Ilari (and I agree) says is what we
>> have.
>>
>> Aargh, turns out that Merke-Damgård strengthening probably affects
>> things...
>>
>> For SHA-256, MD strengthening consists of padding bit and 64-bit
>> message bit count, for total of 65-512 bits of padding.
>>
>> Trying to construct the raw SHA-256 message words for inner hash with
>> 9 byte label (K is key, L is label, H is hash).
>>
>> KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK
>> 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636
>> 00201254 4C532031 2E332C20 LLLLLLLL LLLLLLLL LL20HHHH HHHHHHHH HHHHHHHH
>> HHHHHHHH HHHHHHHH HHHHHHHH HHHHHHHH HHHHHHHH HHHH0180 00000000 000003B8
>>
>> Adding 10th byte to label seems to blow the block (0x3C0=1*512+448):
>>
>> KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK KKKKKKKK
>> 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636
>> 00201354 4C532031 2E332C20 LLLLLLLL LLLLLLLL LLLL20HH HHHHHHHH HHHHHHHH
>> HHHHHHHH HHHHHHHH HHHHHHHH HHHHHHHH HHHHHHHH HHHHHH01 80000000 00000000
>> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
>> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000003C0
>>
>>
>> For comparision, with SHA-384, the blocks for 9-byte label seem to be:
>>
>> KKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKK
>> KKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKK 3636363636363636 3636363636363636
>> 3636363636363636 3636363636363636 3636363636363636 3636363636363636
>> 3636363636363636 3636363636363636 3636363636363636 3636363636363636
>> 003012544C532031 2E332C20LLLLLLLL LLLLLLLLLL30HHHH HHHHHHHHHHHHHHHH
>> HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH HHHHHHHHHHHHHHHH
>> HHHHHHHHHHHH0180 0000000000000000 0000000000000000 0000000000000000
>> 0000000000000000 0000000000000000 0000000000000000 0000000000000638
>>
>> (Which has 327 hash block padding bits).
>>
>>
>> -Ilari
>>
>
>