[COSE] Is the COSE public key encoding inefficient ... was RE: Next steps with COSE-HPKE .... was RE: HPKE: Ephemeral public key encoding
Hannes Tschofenig <Hannes.Tschofenig@arm.com> Thu, 15 September 2022 14:49 UTC
Return-Path: <Hannes.Tschofenig@arm.com>
X-Original-To: cose@ietfa.amsl.com
Delivered-To: cose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 65431C1524D4 for <cose@ietfa.amsl.com>; Thu, 15 Sep 2022 07:49:01 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.908
X-Spam-Level:
X-Spam-Status: No, score=-1.908 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=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 (1024-bit key) header.d=armh.onmicrosoft.com header.b=Su75qdD/; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.b=Su75qdD/
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 oEWSQ-9YhOhX for <cose@ietfa.amsl.com>; Thu, 15 Sep 2022 07:48:57 -0700 (PDT)
Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2040.outbound.protection.outlook.com [40.107.105.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 64A73C15259D for <cose@ietf.org>; Thu, 15 Sep 2022 07:48:57 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=PbpIsA1RDWI7Z1/8kbVrSJEzzoR28ReqNlHY7obvL4DPYZ9hbyPxULg7DXjUqyxLe9twdxd2icnFYuiLAuAyRg8Cl4RMeCWpQBApWvY5MzvqSfy+vOJg0MTWaZA3Q7JKx1AIihIFXy9AszvajryV4PLTWfSdSDkOrc5u/OzmR6ml1iSv/pMRRxUr+2MxnslM4TJAHjlTreB4WqAenW28AXU/HzXLjRqneMNi3WNu01Q77S1Vx72xg1Gl8Owp725dpUKgQM49hdndiStnOyEJx0AMUIcKp292gzVj7tEmcJ/LfrjyNxQ1dQ9r32Nfr0+BN8wmD5lLD8AvvuoovSigFQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XU7NwZnqT8pZczr7EMWwfHY/fA+IwsjpOBjzPcx84iw=; b=kSYGG4ffsKjEpWDKsKWoJ2+K4BlJtKsXFePlSrnJA5nBfRIs6xnWub/Ls6WXgJecC3MJcj5+uvObSv0vw8tv74aqYOievcRpm3g19CDRUMv2D1W0mWDK3OVspxQbvzt/wf66ROcE6mYyoZ7Lo1yhYk5mPH6mtmLUn+1PAwoLQtE/yWkGCuPDU3avDz5f0SKXYV4dlkmvDXoRTNkwtGpTQCIVdwNyKW3JnOP/LPYE+Is9FQ8dxViFOSeanP74lQXhV5gKPboXN6aW2J6ox//MGFb5rZPGXmf6iG833OKcuwmDFEpghf7SKEk7A3bkUgGabGzbDqyeswrCX+TOk08jXg==
ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=ietf.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XU7NwZnqT8pZczr7EMWwfHY/fA+IwsjpOBjzPcx84iw=; b=Su75qdD/2bvDJ5hzt754bruTvjPbDVsMYQu/dKmQcV+pcISJ/+3zBLPEsTfiji/Nv6X+eUvtKaR4OSpKp9jsrmvmBA9eXbt2LI75pZ8smYidJ+mbdon6SMTy52DpmsMosMnnBdMI0tJYSPoy37th7rzdQRQXDd4pewJfSxaEB+M=
Received: from AS9PR07CA0026.eurprd07.prod.outlook.com (2603:10a6:20b:46c::31) by GVXPR08MB8233.eurprd08.prod.outlook.com (2603:10a6:150:3f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.15; Thu, 15 Sep 2022 14:48:53 +0000
Received: from VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::7e) by AS9PR07CA0026.outlook.office365.com (2603:10a6:20b:46c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.6 via Frontend Transport; Thu, 15 Sep 2022 14:48:53 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com;
Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C
Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT004.mail.protection.outlook.com (10.152.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Thu, 15 Sep 2022 14:48:52 +0000
Received: ("Tessian outbound 8ec96648b960:v124"); Thu, 15 Sep 2022 14:48:52 +0000
X-CR-MTA-TID: 64aa7808
Received: from 74372a51ce84.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7524F0CC-2D87-4B7A-9DED-D9BB4F432329.1; Thu, 15 Sep 2022 14:48:45 +0000
Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 74372a51ce84.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Sep 2022 14:48:45 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QFB3XKk2ml+pmPlYM1PKlhbikwtFxelOUWFQXi3p3SviNGEFiYlntG0ky5HM71gR7Ru2TZtYWG5GNGLVm8wZnkitiluen8bVXiScbsncaK+5dyPqjq3PqMSWv+6nZ0CNQ+WbG73Z5A7w39Dz+EinlXnyGn4GmigHIcLCIp6sRn+YkRzImd8hCk3HjXcPshoGuWThFOVlaLryNXjSm/BulM0/+hXLhI+Z6/qZyTlHJH10n5z8nMje1Kn63pbafYG9QPXdsY+8AJK7NbLYvU0b1jn2pbdLOuGDJkLskeB+KD7UxgQhdSzK5hHvqEyxNbMipbH2LubGRHtSMCgXh7ve/w==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XU7NwZnqT8pZczr7EMWwfHY/fA+IwsjpOBjzPcx84iw=; b=PNoYryfR+cRMArd8+v0bEPXgwVX5CJTbstvsX6Rq/xQXqBB5Jn5TnfbXMRtXFbRez4tRipTT2TxKmrGanuzY7i1BBi1Zx6oZtH5yqdfIiDW1fj7XaGWUF1vyjcXvdkFzZdIqoatIq/OhpN+0FAOPJu8isB4UtcA9uoinAkD20lnsElwvy/sNEBWxGSjr99wtg7WvZRN62ehFw9YhLqVu4TyK1dAValt+rlqyDQQLa0xTBlwSaGcohwf8Bq3QcNMl0N58R/li6x+ahx2KpDzvNkC48ALO5ZF+I4Bz47nLRZiM5lbRB5TwYpdw+gJmpJSl9Vx616vRoHr0m7wPKQHdlQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XU7NwZnqT8pZczr7EMWwfHY/fA+IwsjpOBjzPcx84iw=; b=Su75qdD/2bvDJ5hzt754bruTvjPbDVsMYQu/dKmQcV+pcISJ/+3zBLPEsTfiji/Nv6X+eUvtKaR4OSpKp9jsrmvmBA9eXbt2LI75pZ8smYidJ+mbdon6SMTy52DpmsMosMnnBdMI0tJYSPoy37th7rzdQRQXDd4pewJfSxaEB+M=
Received: from DBBPR08MB5915.eurprd08.prod.outlook.com (2603:10a6:10:20d::17) by AM8PR08MB6449.eurprd08.prod.outlook.com (2603:10a6:20b:364::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.15; Thu, 15 Sep 2022 14:48:43 +0000
Received: from DBBPR08MB5915.eurprd08.prod.outlook.com ([fe80::175:5593:658:8352]) by DBBPR08MB5915.eurprd08.prod.outlook.com ([fe80::175:5593:658:8352%5]) with mapi id 15.20.5632.015; Thu, 15 Sep 2022 14:48:43 +0000
From: Hannes Tschofenig <Hannes.Tschofenig@arm.com>
To: Ilari Liusvaara <ilariliusvaara@welho.com>, "cose@ietf.org" <cose@ietf.org>
Thread-Topic: Is the COSE public key encoding inefficient ... was RE: [COSE] Next steps with COSE-HPKE .... was RE: HPKE: Ephemeral public key encoding
Thread-Index: AdjJDpd42+/qrUslS06O3i+hjj+U6A==
Date: Thu, 15 Sep 2022 14:48:43 +0000
Message-ID: <DBBPR08MB5915C12E04BEB2E4259605EEFA499@DBBPR08MB5915.eurprd08.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ts-tracking-id: 8D77EF5B0C697C48BAB969E49FCC562F.0
x-checkrecipientchecked: true
Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
x-ms-traffictypediagnostic: DBBPR08MB5915:EE_|AM8PR08MB6449:EE_|VE1EUR03FT004:EE_|GVXPR08MB8233:EE_
X-MS-Office365-Filtering-Correlation-Id: 37ea9425-57f0-48cf-6bc4-08da97296857
x-checkrecipientrouted: true
nodisclaimer: true
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam-Untrusted: BCL:0;
X-Microsoft-Antispam-Message-Info-Original: nrnKvU1060KJuUGY4YgXzvfuNw0NV+Y5A//2XO48I0bN5p9HR7rAyRjCXuoNbfJrNgUsaUKrCep7UESeei9o0olsVBdzocBH7vc1wmfkeMlpYNJ6t8OUxHArLtRILL0UZFCV642xRnbo9DZ+tMD6BPpCBUNZsPnHFuliX7SGBkIANMc7SzKpBkZSMyAk++EhRntktF2ZAJIFgWjE7MhWrCZ/lN7ZmWVPMRqnxQn5QWgHD9upQp6sRdW2GhYZGu4H3WVdv+sGew9nrb8+ldK/ueMd++rBXdzqCuORkx2rnoFmISej29XE6INlOJ1J3c0oRop3Jo9XB6F+ePUfK+jMPhvZfVFqbJ2CIlK/lqrdu7K39T3X2AFMb1F9QdrhJEyuWT5dZMbES+UNetwmAP4OXczuikXq4WdQ/s/AUL6Gt5MjHE+/EzV86SkNf9EXhqUovowA4RwVcQNKyGFiXL/kNlNQ+wBJnolpmHC8GkZYIKHZP/mLEwuPk0VSgzKobKyMWisu5s3/cDlmLjvsR5Efk7MAWjOrYXb0TOi2rvXfoj9FNrUGYvc8+RIK+K4q62LFR9vjOdwp+aKyh5/WFTsrDLckZvlZuagQrRAeENQpW4MJX4Zcqn7MUO8s4tW8jLEpAmhWWUXkExRL5OKQ8yZiJO2w9j/ni2dkGRo4Vtx80//BTm+T1mXdGI/dZ7Hg+A/eWG8YI3xAnm+odLz3uNfcSvlKubgkZGPKLdvEENCH1Vm72T37wQdxlLfsDFRE6E1isPWpcjqRAAlAZwRWFXWfJ2+q+UQBgxqgE0sQOaE87digamApjDYjjmj4I+v/S0hXOymu2K05tUZsuX8w+3FSkg==
X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB5915.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(26005)(71200400001)(9686003)(6506007)(7696005)(53546011)(41300700001)(122000001)(38100700002)(110136005)(8676002)(66446008)(66476007)(76116006)(64756008)(66946007)(66556008)(52536014)(86362001)(33656002)(38070700005)(83380400001)(186003)(966005)(478600001)(55016003)(316002)(8936002)(5660300002)(2906002); DIR:OUT; SFP:1101;
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6449
Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
X-EOPAttributedMessage: 0
X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id-Prvs: b4a22448-e542-4531-da5d-08da972962f7
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: u1MfP0rJBBYjk2Xd5ee33AjEVAj9kEmDWHjkpY6e5KDUZARB4S4w3SSpJzpIP6EkZRKDejvXrJNMl8GBofXzpIIF9wxnCcS/Bod3uze9d3o81cD2PsMAD/SQZ6emiBOGI+MUnNprf7DjbtN5nuiEmWg6/0xGIVMwqQg/iCt/sTwCXC8XSOw0itIrZV04SVS+v7av0Kkvjs5KSM9ykzsEu7lXzK629nvjRD9M2dzXI4AHHCHdTAUkK7O21yHoGypG8uoLa6BNXg0aXVd3mNWzXHxSb7sDvVyqpRcANSGwXJznT1mJKHS0QSwycouugFMPKYVCoyI9jiXOGW0Gt+NqOGdRDS+JY/veHKvLrodV1OE9Qn1NRswczmuqkKEFsHQzI9M/89KziKGdB4iIxKEVEu8M5pW31GNlhl/gppudFa4Yb7CujODEr/lLxCgpj4Wu3sUknTinCzHJ8RnMIwekuWSpiYs8fuVilarmLC+3klaGS7TWnW3j9+3SJWSP0Jy41AvOIu2DFX5rAVe3B7UPc2EJzMaRSlWXMnQ1coIqeGOrM/KHXR75txrSxl4qPxueLtyQqgl5HBS69esYHqWToPLaXDTq1nsEg+B6AKxMQNb4Vooid0aF7CmLmN12cyAamCCe3qpOn3Uv/wzSGthf7Ul7mejKndM9zf66SmB2EJTV9WVAjQR/u3AUIJOF6GZ9Vc9bAqzUvnC1GdU+J4VWNOdjuf/ywOZrtz1wNDTb8MXvZ7N9jUBWmKT57uioR5Lx8nSR0GK9O82eym4gKecQ4gDk1OP/WskQFeDaByuTrAfTvQ8V6ozlGveoGZZRH1yFrFA3FRUMGxzE9xAD48Iugg==
X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(451199015)(46966006)(40470700004)(36840700001)(81166007)(82740400003)(86362001)(356005)(33656002)(47076005)(83380400001)(336012)(186003)(5660300002)(8936002)(2906002)(26005)(53546011)(9686003)(7696005)(36860700001)(6506007)(8676002)(41300700001)(52536014)(70206006)(70586007)(316002)(82310400005)(40480700001)(40460700003)(55016003)(966005)(478600001)(110136005); DIR:OUT; SFP:1101;
X-OriginatorOrg: arm.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2022 14:48:52.4797 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 37ea9425-57f0-48cf-6bc4-08da97296857
X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com]
X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB8233
Archived-At: <https://mailarchive.ietf.org/arch/msg/cose/zg-PfuD2uUi_YgrOJ11wFpGiBbw>
Subject: [COSE] Is the COSE public key encoding inefficient ... was RE: Next steps with COSE-HPKE .... was RE: HPKE: Ephemeral public key encoding
X-BeenThere: cose@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: CBOR Object Signing and Encryption <cose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cose>, <mailto:cose-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cose/>
List-Post: <mailto:cose@ietf.org>
List-Help: <mailto:cose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cose>, <mailto:cose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 15 Sep 2022 14:49:01 -0000
Hi Ilari, Hi Daisuke,
The main decision for the group is whether there is willingness to define new public key formats in addition to those already defined. A factor in the decision making might be whether the existing format is insufficient.
It turns out that neither COSE nor HPKE define new cryptographic algorithms. They just use them, including their encoding. Section 13.1 of RFC 8152 (COSE) defines the public key encoding of elliptic curve keys and references Section 2.2 of RFC 5480, which points to Section 2.3.3 "Elliptic-Curve-Point-to-Octet-String Conversion" in [SEC1]. Section 7.1.1 of RFC 9180 (HPKE) references the uncompressed Elliptic-Curve-Point-to-Octet-String in [SEC1], which is in Section 2.3.3. This means that COSE and HPKE use the same encoding for the public key (of the NIST curves).
Hence, all we are talking about here is carrying the information in slightly different ways. Let's take the P256r1, for example:
Your proposed public key format for NIST P256r1 where you dump the key into the -2 (x) field.
{
/ kty => OKP /
1: 1,
/ kid /
2: h'1F677209D1C5174C',
/ crv => -65537 (HPKE P256 with SHA256) /
-1: -65537,
/ X-Y coordinates /
-2: h'040E271193..69'
}
The existing format specified by COSE places the public key is separated into two fields, x and y. COSE also defines a compressed and an uncompressed encoding of the public key (which we discussed at the list).
(FWIW HPKE references the uncompressed format.)
Here is the uncompressed format:
{
/ kty => EC2 /
1:2,
/ kid /
2: h'1F677209D1C5174C',
/ crv => P-256 /
-1:1,
/ x => x-coordinate /
-2:h'0072...85e5c8f42ad',
/ y => y-coordinate /
-3:h'01dc...fe1ea1d9475',
}
Here is the compressed format:
{
/ kty => EC2 /
1:2,
/ kid /
2: h'1F677209D1C5174C',
/ crv => P-256 /
-1:1,
/ x => x-coordinate /
-2:h'0072...85e5c8f42ad',
/ y => y-coordinate (sign-bit) /
-3:true,
}
So, this raises the question where the optimization potential is? While the inefficiency was raised in discussions, I believe that this is not really the design goal here (as I will point out in my other email to Daisuke).
Ciao
Hannes
[SEC1] https://secg.org/sec1-v2.pdf
-----Original Message-----
From: COSE <cose-bounces@ietf.org> On Behalf Of Ilari Liusvaara
Sent: Thursday, September 1, 2022 7:02 PM
To: cose@ietf.org
Subject: Re: [COSE] Next steps with COSE-HPKE .... was RE: HPKE: Ephemeral public key encoding
On Thu, Sep 01, 2022 at 11:00:56PM +0900, AJITOMI Daisuke wrote:
> Hi Hannes and Ilari
>
> As an implementor of HPKE library
> (https://github.com/dajiaji/hpke-js) let me offer my opinion.
>
> I strongly agree with Ilari's opinion.
>
> I don't know what kind of discussions were held in IETF114, HPKE spec
> (RFC9180) defines that a sender's ephemeral key (enc : encapsulated
> key) output by KEM is an octet string.
> I see no point in converting to the existing public key structure (JWK
> for COSE), which would rather lead to more complex specifications and
> implementations, and cause security issues.
There is a video recording of the session on IETF youtube channel.
IIRC, it discussed the NIST curve case, but not the CFRG curves.
As for concerns about extending OKP to non-curves, OKP was meant for that from the very begninning and the specification specifically says that it does (albeit not in the clearest way).
For uncompressed NIST curves, such re-encoding would save some space, which can be surprisingly valuable.
For P-256, it allows compressing 65 bytes to 43.
For P-384, it allows compressing 97 bytes to 59.
For P-256, it allows compressing 133 bytes to 77.
Adding compact NIST curves to HPKE would make this obsolete, as keys are even smaller than the compressed ones given above. I think the COSE-HPKE spec should register the codepoints, unless someone else gets there first (there has been at least one I-D proposing exactly that, but it seems to have gotten stuck in some process hole).
> Of course, existing key structures could be used to represent the
> recipient's public key.
> However, the sender's ephemeral key depends on the recipient's public
> key information, and there is no need to specify the many parameters
> such as kty, crv, alg, etc. which is already determined by the
> recipient's public key.
Here, one potential issue is that the eph header is defined to take COSE_KEY and does not allow direct-bstr. There are a few options:
1) Define a new parameter that allows bstr.
Drawback: New parameter.
2) Redefine eph to allow bstr.
Drawback: Comparable to allowing int in kid, which was controversial.
3) Abuse symmetric kty.
Drawback: Wastes 3 bytes.
(My test implementation does the option 3.)
> In my opinion, the required attributes for the sender's ephemeral key
> related information are as follows:
> - kid: bstr. the recipient's public key identifier.
> - ek (or enc?): bstr. the sender's ephemeral public key.
> - kdf: int(2-byte). optional. the KDF identifier selected by the
> sender if the recipient's public key supports more than one KDF algorithm.
> - aead: int(2-byte). optional. the AEAD identifier selected by the
> sender if the recipient's public key supports more than one AEAD
> algorithm. kdf and aead might be able to be combined into one parameter.
> - ver: int (2-byte). optional?. the version of the HPKE application.
> An HPKE application will probably specify how to use INFO and AAD. It
> is necessary to define a version of the specification which could be updated.
>
> Finally, I think we can learn a lot from other standards that use HPKE:
> ECH, ODoH, and OHTTP quite naturally use "enc" as it is, as an octet string.
As what my test implementation of COSE-HPKE currently does:
- Public/Private keys are always OKP, with special crv values
(compressing long-term keys is not supported, since these infrequent
on constrained channels).
- The crv value also species the kdf to use (chosen to match kem as
closely as possible).
- kid is used for key filtering. Especially for COSE_Encrypt0, which
only does single attempt at decryption.
- alg is used for specifying AEAD to use, again using special values.
- The encapsulated key is put into eph field.
- This primarily abuses kty symmetric, k is the raw key.
- NIST curves can also use EC2 keys for compressed form, since
encapsulated keys are common on constrained channels.
- The crv and alg mappings are build time genrated from table. If
the underlying HPKE library supports it, adding new alg or crv
is one line addition.
- The underlying HPKE library has one major quirk: It has support
functions for that EC2 curve compression/decompression (going so
far as to use the COSE codepoints for designating the curves).
- If only single recipient is needed COSE_Encrypt0 can be used
instead of COSE_Encrypt saves few dozen bytes.
- There is 8MB message size limit when decrypting, but ciphertext
might not count. Largest message sizes I have tested exceed 20GB.
-Ilari
_______________________________________________
COSE mailing list
COSE@ietf.org
https://www.ietf.org/mailman/listinfo/cose
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
- [COSE] Is the COSE public key encoding inefficien… Hannes Tschofenig