Re: [COSE] cose-cbor-encoded-cert nameConstraints encoding

Göran Selander <goran.selander@ericsson.com> Mon, 01 August 2022 06:45 UTC

Return-Path: <goran.selander@ericsson.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 289F4C1594A8 for <cose@ietfa.amsl.com>; Sun, 31 Jul 2022 23:45:57 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.692
X-Spam-Level:
X-Spam-Status: No, score=-7.692 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.582, 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_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=ericsson.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 Shts5ic-7dYZ for <cose@ietfa.amsl.com>; Sun, 31 Jul 2022 23:45:52 -0700 (PDT)
Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2072.outbound.protection.outlook.com [40.107.20.72]) (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 CBDBEC14F74F for <cose@ietf.org>; Sun, 31 Jul 2022 23:45:51 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I6nBq8wGMTDQqqSdmpfrI5hzJZP9iyq99oLt3GFrV8/IKj1z0aLJwqRDUvqMFxt9FLO1Ugig5RqReMvrBU6VDxq7sHhS9ZXmjM19MG3FTDFpO0T7WM2BTpCsayk2J8avZQTA0jJjqbNOM68mFDE/ThRZEnvYekxj6oj5VNXLr62vLzOe86v9ltjX1HivIN8esdhmELX33V5cqQmJ7qcaljKEJyeenA59iWCvDgaBtKWSUKX+cxYQgseleT8oQgtFcOx89fBnntnf2WZ+fs4tbeSTcn+HAla69x+AzHuCxlBdqPv01i4diDui5CSkZztR43sGfndVx0+n/4wh0a/u/g==
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=t7oIYAELc0PxGrVTkLuysWQrrWh1sgRw/Cxoq+EXvSw=; b=C2wAdmdL/+83i7WVUcuzbYnyQbk2ccQkbLluMInDliTO4YBYPoovPw6POu71m4zX78nlR9mIqppEaFJgzEbgbgLZuqw0ePQ6J9HwR/BQe1GuSrfP3t9zeYSft0gAHAxBKnbfS3mngraX9Har94t+IFAL80fYLXFM4ca6QvqapFIa1B4R42y4TxJtTnP4KHR8cngHft5+3z3FzKFKFdwaSW3xGrFAt3cMHKWWUlN1u+x8sgX1yp4DrCPaYmH70tG9/3eGk54X2eydQ3r7+MokA+M7YrUJZY3W0jdhvTx+CKPBUZMOoPm+0JWVOWHG8U/2agdGATymN2fUEIF26k/oZA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ericsson.com; dmarc=pass action=none header.from=ericsson.com; dkim=pass header.d=ericsson.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t7oIYAELc0PxGrVTkLuysWQrrWh1sgRw/Cxoq+EXvSw=; b=dfYKRUru+o1Gg3tH/vCpEd23kD2Fepu+kbEgaNnRg+zMbplnYEZ27zEveFpc3lMv/Ku42y5YsEm2vLRI4LhuJfZ3DxDfUjkPV5QI87vSFUPP/1t+ZkxNTRovcCaSjlSo4nG8FIWVMjuOKKywmIijGIePepmqMBBQtxTh/8CrJaQ=
Received: from PAXPR07MB8844.eurprd07.prod.outlook.com (2603:10a6:102:24a::19) by DB9PR07MB7067.eurprd07.prod.outlook.com (2603:10a6:10:211::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.12; Mon, 1 Aug 2022 06:45:47 +0000
Received: from PAXPR07MB8844.eurprd07.prod.outlook.com ([fe80::e047:d5c7:12e1:f04]) by PAXPR07MB8844.eurprd07.prod.outlook.com ([fe80::e047:d5c7:12e1:f04%4]) with mapi id 15.20.5504.010; Mon, 1 Aug 2022 06:45:47 +0000
From: Göran Selander <goran.selander@ericsson.com>
To: Ilari Liusvaara <ilariliusvaara@welho.com>, "cose@ietf.org" <cose@ietf.org>
CC: "Miguel Garcia, Armando" <armando.miguel.garcia@aisec.fraunhofer.de>, Joel Höglund <joel.hoglund@ri.se>
Thread-Topic: [COSE] cose-cbor-encoded-cert nameConstraints encoding
Thread-Index: Adig5E2LJpw1dMsDRcCu/frbqyzc3AAHDPWAARusQfw=
Date: Mon, 01 Aug 2022 06:45:47 +0000
Message-ID: <PAXPR07MB884427CA452BFDD6548F42D7F49A9@PAXPR07MB8844.eurprd07.prod.outlook.com>
References: <DM6PR14MB218696340AC6E5AC3933D19A92949@DM6PR14MB2186.namprd14.prod.outlook.com> <YuABp6yWJq0pkYxE@LK-Perkele-VII2.locald>
In-Reply-To: <YuABp6yWJq0pkYxE@LK-Perkele-VII2.locald>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ericsson.com;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: d6cf716f-327c-44a4-2922-08da73897756
x-ms-traffictypediagnostic: DB9PR07MB7067:EE_
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: AmGMSPYqeSLnJUOiZnweotYtaPYPUHToEsu3+VsFWmP7etglcP4YiygU3iu9ojCGbjhJNkLvISiUcd/TCqvYrLrheq8+bqwsdksAzuTFygqH7Tmnav7699/3ts8sq0qbM5AENbfJF0QINca+bHF/yjF0A0IlLWSDFWqC6Qv3bcmGWcqxq7ywKQRBCE/VgtpSOQFlP4ge1CHFA2tbpvMGZ0Xlu0HFPEKOdblhcugtASeKy6TiiPg9V5GwkcqTtk4fnyqSnlj2xIcOFHRxI1IP8NaJ3PTcuQe6MB+ArXw+xx4kLXGbZWNWwD2IzhBhuF86VSk+n84jemKg/KcLVjKg+17P9anMjG08VoLKUqNJ/ryrBw+jtOgq43sDBszx0aKNa/8LK2mZOPANI6yzhHS0oFMSWAFjMAk9vUvsCvcMCoTu5imLjSFa31I87GStOOp+toGU8i1umCYDnVHH4hYbYS06cHaY0trCeG9FzTIgALo6qyoBfzjjGfrAutxr0Qd8MVbBsccljDOdQPWJa+1CytWy5mqa16WhYXfVMgzeHi+kP0HNn/l6zVFhiYmdz77BpkJLuWxPUglYpTJKLLXo8CIZ2yBMqrpiTX/LjaV4jqk5eZUFeHeqYlpC5HWtIuiO2G/HFN0zDylqgRAZbV43lELlWRD8RqknXzvw0LM34AAZeq4fge+ooSJJMk0SGnyiki8KwU9/9pFgNxZfbgDnK87ZGNVQO7YOd/goPaBD1wA2Ta9xKcwT/tUUOJTvWm8tlnGz04Mou2Yxc9LO0B4Jx4mRjr5ngN+TAFMVfGkgW4mtNl1UBE0kvitxRqfCzPLlWYwXhLr5rlCzkS+zTDVxdHUEpREbmf2qxKWN0T34cjBGD5PY5C9Cl+a/M952hd8l
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR07MB8844.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(136003)(39860400002)(376002)(366004)(346002)(53546011)(7696005)(6506007)(26005)(38070700005)(9686003)(86362001)(33656002)(91956017)(55016003)(122000001)(38100700002)(66574015)(186003)(82960400001)(83380400001)(166002)(478600001)(316002)(52536014)(966005)(8936002)(5660300002)(8676002)(4326008)(71200400001)(64756008)(66476007)(66446008)(66946007)(66556008)(76116006)(2906002)(54906003)(110136005)(41300700001); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: SKXB7jXyftCKgzqHTw0Xu8WoEH5bmBA/cg2RE98rtq+ZIGecbQ3V0fAnO7U/R8j/rpEUSKIGJlMCIzbxnl9ULEtBrBce98AR350eWwMMzEHNo/46fM4uj1aYRQHP+wki3GMqh4rfUCtjR4bk980EObxjmyvjXrIE+vUTmsn7gckaJ5P8mNmJ3EnMUYpvceoG9O16kN00gHA05VKbOy1kc3cfTzGO6MyvkTPHHzLS8Wq5EpbBxiy8tsFPrXvVj4Y8XP9IO6KFBcJyRNnb1WTNazlBiYEU2NVodOHqW+V3N3bgLTRLvpE5ciz1Mdg1/+vheNz4oAK8Mqh+y/qawXYx9d4mr2YMj0rhZInhAPC+rfLYY6VeUUmulWTMyabFDnc/HOe94yS/2KC6qUpLjROF4aeNuW0PE8FrR0IQFx4qbs9pIQwNSqearzyH1Mw98HRijl8/6hG1fMaRVX+LLam8nHWXdbT9MISqKebd2Q+/cfVxE1IJ0AzwvnAb/9auC9Z6b/ScT9kRHaQV5tDEP4bzzHpZkLkn5gFeQD1Gb0ftm/9UEr+8K78zVH1nzJBdRmtDeQcc2MOlBkUNhe75p5oTol+3KiaVni0RaG+IfoEQ73J74vZDwl+2uAwRT5BDiCD2lwBiZb6QyFbMvuQ49pv5wp3+cOq5h2sC4Dab72WjeoXiu/5DJmQ17juXGBEsVg3BgN/GTdNAZ1wHZrEfuH5Bc1pDvaSa9nz2qLUpphAgvQtA2WHrFty/oCi2/CwfUioSzlHmeCUnyLEKzvUwk8ptLkY5leqRn+60z2Su+HFJrp2b4oAnJFAjkpgwIyQKe5lreMUmx3r6496D7PPYOySgO8egWwrnacEKzd0VElyLE5iI6J2rx00hjNs4B3zRGgZU1jAuyMptoExESb7G84Jp8Z+GUKXe3yamiZqoLNSkiGXNkDWkPrDNMk/ZDximlBV9odIbcSYfG0xP0CWX8F4ehq8ULJLZ/PGWnuoSFY+bdBpc92721hiXv63Lqm62K2x3251oSAL7pAfC+vQNPh2M1BWL+22HpuHb5jR2p2eMNcr5CLlF9EXgB0qNPV3vW+eNVicbMl0EnOHZmH6YebY0Hryc4dAXCkSKudC3IVdnvnosXbIkItIPRTSniBYRprjm2GLzKVYlzjRvuVjGOn/iNeTL9kd81vHE+cOQ8/hElbaeqMLUTVQrUpBNXZ+gaESJtwhF6wv3Qa0fjZnB2Di6H7oV+3OxM/2HGkiV3Qaf2+YW7FmP6GNY2RbsuoOI13c0jA3I0/Z8Gy7ViY3QmC3UHi11gUqSKN0l/bHtAyGXfgOlkvC2U4VxhUN7b4BF6NooWQmCAQ73qREbPpNRJG6KmGjJ0lKpCeFV8RESouo0YIGAHZgG3HVp/LF9TfKNdpCMbpe7mbeM5U767clnmHGsCkFRVH97+3SDENxZMlFkQORbVhYbOjG5/6+G3lhGBsJzWRxMURL4JCrFsRYUGaQ+/sKl2w3KzMSgMm3VgaJGdf5JhMZdRD23hCjPPtM2/9C7tVvxklmsQoPxSv12GOB7X/i88xgrOZXEznq71YT9+7SncipUjzK1lezwp6v4JLcpE55dmDTIWFxq1CwIlUketf6fUmoGwyCvSyQ0vC8BxEo=
Content-Type: multipart/alternative; boundary="_000_PAXPR07MB884427CA452BFDD6548F42D7F49A9PAXPR07MB8844eurp_"
MIME-Version: 1.0
X-OriginatorOrg: ericsson.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: PAXPR07MB8844.eurprd07.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: d6cf716f-327c-44a4-2922-08da73897756
X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Aug 2022 06:45:47.5570 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 92e84ceb-fbfd-47ab-be52-080c6b87953f
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: ULGXdbfnoHsr59yPYpQJp7P+2C8adWKWqhhrf7yzfjLmH1TYPz7d/8QTQr0C/WFICdRyAtsWx4QgrCpjf7j7lIBcq4Wc3oyI+cfNvmx0z4A=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB7067
Archived-At: <https://mailarchive.ietf.org/arch/msg/cose/bs-sZ6Lx6dHiLkWve5o5ISUtet4>
Subject: Re: [COSE] cose-cbor-encoded-cert nameConstraints 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: Mon, 01 Aug 2022 06:45:57 -0000

Hi Ilari, and all,

Many thanks for the detailed comments with issues and proposed resolution!

Unfortunately we are now in a slow phase with vactions and parental leave but the  plan to get back with an update before the next IETF meeting.

Noting the increased interest and the announced [1] ongoing C-implementation by Fraunhofer AISEC, maybe someone else will pick up on these comments earlier?
[1] https://github.com/cose-wg/CBOR-certificates/issues/93

Just two minor comments in-line below.

From: COSE <cose-bounces@ietf.org> on behalf of Ilari Liusvaara <ilariliusvaara@welho.com>
Date: Tuesday, 26 July 2022 at 17:02
To: cose@ietf.org <cose@ietf.org>
Subject: Re: [COSE] cose-cbor-encoded-cert nameConstraints encoding
On Tue, Jul 26, 2022 at 12:07:53PM +0000, Corey Bonnell wrote:
>
> In reviewing the latest draft of cose-cbor-encoded-cert, I noticed that
> section 3.3 [1] defines GeneralSubtree as the following:
>
> GeneralSubtree = [ GeneralName, minimum: uint, ? maximum: uint ]
>
>
>
> However, RFC 5280 section 4.2.1.10 [2] says:
>
>
>
> "Within this profile, the minimum and maximum fields are not used with
>    any name forms, thus, the minimum MUST be zero, and maximum MUST be
>    absent.  However, if an application encounters a critical name
>    constraints extension that specifies other values for minimum or
>    maximum for a name form that appears in a subsequent certificate, the
>    application MUST either process these fields or reject the
>    certificate."
>
>
> Given this, I don't think it is necessary to provide "minimum" and "maximum"
> fields as they are static ("minimum" is always 0 and "maximum" is always
> absent) in an RFC 5280-compliant certificate; a list of GeneralName for the
> GeneralSubtree is sufficient.

I have written a test CBOR X509 codec.

[GS] The term ”C509” as abbreviation for CBOR encoded X509 certificates is not rooted yet. What does the WG think, is “CBOR X509” a better term?

>From its issue notes, I found a
related issue note:

 "GeneralName can start with uint, so it is pretty nasty to determine
 if any uint in maximum position is in fact a maximum or start of
 next name. This probably will not work at all if GeneralName ever
 gains a type that can take uint as argument. And since minimum has
 a default, it is in fact optional, so the only required field is
 the GeneralName one."

However, the issue resolution note is busted (broken CDDL), and looking
at the code, the minimum/maximum handling is FUBAR.

In light of Corey's above mail, I just ripped out the minimum/maximum
handling, making those generate extension unencodeable if present.

Now each X.509 GeneralSubtree is encoded as CBOR GeneralName.

[GS] This sounds like the right approach.

Göran



        Some other notes I found:




 Certificate policies extension:

  The qualifier value field is of type dependent of qualifier id.
  Different qualfiers seem to put different things there. CPS seems
  to be IA5String, and unotice seems to be sequence{text}. If some cert
  has something else, who knows what the value is. The value field in
  CBOR is text, so sticking raw ASN.1 blobs is not possible.

  => Only qualifiers id-qt-cps and id-qt-unotice are supported.

* Key Usage extension:

  The present encoding seems to be ambiguous. For example, both 06 C0
  (committing signature certificate) and 01 06 (CA certificate) seem
  to encode as integer 3. With 1 prepended, those encode as integer 7
  and integer 131 respecively.

  => Prepend 1 bit to key usage before encoding.

* Name Constraints extension:

  Both permitted and excluded fields are optional, but the spec is not
  clear how missing field is encoded. The cbor-cert spec allows for
  empty array, while PKIX does not allow empty field. However, for
  implementations, it would be easier to encode absent field as
  null.

  => Encode missing permitted/excluded as null.

* Subject Directory Attributes extension:

  The ASN.1 is effectively list of tuples of OID and set.
  The CBOR is tuple of OID and set. There is no obvious way to map
  between the two. Furthermore, the present construction produces
  two values, which is not legal for extension, which can only
  produce one.

  => Use SubjectDirectoryAttributes = [+Attributes]

* Attribute table:

  Presently jurisdictionOfIncorporationCountryName and domainComponent
  both have id 21.

  => Encode domainComponent as 22.

* AS numbers extension:

  Is there a reason the numbers can not backjump?

  => Encode backjumps by overflowing 32-bit ASN.

* "AS Resources v2 (id-pe-ipAddrBlocks-v2)":

  I presume the OID should be id-pe-autonomousSysIds-v2.

* Section about "IP Resources" talks about "previous ASid".

  This looks odd...

* IPv6 address encoding can overflow:

  In encoding IPv6 addresses, the address differences can overflow
  uint. However, I do not expect this happening outside pathological
  cases, especially as CBOR ints go to full size of IPv6 subnetwork
  identifier.

* The encodings of Brainpool curves:

  The payload seems to be 20 octets, but the topmost TLV has length of
  19.

  => Fix topmost TLV length to 20 (0x14).

 * The encodings of ANSSI curve:

  The payload seems to be 21 octets, but the topmost TLV has length of
  19.

  => Fix topmost TLV length to 21 (0x15).

* Authority Key Identifier Extension:

  In pile of CA certs I have laying around, about 1/10 lack keyid in
  AKI.

  => Encode absent keyid as null.


Throwing the pile of CA certs I have at the implementation:

* 24 certificates have fatal errors that prevent compression:
  - 15 have bad notBefore
  - 3 have EKU explicitly not critical
  - 2 are X509v1 certificates
  - 2 have disagreeing signature algorithms
  - 1 has negative serial number
  - 1 has bad notAfter
* 15 certs hit error encoding CRL Distribution Point:
  ("Entry is not a pure DISTRIBUTION_POINT")
* 405 certs hit error encoding Certificate Policies:
  - 326 "Unsupported VisibleString notice"
  - 42 "Unsupported BMPString notice"
  - 29 "Unsupported notice reference"
  - 8 "FFCS VisibleString"
- 5 certs hit error encoding Authority Key Identifier:
  ("Invalid serial in AKI").
- 236 certs have Authority Key Identifier without keyid.




-Ilari

_______________________________________________
COSE mailing list
COSE@ietf.org
https://www.ietf.org/mailman/listinfo/cose