Re: [jose] [COSE] COSE/JOSE elliptic curves and their relationship with key types

Neil Madden <neil.madden@forgerock.com> Tue, 13 July 2021 06:57 UTC

Return-Path: <neil.madden@forgerock.com>
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 1416C3A1A30 for <jose@ietfa.amsl.com>; Mon, 12 Jul 2021 23:57:05 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.097
X-Spam-Level:
X-Spam-Status: No, score=-2.097 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=unavailable autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=forgerock.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 FlcG6u-aQDtE for <jose@ietfa.amsl.com>; Mon, 12 Jul 2021 23:57:00 -0700 (PDT)
Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 946143A1A31 for <jose@ietf.org>; Mon, 12 Jul 2021 23:57:00 -0700 (PDT)
Received: by mail-wm1-x32f.google.com with SMTP id h18-20020a05600c3512b029020e4ceb9588so803045wmq.5 for <jose@ietf.org>; Mon, 12 Jul 2021 23:57:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=forgerock.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc:message-id:references :to:content-transfer-encoding; bh=sl2TEwlG3T6OmzQZ+hCGVPlxIWwO6MYcn6fSRrMi8eE=; b=CRsI48HLJiikOQGOu4gAyhl3WYln9WdOE7pASWxocO5cGgH0/WJlhmLax2OaAUC7cX 1Shaksim/ffLvLXg1QqEbhgogIBNL2cjr7Tgfyv72BAXEPE31lPWVF1RYZRm2p4BFsDV fZanOARBOE3wmQdz8/AmQW3ac2O4aScBbVgeo=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to:content-transfer-encoding; bh=sl2TEwlG3T6OmzQZ+hCGVPlxIWwO6MYcn6fSRrMi8eE=; b=SX94JRFQItEM7Zahi6vOQ2DFpxlNMU7xDcN/5iA+3m4lEV+uSIN3OVMnpFNAnpBUib L3hD4B8DPEV10EB1QIuXks9F9hbPueRSiGosvvkDXASg5JmvyMVEB2Ajy4jZN54tG9TH enCyOAiLFSzLdfx/C2OVVNknBQVcmI+VloVkeQcZtbwb8kbNF85In3A/yjgq+7k8O69i RARIdeUDopQq1L6QmXZueOsJun/HFTK4PVvwfCPt1TPBXDYdSZVLo+stf06DowLTgBUo KYJTmi03G/ZJ2wt0tnSzVtRuZR/K9tWATZ2QPetWLnHxAOqHIRgaHjqic/OQQOq4/SS8 xhwA==
X-Gm-Message-State: AOAM531I8OqUUHz6d9OXfH9oW9Q+LCmfKdLBg5wdfNPkk6YM9adcTknr JWHPL9dHWsdNVBYgDQ3IjynpE8vKzjh0nB6pysX2r1jm/FtCjBqnytMkal8+Wbp23y/Tc54E
X-Google-Smtp-Source: ABdhPJwSPktJm2C0MPhGnOSJy8qBfn7aoMKnyUkcaTSAmx6YvCfesmCs07fuUkA7FqngqMSROSyuTA==
X-Received: by 2002:a1c:1f8a:: with SMTP id f132mr3236223wmf.56.1626159416925; Mon, 12 Jul 2021 23:56:56 -0700 (PDT)
Received: from [10.0.0.6] (113.87.75.194.dyn.plus.net. [194.75.87.113]) by smtp.gmail.com with ESMTPSA id d18sm1507572wrw.7.2021.07.12.23.56.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jul 2021 23:56:56 -0700 (PDT)
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
From: Neil Madden <neil.madden@forgerock.com>
In-Reply-To: <20210713034600.GJ17170@mit.edu>
Date: Tue, 13 Jul 2021 07:56:55 +0100
Cc: Michael Richardson <mcr+ietf@sandelman.ca>, jose@ietf.org, cose@ietf.org
Message-Id: <47195B9C-4323-467A-AE27-949DE33C38A4@forgerock.com>
References: <20210707212059.GX17170@mit.edu> <21116.1625697755@localhost> <20210713034600.GJ17170@mit.edu>
To: Benjamin Kaduk <kaduk@mit.edu>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/jose/oUtckNTF5fHARBTJQ-0-neeeV3A>
Subject: Re: [jose] [COSE] COSE/JOSE elliptic curves and their relationship with key types
X-BeenThere: jose@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Javascript Object Signing and Encryption <jose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jose>, <mailto:jose-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jose/>
List-Post: <mailto:jose@ietf.org>
List-Help: <mailto:jose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jose>, <mailto:jose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 13 Jul 2021 06:57:05 -0000

My understanding is that single-coordinate representations (OKP) are safer because they reduce the scope for invalid curve attacks, but that they were patent-encumbered for many years. With a double-coordinate representation you have to carefully check that (x,y) satisfies the curve equation. With a single coordinate you instead calculate y from x using the curve equation (if you need it), so it can’t fail to satisfy it. IMO, that should be the preferred representation for any new curves. 

Note that if you want to be completely unambiguous then you typically want a single coordinate (x) plus a bit to say which of the two roots to use for the y-coordinate. RFC 8037 allows this by not committing to what “x” represents, but RFC 8152 for COSE says that the “x” field is the little-endian encoding of the x-coordinate specifically, so you might need a different type. (In fact, EdDSA public keys are the *y* coordinate plus a single bit to say which x-coordinate to use, so I think COSE is already breaking its own contract).

— Neil

> On 13 Jul 2021, at 04:46, Benjamin Kaduk <kaduk@mit.edu> wrote:
> 
> Hi Michael,
> 
> Thanks for sharing your thoughts.
> 
> On Wed, Jul 07, 2021 at 06:42:35PM -0400, Michael Richardson wrote:
>> 
>> Benjamin Kaduk <kaduk@mit.edu> wrote:
>>> As written, that seems to allow a notion of "consistent" that is not
>>> strictly 1:1, but all of the curves defined so far only have that 1:1
>>> mapping, and trying to use any other "kty" for an existing curve would run
>>> into interop problems with existing implementations that reject other "kty"
>>> values for that curve.
>> 
>> It seems to me that we think it's always gonna be 1:1, but that we admit that
>> we can't predict the future, and so we are providing some extra rope.
> 
> There is of course a reason that I am asking the question.  I had hoped
> to separate the initial batch of responses to the general question from the
> specific case, so I didn't mention it in the initial note, but
> draft-ietf-lwig-curve-representations registers the Wei25519 and Wei448
> elliptic curves (the short-Weierstrass analogues of Curve25519 and
> Curve448), and currently lists the key type for both as "EC2 or OKP".
> 
> To my knowledge, these curve (representation)s are not in wide use and
> there is thus not a well-established single point representation to use
> with them.  However, since the intent of the work is to expose the CFRG
> curves' benefits to implementations tailored to short-Weierstrass curves,
> which in turn would be likely to use the "EC2" representation in its
> interfaces, it seems like if we were to pick a preferred representation it
> would be "EC2".
> 
>> It also seems that we might also be thinking that there might be other ways
>> to encode the keys (into bytes), but that mostly it is the case that we have
>> a single encoding that we stick to.
> 
> But for a protocol don't we kind of only want a single encoding anyway?
> 
>> (Why did we call it "EC2". Huh)
> 
> I feel like I used to know this, but am drawing a blank.  Maybe that there
> are two coordinates included?
> 
> Thanks again,
> 
> Ben
> 
>>> Do we expect a strict relationship where each curve has exactly one "kty"
>>> that it's used with?  If not, in what scenario(s) would there be multiple
>>> "kty" values to use with a single curve?
>> 
>> 
>> --
>> Michael Richardson <mcr+IETF@sandelman.ca>   . o O ( IPv6 IøT consulting )
>>           Sandelman Software Works Inc, Ottawa and Worldwide
>> 
>> 
>> 
>> 
> 
> 
> _______________________________________________
> jose mailing list
> jose@ietf.org
> https://www.ietf.org/mailman/listinfo/jose


-- 
ForgeRock values your Privacy <https://www.forgerock.com/your-privacy>