Skip to content

Conversation

@tahina-pro
Copy link
Member

@tahina-pro tahina-pro commented Oct 30, 2025

So far EverCBOR only supported the deterministic encoding of CBOR (IETF RFC 8979 Section 4.2.1.)

This PR introduces CBORNondet, a verified CBOR parsing and serialization library supporting definite-length non-deterministic encoding of CBOR. As a major contribution, CBORNondet checks for map key duplicates in the basic data model, using an amount of stack proportional to the nesting of maps in map entry keys. The user can specify such a bound when calling the CBORNondet parser.

This PR introduces a safe C API for CBORNondet, with as few preconditions as possible: liveness of pointers (but not necessarily the fact that they are not null), consistency of array lengths, and data invariant on values of CBOR object type, but nothing more. In particular, CBORNondet accessor functions no longer require a specific major type on the CBOR object being accessed: for instance, cbor_nondet_map_iterator_start will gracefully fail if applied to a non-map CBOR object.

TODO:

More hypothetical:

  • Allow use of CBORDet objects in CBORNondet. This might be necessary for COSE, but we are not sure yet. Note that we do not intend to implement full determinization of CBORNondet objects, because this is not reasonably implementable in constant stack space (thus, we do not intend to support using CBORNondet objects in CBORDet.)
  • Add support for floating-point values. This is contingent on ongoing IETF CBOR working group discussions about equivalence of NaNs for the purpose of map key comparisons, which are not fully standardized yet.
  • Add support for extended data models, such as big integers including the domain of regular integers. CBOR.Spec.Raw.Valid.fsti and CBOR.Spec.Raw.Nondet.fst are generic in the data model, but their implementations CBOR.Pulse.Raw.Nondet.Compare.fst and CBOR.Spec.Raw.fst only support the basic data model.

@tahina-pro tahina-pro marked this pull request as ready for review December 10, 2025 04:26
@tahina-pro tahina-pro merged commit 0637b87 into project-everest:master Dec 10, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant