Re: [TLS] Derive-Secret(foo, "bar", "")

Eric Rescorla <ekr@rtfm.com> Tue, 21 March 2017 12:14 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 1D61E1296DB for <tls@ietfa.amsl.com>; Tue, 21 Mar 2017 05:14:11 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.598
X-Spam-Level:
X-Spam-Status: No, score=-2.598 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_LOW=-0.7, 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 4QoVrJZCoMns for <tls@ietfa.amsl.com>; Tue, 21 Mar 2017 05:14:08 -0700 (PDT)
Received: from mail-yw0-x233.google.com (mail-yw0-x233.google.com [IPv6:2607:f8b0:4002:c05::233]) (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 E47661297E9 for <tls@ietf.org>; Tue, 21 Mar 2017 05:14:04 -0700 (PDT)
Received: by mail-yw0-x233.google.com with SMTP id v76so108576333ywg.0 for <tls@ietf.org>; Tue, 21 Mar 2017 05:14:04 -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=kIjluI/2LND+cViGfaAjXxCA1Nu13T0IajQvnIlkVdo=; b=TAK7BMAw8W8YgizcLu7/+7Tv0oAtubXa7jmJgmhdOLzUcddp0uoBkX9VOwsMHILpUJ eBqCrYxVolXU+xbVBb7H2MYv50AdOXOassPziefSdBu1R9oiHxhV1koKn+nf3QuiJADf ITdUa8L9tLfFCL1YrzpGo+M95IWSH+a/acul7P62sVD0UlRwvbQRyYBfAsWrF5Iw5ZB7 GgKdqnkl2tFRQpdBaI9iF32vagZkpL5d79NN30WQI5jciW8XjMcdha7kT5je1fNE875T BqVXa23IumJbCIZ0bdeU3DSls8+rYSp58aCMc8FCMVjyPW9cmJ94UtFVUjOSMv6LTy6t 39hA==
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=kIjluI/2LND+cViGfaAjXxCA1Nu13T0IajQvnIlkVdo=; b=lSb3mbx6l4jHtUW2yim5koOGemCeQJhfVgaK6cR9S1P+2WL+4NG7uQzFI4U8RGiD2B Lb8HhyBmjh/rRn0kCLX6nVWo579wcpvcUvGwz2YM1y7NYQyI/qAgJ8DNxh9IPfLsLX/n ShyUMz62QKrD1EhRz59ztDZEgW5TgBd0AxjkusKiYSl0zRefStyysfGQnJs4Kce5nPAW hC6VdCMeiD0qQFo5urL7Yw0cSoDuEZNrd5kFJvN6hatc+xSfG2mcpRbO7zAqKryu2Uic yyS2qmbnyclODG62/5IVuJGuaRPGwkSCrS/yDHLiUmuOqz4t9ia1dyyq42Ak74KqiVt8 TQvA==
X-Gm-Message-State: AFeK/H3M4sUcjCW8uXVW4/1msau/qEVZ+IJl/YQ0tNc1Uu7G5KCpjs7UpGLgtD2CABTjY2GAEwgq66V9Kp8luw==
X-Received: by 10.37.53.138 with SMTP id c132mr22135780yba.105.1490098444158; Tue, 21 Mar 2017 05:14:04 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.129.154.210 with HTTP; Tue, 21 Mar 2017 05:13:23 -0700 (PDT)
In-Reply-To: <20170321094530.GA493@LK-Perkele-V2.elisa-laajakaista.fi>
References: <20170321094530.GA493@LK-Perkele-V2.elisa-laajakaista.fi>
From: Eric Rescorla <ekr@rtfm.com>
Date: Tue, 21 Mar 2017 05:13:23 -0700
Message-ID: <CABcZeBM8WK_ZcprSAyJ_6HES5=eCgdpGarJeKnFrOwFw-YD=ng@mail.gmail.com>
To: Ilari Liusvaara <ilariliusvaara@welho.com>
Cc: "tls@ietf.org" <tls@ietf.org>
Content-Type: multipart/alternative; boundary="001a114bbb32720416054b3c942a"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/qm9BuzvrC7219uMFkOAVIvMlgCM>
Subject: Re: [TLS] Derive-Secret(foo, "bar", "")
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: Tue, 21 Mar 2017 12:14:11 -0000

On Tue, Mar 21, 2017 at 2:45 AM, Ilari Liusvaara <ilariliusvaara@welho.com>
wrote:

> What is the correct HkdfLabel for Derive-Secret(foo, "bar", "") in
> TLS 1.3 draft-19?
>
> I ask, because I ran into interop problems because of this, between my
> implementation and OpenSSL, and I traced it to this.
>
> Let's assume PRF-hash is SHA256 (32 bytes output)
>
> I interpret the spec so that the HkdfLabel is:
>
> 00 20 0C "TLS 1.3, bar" 00
>
> That is, 32 bytes output, 12 byte raw label "TLS 1.3, bar" and
> 0 byte context.
>
> OpenSSL seems to interpret it as:
>
> 00 20 0C "TLS 1.3, bar" 20 e3 b0 c4 42 98 fc 1c 14 9a fb f4 c8 99 6f
> b9 24 27 ae 41 e4 64 9b 93 4c a4 95 99 1b 78 52 b8 55
>
> Where the e3b0c442... bit is the SHA-256 hash of empty string.
>
> That is, 32 bytes output, 12 byte raw label "TLS 1.3, bar" and
> 32 byte context, holding SHA-256 of empty input.
>
>
> Which is correct? Or neither?
>

I believe that OpenSSL is correct. Note that this construction already
appeared in the computation for the binder keys in -18 and I believe that
everyone interpreted it as the hash of the empty string.

I think that's more natural given the notation, because Derive-Secret
explicitly hashes the input, whereas HKDF-Expand-Label is defined
as using "" = means a 0-length hash. If people think we should adopt
your interpretation, I think we would need to special-case the notation,
which of course isn't the worst thing in the world.

Maybe we should update the draft, though.

-Ekr


>
>
> -Ilari
>
> _______________________________________________
> TLS mailing list
> TLS@ietf.org
> https://www.ietf.org/mailman/listinfo/tls
>