Subject: [Cbor] Simple value clarification

From: "Lundblade, Laurence" <[email-masked]>
Date: Sun, 6 Nov 2016 22:36:13 +0000

Is there a difference between these two ways of encoding simple values?
1) true, false… encoded as f4, f5.. f7
2) true false… encoded as  f8 14, f8 15… f8 17

- Table 2 implies they should be the same to me
- CBOR playground doesn’t consider them the same outputting "simple(20)” for input f8 14
- The parenthetical in section 2.3 implies representation 2) is shouldn’t be used because it is confusing, but doesn’t explicitly forbid it

My choice of resolution would be:

true, false… are always encoded as f4… f7, never as f8 14… f8 17

encodings f8 00 ... f8 1f are not allowed and are malformed cbor upon which a parser will error out. If you want to encode a simple value less than 24, use of e0 … f7 is required.

The encodings of unassigned simple values available to extend CBOR are:
0… 19 which must be encoded as e0 … f3
32 … 255 which must be encoded as f8 20 … f8 ff

LL

---

From: Carsten Bormann <[email-masked]>
Date: Mon, 7 Nov 2016 01:56:12 +0100

Hi Laurence,

thank you for your input!

> 2) true false… encoded as  f8 14, f8 15… f8 17

Don’t do (2).

> - Table 2 implies they should be the same to me

That is on the data model level, where you don’t see the difference.

> - CBOR playground doesn’t consider them the same outputting "simple(20)” for input f8 14

That seems to be a bug in the tool*) — it should reject that value according to the text between Table 1 and Table 2.

> - The parenthetical in section 2.3 implies representation 2) is shouldn’t be used because it is confusing, but doesn’t explicitly forbid it

… only the values 32 to 255 are
   used. …

sounds pretty normative to me (yes, we could have sprinkled a MUST there).
But maybe we should revisit that text to be clearer.

> true, false… are always encoded as f4… f7, never as f8 14… f8 17

Yes.

> encodings f8 00 ... f8 1f are not allowed and are malformed cbor upon which a parser will error out. If you want to encode a simple value less than 24, use of e0 … f7 is required.

Yes.

> 32 … 255 which must be encoded as f8 20 … f8 ff

Exactly.

Grüße, Carsten

*) interestingly, I just got another bug report for that tool…  Need to spend some quality time with it soon.

---

From: "Lundblade, Laurence" <[email-masked]>
Date: Mon, 7 Nov 2016 16:41:38 +0000

Thanks for the confirmation.

Seems worthy of errata for the RFC to me. Someone getting the wrong idea could lead to an interop problem, particularly since cbor.me doesn’t complain.

LL