Re: [Teep] JSON/JOSE vs. CBOR/COSE

Carsten Bormann <cabo@tzi.org> Fri, 21 February 2020 11:29 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: teep@ietfa.amsl.com
Delivered-To: teep@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id BD713120255 for <teep@ietfa.amsl.com>; Fri, 21 Feb 2020 03:29:39 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.199
X-Spam-Level:
X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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 JSQDrhrC8ASG for <teep@ietfa.amsl.com>; Fri, 21 Feb 2020 03:29:37 -0800 (PST)
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 48BCA120236 for <teep@ietf.org>; Fri, 21 Feb 2020 03:29:37 -0800 (PST)
Received: from dynamic-218-i.informatik.uni-bremen.de (dynamic-218-i.informatik.uni-bremen.de [134.102.218.208]) (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 48P8PV40Zpzyd9; Fri, 21 Feb 2020 12:29:34 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <a16d028a-43cf-bb5f-f21c-e26315280a2c@sit.fraunhofer.de>
Date: Fri, 21 Feb 2020 12:29:34 +0100
Cc: "Konda, Tirumaleswar Reddy" <TirumaleswarReddy_Konda@McAfee.com>, Mingliang Pei <mingliang.pei=40broadcom.com@dmarc.ietf.org>, Nicolae Paladi <nicolae.paladi@ri.se>, Hannes Tschofenig <Hannes.Tschofenig@arm.com>
X-Mao-Original-Outgoing-Id: 603977374.411396-ffcd1f12016ecdd7977421d6d5debefc
Content-Transfer-Encoding: quoted-printable
Message-Id: <7CE83214-D432-48EA-A7EA-FFE8AEF3E73D@tzi.org>
References: <AM6PR08MB37181998F4E68A7F6BCC8110FA130@AM6PR08MB3718.eurprd08.prod.outlook.com> <59627424-2BE9-4E52-8F57-B7853D71023C@ri.se> <CABDGos7T5rjN4qHUyg_ptC+uB4gEjY26pe3=Z+Kky-LG5gkHDQ@mail.gmail.com> <CY4PR1601MB125438E2058280B86B32F650EA120@CY4PR1601MB1254.namprd16.prod.outlook.com> <a16d028a-43cf-bb5f-f21c-e26315280a2c@sit.fraunhofer.de>
To: "teep@ietf.org" <teep@ietf.org>
X-Mailer: Apple Mail (2.3608.60.0.2.5)
Archived-At: <https://mailarchive.ietf.org/arch/msg/teep/G7lPa4_Tmrgg9k4Rd5-2kJ9qCqg>
Subject: Re: [Teep] JSON/JOSE vs. CBOR/COSE
X-BeenThere: teep@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: A Protocol for Dynamic Trusted Execution Environment Enablement <teep.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/teep>, <mailto:teep-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/teep/>
List-Post: <mailto:teep@ietf.org>
List-Help: <mailto:teep-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/teep>, <mailto:teep-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 21 Feb 2020 11:29:40 -0000

On 2020-02-21, at 10:48, Henk Birkholz <henk.birkholz@sit.fraunhofer.de> wrote:
> 
> use cbor-diag

Just in case this term is not well-known:
CBOR diagnostic notation was originally defined in Section 6 of RFC 7049 and has been extended in Appendix G of RFC 8610.

https://tools.ietf.org/html/rfc7049#section-6
https://tools.ietf.org/html/rfc8610#appendix-G

Every JSON text also is an instance of CBOR diagnostic notation, i.e., CBOR diagnostic notation is a strict superset of JSON.

A few tools support CBOR diagnostic notation, e.g.,

	gem install cbor-diag

… and then convert for example with

	diag2cbor.rb foo.diag >foo.cbor

(See below for more info.)

There is also support in https://crates.io/crates/cbor-diag-cli

Grüße, Carsten



gem install cbor-diag

gives you the tools:

cbor2diag.rb
cbor2json.rb
cbor2pretty.rb
cbor2yaml.rb
diag2cbor.rb
diag2pretty.rb
json2cbor.rb
json2pretty.rb

which do pretty much what you would expect them to do, given these
definitions:

"cbor" is binary CBOR.
"diag" is CBOR's diagnostic notation.
"json" is JSON.
"pretty" is the pretty-printed representation of binary CBOR as used by
cbor.me.).
"yaml" is YAML.

Output is to stdout, input from stdin or files given as command line
arguments). (json2cbor.rb also has a -v option.)