NordicSemiconductor / zcbor

Low footprint C/C++ CBOR library and Python tool providing code generation from CDDL descriptions.
Apache License 2.0
105 stars 34 forks source link

zcbor_decode: Allow deciding at run-time whether to enforce canonical data #407

Closed oyvindronningstad closed 3 months ago

oyvindronningstad commented 4 months ago

Currently the decoder fails if ZCBOR_CANONICAL is defined and it receives non-canonical data. Instead, add a bool to the constant state to decide whether to enforce. ZCBOR_CANONICAL decides the default value for the bool.

Also fix various things related to constant_state

Gracefully handle constant_state being missing. Always use ZCBOR_ERR_INVALID_VALUE_ENCODING for non-canonical data.

oyvindronningstad commented 3 months ago

@plskeggs Thanks, added a bit of explanation to the README.

plskeggs commented 3 months ago

@oyvindronningstad when do you expect this to be available in NCS main?