Re: [COSE] Help with RFC8152 encryption example

Carsten Bormann <cabo@tzi.org> Mon, 10 May 2021 10:35 UTC

Return-Path: <cabo@tzi.org>
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 E72A33A1770 for <cose@ietfa.amsl.com>; Mon, 10 May 2021 03:35:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.197
X-Spam-Level:
X-Spam-Status: No, score=-4.197 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 ugxvW0CfNr7Q for <cose@ietfa.amsl.com>; Mon, 10 May 2021 03:35:20 -0700 (PDT)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 4F2EC3A176E for <cose@ietf.org>; Mon, 10 May 2021 03:35:20 -0700 (PDT)
Received: from smtpclient.apple (p548dcb12.dip0.t-ipconnect.de [84.141.203.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4Fdy9x3QGjzyWK; Mon, 10 May 2021 12:35:17 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <b9138e0c-a63f-bb15-11f1-b7c4519ebf2e@gmail.com>
Date: Mon, 10 May 2021 12:35:16 +0200
Cc: cose@ietf.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <BEEEB4E5-5FAC-4EA6-88FD-23D7B031C7AB@tzi.org>
References: <b9138e0c-a63f-bb15-11f1-b7c4519ebf2e@gmail.com>
To: Anders Rundgren <anders.rundgren.net@gmail.com>
X-Mailer: Apple Mail (2.3654.80.0.2.43)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cose/t5U_VRQs_CGVIEjwHsQhNpZiMM0>
Subject: Re: [COSE] Help with RFC8152 encryption example
X-BeenThere: cose@ietf.org
X-Mailman-Version: 2.1.29
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, 10 May 2021 10:35:25 -0000

Hi Anders,

> On 10. May 2021, at 11:24, Anders Rundgren <anders.rundgren.net@gmail.com> wrote:
> I took this simple sample:
> https://datatracker.ietf.org/doc/html/rfc8152#appendix-C.4.1
> 
> and adjusted it to fit Carsten's http://cbor.me/
> 
> 16(
>      [
>         {
>             1:10
>          } ,
>        {
>           5:h'89f52f65a1c580933b5261a78c'
>        },
>         h'5974e1b99a3a4cc09a659aa2e9e7fff161d38ce71cb45ce460ffb569'
>      ]
> 
> It returns 51 bytes but the RFC says 52 bytes.

The example in the RFC is (comments removed)

16([h'A1010A', {5: h'89F52F65A1C580933B5261A78C'}, h'5974E1B99A3A4CC09A659AA2E9E7FFF161D38CE71CB45CE460FFB569’])

Or, if you enable cbor.me to show embedded CBOR [1],

16([<< {1: 10} >>, {5: h'89F52F65A1C580933B5261A78C'}, h'5974E1B99A3A4CC09A659AA2E9E7FFF161D38CE71CB45CE460FFB569’])

http://cbor.me/?bytes=D0(83(43(A1010A)-A1(05-4D(89F52F65A1C580933B5261A78C))-58.1C(5974E1B99A3A4CC09A659AA2E9E7FFF161D38CE71CB45CE460FFB569)))

Your example however is missing the 43 byte: The map {1:10} needs to be, CBOR encoded, kept in a byte string.

Grüße, Carsten

[1]: https://datatracker.ietf.org/doc/html/rfc8610#appendix-G.3