Subject: [Rats] CDDL, CBOR and JSON for claims

From: Laurence Lundblade <[email-masked]>
Date: Thu, 9 May 2019 12:03:39 -0700

I’ve just looked at the SenML RFC <https://tools.ietf.org/html/rfc8428> as something similar to what we are doing. It describes how to encode sensor measurements in JSON, CBOR, XML and EXI. It does not use CDDL. 

While interesting to see, I was thinking we would instead use CDDL to describe the information model for claims. There would be generic rules for encoding into CBOR and JSON. The CBOR rules are just standard CDDL. JSON would start with these rules are here in CDDL Appendix E <https://tools.ietf.org/html/draft-ietf-cbor-cddl-08#appendix-E>.

One thing I am inclined to take from SenML is the definition of both a string and integer name/label/key for each claim. The integer name/label/key is used with  CBOR when the most compactness is desired. The string name/label/key is used with JSON and can also be used with CBOR if more readable CBOR is desired.  CWT  does this too. 

I would restrict names/labels/keys the way CBOR does in section 1.4 <https://tools.ietf.org/html/rfc8152#section-1.4>: label = int / tstr

I would allow bstr for values in CDDL and specify that the are base64URL encoded when encoded for JSON. Also need to figure out how to handle dates and times.

Comments?

LL

---

From: Henk Birkholz <[email-masked]>
Date: Fri, 10 May 2019 10:56:48 +0200

Hi Laurence

On 5/9/19 9:03 PM, Laurence Lundblade wrote:
> I’ve just looked at the SenML RFC 
> [...]
> It does not use CDDL.

Please have a closer look:

> https://tools.ietf.org/html/rfc8428#section-11

Spoiler: section 11 shows the CDDL data definition.

Actually, this RFC also illustrates a convenient way how to design a 
CDDL data definitions that enables you to provide support for both 
serialization in JSON an/or CBOR. There is a serialization-agnostic 
"body" (Figure 1) and then a branching for a "JSON-Specific CDDL" data 
definition (Figure 2) and/or a "CBOR-Specific CDDL" data definition 
(Figure 3).

Although it does not provide direct support for JSON (only SBOR), CoSWID 
also enables this option by using the same "mapping mechanism" for map 
member label names.

> https://github.com/sacmwg/draft-ietf-sacm-coswid/blob/master/concise-swid-tag.cddl

Viele Grüße,

Henk