Re: [Sframe] Question about the use of HKDF-Extract

Richard Barnes <rlb@ipv.sx> Thu, 03 August 2023 15:32 UTC

Return-Path: <rlb@ipv.sx>
X-Original-To: sframe@ietfa.amsl.com
Delivered-To: sframe@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D738CC152564 for <sframe@ietfa.amsl.com>; Thu, 3 Aug 2023 08:32:53 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.902
X-Spam-Level:
X-Spam-Status: No, score=-1.902 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_BLOCKED=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=ipv-sx.20221208.gappssmtp.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BRcZ-Um07rCX for <sframe@ietfa.amsl.com>; Thu, 3 Aug 2023 08:32:53 -0700 (PDT)
Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2E011C152561 for <sframe@ietf.org>; Thu, 3 Aug 2023 08:32:52 -0700 (PDT)
Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2b9a828c920so16592291fa.1 for <sframe@ietf.org>; Thu, 03 Aug 2023 08:32:52 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipv-sx.20221208.gappssmtp.com; s=20221208; t=1691076771; x=1691681571; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=f4+3jodOIC+nqUTbLoUWbfWCbt+0wnQZdTEdty+W0EA=; b=tQ8x7z93ZV/21rpTAcHyVs3mDe2ndzAzvuSXGYNF0WinIcJ9fXGgmX0ndCVuf/6czs JJFssuYwuG4xJog0ebyS6Gi1ebQN2Ovxc4hiIpFVWDu/gI/+mWKovooGQFvHAtIV0b5l Iq7XtStJUwVzSB9UTVpyGAVGMy+kfakVw1JWJ4O6bfbzupRy03lBseYZ8+zsqUVSaTgi z40MrQboRf2j2ZRj+T3sRACcZrMK1KoROn1RlFxruuiHAaEWLb+lCPUZwvjtlu3GQZCN 6VT27NExRCxl04qascBhT4P+BoYQfbkC/olqlllBLO15hVNrQRHIuBC6TJ6SBe/2YMls LMSA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691076771; x=1691681571; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f4+3jodOIC+nqUTbLoUWbfWCbt+0wnQZdTEdty+W0EA=; b=NWDdY+CpkbTADHjklpol6Kd3mkMp8sJ+DHz3IbBNzVTmrRmWjbXcb8CU5Nta3geXjc ZuPkRV+IZXWJ57J6xP16nckk3Mjanj2vDhofUj9x6HHYo719X++nxfNg5SbAMco3Uly4 EvdmppL2LrVFpuZQLdBkf+tp12U49hf8wFTPAK8JgvrIhF7zKYEA1TlXylC5WfbgJWep O5xEavDu0OrIzs+5WP/vNIXZrdzRk7OD7ZdSnSMVHTQVGH39KO7JyZzt6KUhfgCZlkVF QuwyQ5n610ioZ+dyl3OZcjwrnTrTaiTca2xc9F2hUbBMJP+wlxxj5OH9uxhXQTS2WUby J5bg==
X-Gm-Message-State: ABy/qLbOGxE9AX5J9KeX9dEqbcR19mEbKfVu9gDROnrlBFTQRJanhg9t 8cgFKqhJMqg2v+z9U2k+1RLsBhhYlfzgi/mU07MY1s4rG2MWtjOy8LG9YQ==
X-Google-Smtp-Source: APBJJlGjMQWZLJOCHJeguhl1arS63uXJQ1aAlQofs+Ih4cx09MK3047iQNxBIoIyenkbOx13PfONqy+KMEI74o0FtPk=
X-Received: by 2002:a05:651c:14b:b0:2b3:4ea3:d020 with SMTP id c11-20020a05651c014b00b002b34ea3d020mr8303687ljd.17.1691076770967; Thu, 03 Aug 2023 08:32:50 -0700 (PDT)
MIME-Version: 1.0
References: <4dfb9a54701e4682bf131f2f92f84699@amazon.ch>
In-Reply-To: <4dfb9a54701e4682bf131f2f92f84699@amazon.ch>
From: Richard Barnes <rlb@ipv.sx>
Date: Thu, 03 Aug 2023 11:32:39 -0400
Message-ID: <CAL02cgQUpSVjQH6vdFQu5=skJADyFJQW2Nogba4XyEc16_vpRA@mail.gmail.com>
To: "Mularczyk, Marta" <mulmarta=40amazon.ch@dmarc.ietf.org>
Cc: "sframe@ietf.org" <sframe@ietf.org>
Content-Type: multipart/alternative; boundary="00000000000038c9940602067ed6"
Archived-At: <https://mailarchive.ietf.org/arch/msg/sframe/jUQd924XArYC-pQWDx4ayYySRAI>
Subject: Re: [Sframe] Question about the use of HKDF-Extract
X-BeenThere: sframe@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Secure Media Frames <sframe.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/sframe>, <mailto:sframe-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/sframe/>
List-Post: <mailto:sframe@ietf.org>
List-Help: <mailto:sframe-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/sframe>, <mailto:sframe-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 03 Aug 2023 15:32:53 -0000

Hi Marta,

Thanks for taking a look.  Your proposed structure looks good to me.
Please send a PR!

Cheers,
--Richard


On Thu, Aug 3, 2023 at 10:00 AM Mularczyk, Marta <mulmarta=
40amazon.ch@dmarc.ietf.org> wrote:

> Hi all!
>
> First of all, I think it's a great protocol, super simple and useful.
>
> Now my actual small question. I noticed that derive_key_salt uses the HKDF
> in a bit non-standard way. Is there a reason for this, or can we use the
> "more standard" way I propose below? If people like the idea, I'm happy to
> draft a PR. In detail, the draft states
>
>    sframe_secret = HKDF-Extract("SFrame 1.0 Secret " + KID, base_key)
>    sframe_key = HKDF-Expand(sframe_secret, "key", AEAD.Nk)
>    sframe_salt = HKDF-Expand(sframe_secret, "salt", AEAD.Nn)
>
> The way HKDF-Extract is typically used is
> HKDF-Extract(optional_random_salt, base_key). On the other hand, the
> "domain separation" achieved by the label "SFrame 1.0 Secret " + KID
> typically happens in HKDF-Expand. So a more standard way seems to be
>
>    sframe_secret = HKDF-Extract("", base_key)
>    sframe_key = HKDF-Expand(sframe_secret, "SFrame 1.0 Secret key " + KID,
> AEAD.Nk)
>    sframe_salt = HKDF-Expand(sframe_secret, "SFrame 1.0 Secret salt " +
> KID, AEAD.Nn)
>
> This also aligns with MLS, which computes (below the Label is e.g.
> "joiner")
>
>    ExpandWithLabel(Secret, Label, Context, Length) = KDF.Expand(Secret,
> {length, "MLS 1.0 " + label, Context}, Length)
>
> FWIW, my explanation (in very loose terms) of the "more standard"
> derivation would be that the call to HKDF-Extract genertes a uniform key
> from a possibly non-uniform key provided by the application, while the
> HKDF-Expand calls generate 2 uniform keys from a uniform key.
>
> Best,
> Marta
>
> --
> Sframe mailing list
> Sframe@ietf.org
> https://www.ietf.org/mailman/listinfo/sframe
>