-
Notifications
You must be signed in to change notification settings - Fork 107
Description
I've been using the library for a while now, and am currently implementing COSE (RFC 9052). One thing that would be a really nice addition for me is to include pointers (or an index) to the start and end of the raw CBOR data to the cbor_item_t. This would avoid me needing to wrap CBOR items in an additional bytestring if I want to pass the raw CBOR around in my program.
For example if I have this nested map in CBOR:
A1646B657931A1646B657932187B
Diagnostic notation:
{"key1": {"key2": 123} }
And if I want to extract the nested map A1646B657932187B, ({"key2": 123}), and pass it around as raw bytes, this cannot be done (AFAIK, please correct me if I'm wrong). What I have to do is wrap the nested map in a bytestring 48A1646B657932187B and then I can pass it around my program as I wanted. I don't want to burden my client applications with wrapping each object in a bytestring.
I envision it could look something like this:
typedef struct cbor_item_t {
...
unsigned char *start_ptr; // point to first byte of the item in the the raw cbor encoding
size_t length; // length of the item in the raw cbor encoding in bytes
} cbor_item_t;Or if adding to the cbor_item_t is a no go, perhaps a utility function that can calculate it?
Would it be possible to add this? Thanks in advance. Note: I could also try to take a crack at it if needed.