Skip to content

Commit 87f7771

Browse files
committed
Added Unicode NFC requirement for strings. Added numeric encoding test vectors by LL. Added LL as author.
1 parent 3c7e479 commit 87f7771

File tree

1 file changed

+87
-2
lines changed

1 file changed

+87
-2
lines changed

draft-mcnally-deterministic-cbor.md

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,20 @@ author:
3232
name: Carsten Bormann
3333
organization: Universität Bremen TZI
3434
35+
-
36+
name: Laurence Lundblade
37+
organization: Security Theory LLC
38+
3539

3640
normative:
3741
RFC8949: CBOR
3842
RFC8610: CDDL
3943
CDE: I-D.draft-ietf-cbor-cde
4044
IANACDDL: IANA.cddl
4145
IANACBORTAGS: IANA.cbor-tags
46+
UNICODE-NORM:
47+
title: "Unicode Normalization Forms"
48+
target: https://unicode.org/reports/tr15/
4249

4350
informative:
4451
BCSwiftDCBOR:
@@ -180,6 +187,16 @@ dCBOR decoders:
180187
2. MUST reject any encoded major type 7 values other than `false`, `true`, `null`, and the floating point values.
181188
{:start="2"}
182189

190+
## Strings
191+
192+
dCBOR encoders:
193+
194+
1. MUST only emit text strings that are in Unicode Normalization Form C (NFC) {{UNICODE-NORM}}.
195+
196+
dCBOR decoders:
197+
198+
2. MUST reject any encoded text strings that are not in NFC.
199+
183200
# CDDL support, Declarative Tag
184201

185202
Similar to the CDDL {{-CDDL}} support in CDE {{CDE}}, this specification adds two CDDL control operators that can be used to specify that the data items should be encoded in CBOR Common Deterministic Encoding (CDE), with the dCBOR application profile applied as well.
@@ -251,7 +268,7 @@ Vulnerabilities regarding dCBOR will revolve around whether an attacker can find
251268

252269
RFC Editor: please replace RFCXXXX with the RFC number of this RFC and remove this note.
253270

254-
This document requests IANA to register the following CBOR tag in the "CBOR Tags" registry of {{IANACBORTAGS}}:
271+
IANA has registered the following CBOR tag in the "CBOR Tags" registry of {{IANACBORTAGS}}:
255272

256273
| Tag | Data Item | Semantics | Reference |
257274
|:----|:----------|:----------|:----------|
@@ -266,9 +283,77 @@ This document requests IANA to register the contents of Table 1 into the registr
266283
| .dcborseq | \[RFCXXXX\] |
267284
{: title="CDDL Control Operators for dCBOR"}
268285

286+
# Appendix A: dCBOR Numeric Test Vectors
287+
288+
The following tables provide common and edge-case numeric test vectors for dCBOR encoders and decoders, and are intended to exercise the requirements of this specification.
289+
290+
## dCBOR Numeric Encodings
291+
292+
| Value | dCBOR Encoding | Note |
293+
|:------|:---------------|:-----|
294+
| 0 | `00` | |
295+
| 1 | `01` | |
296+
| 23 | `17` | |
297+
| 24 | `1818` | |
298+
| 255 (2<sup>8</sup> – 1) | `18ff` | |
299+
| 65535 (2<sup>16</sup> – 1) | `19ffff` | |
300+
| 65536 (2<sup>16</sup>) | `1a00010000` | |
301+
| 4294967295 (2<sup>32</sup> – 1) | `1affffffff` | |
302+
| 4294967296 (2<sup>32</sup>) | `1b0000000100000000` | |
303+
| 18446744073709551615 (2<sup>64</sup> – 1) | `1bffffffffffffffff` | |
304+
| -1 | `20` | |
305+
| -2 | `21` | |
306+
| -127 (–2<sup>8</sup> – 1) | `387e` | |
307+
| -128 (–2<sup>7</sup>) | `387f` | |
308+
| -32768 (–2<sup>16</sup>) | `397fff` | |
309+
| -2147483648 (–2<sup>31</sup>) | `3a7fffffff` | |
310+
| -9223372036854775808 (–2<sup>63</sup>) | `3b7fffffffffffffff` | |
311+
| 1.5 | `f93e00` | |
312+
| 2345678.25 | `fa4a0f2b39` | |
313+
| 1.2 | `fb3ff3333333333333` | |
314+
| 42.0 | `182a` | Reduced. |
315+
| 2345678.0 | `1a0023cace` | Reduced. |
316+
| -2345678.0 | `3a0023cacd` | Reduced. |
317+
| -0.0 | `00` | Reduced. |
318+
| 5.960464477539063e-08 | `f90001` | Smallest half-precision subnormal. |
319+
| 1.401298464324817e-45 | `fa00000001` | Smallest single subnormal. |
320+
| 5e-324 | `fb0000000000000001` | Smallest double subnormal. |
321+
| 2.2250738585072014e-308 | `fb0010000000000000` | Smallest double normal. |
322+
| 6.103515625e-05 | `f90400` | Smallest half-precision normal. |
323+
| 65504.0 | `19ffe0` | Reduced. Largest possible half-precision. |
324+
| 33554430.0 | `1a01fffffe` | Reduced. Exponent 24 to test single exponent boundary. |
325+
| -9223372036854774784.0 | `3b7ffffffffffffbff` | Reduced. Most negative double that converts to int64. |
326+
| 18446744073709550000.0 | `1bfffffffffffff800` | Reduced. Largest double that can convert to uint64, almost UINT64_MAX. |
327+
| 18446744073709552000.0 | `fa5f800000` | Just too large to convert to uint64, but converts to a single, just over UINT64_MAX. |
328+
| -18446742974197924000.0 | `fadf7fffff` | Large negative that converts to float, but too large for int64. |
329+
| 3.4028234663852886e+38 | `fa7f7fffff` | Largest possible single. |
330+
| 3.402823466385289e+38 | `fb47efffffe0000001` | Slightly larger than largest possible single. |
331+
| 1.7976931348623157e+308 | `fb7fefffffffffffff` | Largest double. |
332+
| Infinity (any size) | `f97c00` | Canonicalized. |
333+
| -Infinity (any size) | `f9fc00` | Canonicalized. |
334+
| NaN (any size, any payload) | `f97e00` | Canonicalized. |
335+
336+
## Invalid dCBOR Encodings
337+
338+
These are valid CBOR encodings that MUST be rejected as invalid by a dCBOR-compliant decoder.
339+
340+
| Value | CBOR Encoding | Reason for Rejection |
341+
|:------|:-----|:-------|
342+
| 12.0 | `f94a00` | Can be reduced to 12. |
343+
| 1.5 | `fb3ff8000000000000` | Not preferred encoding. |
344+
| -9223372036854775809 (-2<sup>63</sup> – 1) | `3b8000000000000000` | 65-bit negative integer value. |
345+
| -18446744073709551616 (-2<sup>64</sup>) | `3bffffffffffffffff` | 65-bit negative integer value. |
346+
| Infinity | `fb7ff0000000000000` | Not preferred encoding. |
347+
| Infinity | `fa7f800000` | Not preferred encoding. |
348+
| -Infinity | `fbfff0000000000000` | Not preferred encoding. |
349+
| -Infinity | `faff800000` | Not preferred encoding. |
350+
| NaN | `fb7ff9100000000001` | Not canonical NaN. |
351+
| NaN | `faffc00001` | Not canonical NaN. |
352+
| NaN | `f97e01` | Not canonical NaN. |
353+
269354
--- back
270355

271356
# Acknowledgments
272357
{:numbered="false"}
273358

274-
The authors are grateful for the contributions of Joe Hildebrand, Laurence Lundblade, and Anders Rundgren in the CBOR working group.
359+
The authors are grateful for the contributions of Joe Hildebrand and Anders Rundgren in the CBOR working group.

0 commit comments

Comments
 (0)