-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Summary
We need a way to validate that decoded data is deterministicly encoded.
Description
We need an optional flag when decoding cbor thats supposed to be deterministically encoded.
- A Context variable to the encoder should allow the encoder to fail if the data is not deterministically encoded, to log warnings, or to silently accept.
Tasks:
- For complex types which are encoded as stings, or bytes, arrays or maps, there is nothing to do except that variable encoding may not be used.
- For simple types, integers, etc. MiniCbor has a function to give you the length of a value in cbor, to check if the value was properly encoded, all that needs to happen is:
- Get the start of the value in the byte stream before its decoded,
- Get the end after its decoded
- Make sure that length matches minicbors stated length for that value.
- If it does, it was deterministically encoded.
- For maps, keys must be in the correct order. See: https://datatracker.ietf.org/doc/html/rfc8949#name-length-first-map-key-orderi See comment below for suggested solution.
The Deterministic Map decoder helper should be made in a general way so it can be re-used for different data structures.