[jose] Re: draft-ietf-jose-hpke-encrypt-01

Orie Steele <orie@transmute.industries> Tue, 09 July 2024 17:55 UTC

Return-Path: <orie@transmute.industries>
X-Original-To: jose@ietfa.amsl.com
Delivered-To: jose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id AC677C1CAE96 for <jose@ietfa.amsl.com>; Tue, 9 Jul 2024 10:55:32 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.096
X-Spam-Level:
X-Spam-Status: No, score=-7.096 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_KAM_HTML_FONT_INVALID=0.01, T_SCC_BODY_TEXT_LINE=-0.01, 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=transmute.industries
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 TZyOgwaevTxP for <jose@ietfa.amsl.com>; Tue, 9 Jul 2024 10:55:28 -0700 (PDT)
Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 C3887C169407 for <jose@ietf.org>; Tue, 9 Jul 2024 10:55:28 -0700 (PDT)
Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1fbc3a9d23bso4565915ad.1 for <jose@ietf.org>; Tue, 09 Jul 2024 10:55:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=transmute.industries; s=google; t=1720547728; x=1721152528; darn=ietf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UR38YmhC3WxUz9aHJSYx51MeFCJRZtWL8QZGgMzlVJo=; b=VG/QGjiUhE5A/2sSopzYUIaPF6axQ4SkrF+fPbKPipvKC6lQlqan+khPbI9vz1IvIq 4azz4WgN3CNQOxhofBnxN21nuQID3bCc4SUjTJTt5q/24WP5bF54IiPWcm5Cgr8MjaA4 fbXK5uN9DZ9AoqUAheqWRc5B8Z+X63ObSd7W6rb+P3dxsgDRYNrgfRE4IW9Aww9nBTIo qoExUmkNs+mvWYsBkkXDFD8EJiCoXMRHU9vmlXKC+9uO74G7hGiBD0QxBO8KRWsB7hEA dTVyHDexpj8fSElpZ53qp2CZgSQyZG8yeR20S+W1BRW+H+qc8SsDbC9RRUfRiiAsNCVn sRlg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720547728; x=1721152528; 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=UR38YmhC3WxUz9aHJSYx51MeFCJRZtWL8QZGgMzlVJo=; b=iNU9TvMtX84xPGzhpCxqtomXiel9OXgNkTsYeKUiOQRlKwUuVi0B/S9MFRP1i/um24 KtAtlOTYDAT/teaU6DSqSxQPVJRER65V2EGCQyEpQYjswmozId6BdZD20FHxuNS4eiQb b8kfitg+4Fuj37U16LLbXrf09XybFD+NiN4to7wQqCRqPgRVOlSqo6SP6sHI3KvXA/HB EwK7GX+MaWpmiXltMS9VFGKau/lMJj2ECaidW9+pt6Vx7L7s8d6mHRrsdkZjn54yVXZv JDBw/ogy1FCh1jn9EywPfbKVhAiTMVi3kSoaDwtVrsMXwSFeFbccYqH9hdoA/BFcdUw+ h+gA==
X-Gm-Message-State: AOJu0YzuUNbRtXQTaV2s0wUuD0SngGKLaMNnXCwf8rcQsnMKrpg9+aqM 1bJtZ0/h3U5LpbqW7orZs1GcVRQvwWmXqoOyCGw7zk9hdx9nhRQCwx0gu2l5W/0y2rkYNvLR0KY Vs+VkuW1ZKJy/REPaXZ8Bfx8wyTjbcPJ9+4ecGQ==
X-Google-Smtp-Source: AGHT+IEz+0gW+h0sbWe0H9cSBNj8S2mFUYzAqeRLTPhTAmvmD3iBU3iulJ0C3tEjBJ054fkNCJvGP7iAl23nGnGExvA=
X-Received: by 2002:a17:902:e549:b0:1fa:2277:f56c with SMTP id d9443c01a7336-1fbb6d6017fmr28649375ad.41.1720547727633; Tue, 09 Jul 2024 10:55:27 -0700 (PDT)
MIME-Version: 1.0
References: <CAN8C-_KMx_M9vL3kwoohkiVrndU_MohxdGC_vLkBo7R_+-6T2g@mail.gmail.com> <CACVbtYOsf7MkHPOzFgE14JhKrSzAd8EkZ0Sr4X0XRMzdCUtbkA@mail.gmail.com> <CACVbtYOOpwTKZt7dH7JV983SmU7gRbsaXY8ru4Ty-+S081oTEQ@mail.gmail.com> <CAN8C-_Kb9ZOec8SXUkqqd3P7VnEYSDukVm56kpdx+fVEw4KHag@mail.gmail.com> <CACVbtYPauBzeSmXPr8Fyb7Jh3u7ydJgX632B0Fwdn4UPgAfQBg@mail.gmail.com> <CAN8C-_JyHsr07FcTMwA01+QTkzjxxqvv0fNpFthytSyyP+MgKQ@mail.gmail.com> <Zo1d2jNRtAjCGC4N@LK-Perkele-VII2.locald>
In-Reply-To: <Zo1d2jNRtAjCGC4N@LK-Perkele-VII2.locald>
From: Orie Steele <orie@transmute.industries>
Date: Tue, 09 Jul 2024 12:55:16 -0500
Message-ID: <CAN8C-_JtWT=mG++9khv7H5Vb4uDoEqNjwhtozTEFFp-XGOuq1g@mail.gmail.com>
To: Ilari Liusvaara <ilariliusvaara@welho.com>
Content-Type: multipart/alternative; boundary="000000000000200c05061cd43cbd"
Message-ID-Hash: 76SPMX2KRMFNQI44UHVVQFYMT5L3E2XH
X-Message-ID-Hash: 76SPMX2KRMFNQI44UHVVQFYMT5L3E2XH
X-MailFrom: orie@transmute.industries
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-jose.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: JOSE WG <jose@ietf.org>
X-Mailman-Version: 3.3.9rc4
Precedence: list
Subject: [jose] Re: draft-ietf-jose-hpke-encrypt-01
List-Id: Javascript Object Signing and Encryption <jose.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/jose/fzZvhyrQDMN_kymnQK69iHxQtR8>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jose>
List-Help: <mailto:jose-request@ietf.org?subject=help>
List-Owner: <mailto:jose-owner@ietf.org>
List-Post: <mailto:jose@ietf.org>
List-Subscribe: <mailto:jose-join@ietf.org>
List-Unsubscribe: <mailto:jose-leave@ietf.org>

On Tue, Jul 9, 2024 at 10:58 AM Ilari Liusvaara <ilariliusvaara@welho.com>
wrote:

> On Mon, Jul 08, 2024 at 09:05:58PM -0500, Orie Steele wrote:
> >
> > I'd love to learn the history of why ECDH-ES+A128KW is not
> ECDH-ES+A128GCM
> > ... but this ship has sailed, "ECDH-ES+A128KW" is mixed into the concat
> kdf.
> > ... the logical equivalent of that happens internally to HPKE, here:
> > https://datatracker.ietf.org/doc/html/rfc9180#section-5.1-9
>
> That is because AES-GCM requires a nonce and breaks badly if it is reused,
> making it not great for key wrapping. Whereas AES-KW does not even need an
> IV.
>
> JOSE does have the (rather broken) A*GCMKW algorithms, which perform Key
> Wrapping using AES-GCM.
>
> The easiest way to get around the GCM nonce issue is to generate both key
> and nonce together using KDF.
>
>
> > The difference is that HPKE doesn't give a different algorithm name for
> > A128KW and A128GCM... it treats them as both 0x0001 see
> > https://www.iana.org/assignments/hpke/hpke.xhtml#hpke-aead-ids
>
> HPKE never uses AES-KW. HPKE always uses AES in GCM mode. It gets around
> the problem with nonce as said above.


>
> > HPKE doesn't know if it's encrypting a content encryption key or not...
> > If you want to ensure that in higher order systems this distinction is
> > authenticated, you need to use setup info or aead aad, see
> >
> https://datatracker.ietf.org/doc/html/rfc9180#name-auxiliary-authenticated-app
> >
> > This leads us back to the current proposal...
> >
> > - alg: HPKE-P256-SHA256-A128GCM ... enc: A128GCM // in separate headers
> ->
> > key encryption
> > - alg: HPKE-P256-SHA256-A128GCM,  enc: A128GCM   // in the same header
> ->
> > integrated encryption
>
> This does not work because JWE unions recipient headers.
>

Which part would you change?


>
> > hpke-info = empty
> > hpke-aad = protected (.aad) // how the distinction is authenticated
>
> ... And this does the wrong thing with Key Encryption (and causes
> implementation problems).
>

What would you set HPKE AAD to be for Key Encryption?
What would you set HPKE AAD to be for Integrated Encryption?


>
> > An alternative proposal:
> >
> > - alg: HPKE-P256-SHA256+A128KW ... enc: A128GCM // -> key encryption
> > - alg: HPKE-P256-SHA256,  enc: A128GCM          // -> integrated
> encryption
> >
> > This doubles the registrations and does not appear to do anything useful.
> > ... unless these different alg values are used as hpke-info to force
> > different key schedules:
> > https://datatracker.ietf.org/doc/html/rfc9180#section-5.1-10
> > ... similar to how ECDH-ES and ECDH-ES+A128KW work in concat kdf today.
>
> This is also prohibited by draft-ietf-jose-fully-specified-algorithms
> (It requires what alg to be independent of enc).
>

Drafts can only be cited as work in progress... it's also in conflict with
RFC7518:

See also: https://datatracker.ietf.org/doc/html/rfc7518#section-4.6.2

      For "ECDH-ES", this is the length of the key used by the "enc"
algorithm.
      For "ECDH-ES+A128KW", "ECDH-ES+A192KW", and "ECDH-ES+A256KW", this
      is 128, 192, and 256, respectively.

So as you can see... "alg" and "enc" are already dependent, as specified in
RFC7518.

We could write:

For "HPKE-P256-SHA256-A128GCM", the length of the content encryption key is
the length of a key used by the "enc" algorithm, note that
"HPKE-P256-SHA256-A128GCM" can be used to encrypt an A256GCM key.

... or someone can propose alternative text that explains how HPKE "alg"
and "enc" values are related.


>
>
>
> -Ilari
>
> _______________________________________________
> jose mailing list -- jose@ietf.org
> To unsubscribe send an email to jose-leave@ietf.org
>


-- 


ORIE STEELE
Chief Technology Officer
www.transmute.industries

<https://transmute.industries>