Subject: [Cbor] CDDL for CBOR+JSON, JC<> and CDDL tool

From: Laurence Lundblade <[email-masked]>
Date: Tue, 8 Mar 2022 09:59:03 -0800

I’ve been playing with the CDDL in rats-uccs-02 <https://datatracker.ietf.org/doc/html/draft-ietf-rats-uccs-02#appendix-A> and the cddl tool hoping it to validate both JSON and CBOR format tokens.

It looks to me like the CDDL, in particular the JC<> generic, is a workable way to handle variances between JSON and CBOR serialization. For example, I think it works for integer labels vs string labels and for enumerated values.  See below.

Use of the JC<> generic is both simplifying and improving the CDDL for EAT.  Makes it easier to read. So it seems to be a good thing. (PR <https://github.com/ietf-rats-wg/eat/pull/173> here if interested)

However, the cddl tool doesn’t seem to be doing very well with JC<>:
 - It seems to generate only JSON when you say “cddl uccs.cddl generate”.
 - It can’t verify JSON that it itself has generated. From the error messages it seems like its trying to decode the JSON as if were CBOR

I would be happy if you could explicitly tell the cddl tool the serialization to work with is either JSON or CBOR. It seems to auto-detect now and get it wrong sometimes.

I don’t mean to complain about the cddl tool too much. It’s very nice that it can do what it does and I can work around the issues.

I am curious about other folks experience with JC<>. It seems to be a good thing to me.

LL

   iss-claim-label = JC<"iss", 1>

   JSON-ONLY<J> = J .feature "json"
   CBOR-ONLY<C> = C .feature "cbor"
   JC<J,C> = JSON-ONLY<J> / CBOR-ONLY<C>