anweiss / cddl

Concise data definition language (RFC 8610) implementation and JSON and CBOR validator in Rust
https://cddl.anweiss.tech
MIT License
91 stars 13 forks source link

`bstr .size` with a range not working #228

Open Limeth opened 3 months ago

Limeth commented 3 months ago

As per the spec, it should be possible to use ranges to check the length of bstrs.

However, the following CDDL (not complete):

m = { field: bstr .size (16..1000) }

causes the following failure:

error validating at cbor location /"m"/"field": expected uint to be in range 16 <= value <= 1000, got Bytes([69, 165, 171, 144, 138, 177, 37, 69, 76, 17, 10, 115, 225, 54, 69, 118, 72, 158, 102, 133, 111, 170, 68, 43, 220, 43, 1, 47, 98, 192, 160, 178, 75, 141, 146, 180, 3, 38, 108, 173, 2, 7, 134, 57, 96, 148, 242, 57, 67, 136, 186, 144, 46, 216, 153, 85, 132, 95, 185, 211, 82, 87, 239, 142, 104, 234, 129, 80, 77, 3, 136, 238, 106, 116, 130, 225, 41, 22, 112, 124, 165, 99, 47, 113, 181, 109, 226, 169, 42, 33, 100, 217, 12, 206, 119, 180, 130, 39, 49, 214, 25, 220, 85, 161, 74, 31, 195, 12, 62, 232, 100, 126, 83, 52, 37, 15, 230, 249, 5, 94, 87])