Giter VIP home page Giter VIP logo

Comments (2)

cabo avatar cabo commented on July 17, 2024

Tag 24 actually takes a byte string for the embedded CBOR, and the code should be handling that just fine. I think what you are looking for is a slightly different tag, which I'll call "decode later" in this message (using tag 99 for exposition). Let's use the very simple data structure ยป17ยซ as the example for the embedded structure (single integer, encoded as h'11').

With tag 24, you first encode the data structure, then wrap in tag 24: resulting diagnostic notation is 24(h'11') (click to see the bytes). This makes the embedded data item easy to skip in one pointer forward movement.

With a new tag "decode later", there would be no byte string wrapper, resulting in 99(17).
Useful support for such a tag would switch the decoder into a "skip mode", where decoding is still needed to determine the length of the embedded data item, but no data structure creation takes place; the decoder would then just provide pointer/length to the application.
A decoder that doesn't know/implement that tag would still decode, and would provide the decoded data item to the application, which may or may not be useful depending on the use case.

I think this is an interesting idea, and we may want to go ahead registering such a tag. Can you describe in more detail how you would use such a tag?

from cn-cbor.

jimsch avatar jimsch commented on July 17, 2024

That is what I get for reading the text and not reading the table above.

What I was looking for was a way to avoid having the extra length bytes of a bstr when wrapping a cbor object. Thus for the COSE specification I was thinking in terms of encoding the content for the plain text as:

plaintext : bstr / tstr / #6.24(any)

This would allow me to avoid the additional bytes associated with having a length for a cbor object that is then wrapped into a binary container. However I still need to say don't do the decoding now because doing a decode/re-encode operation is potentially problematic as my re-encode may not match your original encode operation (mostly definite vs indefinite lengths) but some re-ordering and such could occur as well. In COSE this would also be applied to the protected map and potentially to the associated authenticated data fields. The first is definitely a map and the second will most likely contain cbor data if used in a constrained world.

There is only a space savings if the length of the embedded data is more than 24 bytes - so it would be more likely to be a space savings in the case of signed/mac-ed plain text rather than for the protected header or aad cases.

This might also have uses in the case where you have posited using the current tag definition. I assume this is mostly to do layering of things. Thus an upper layer includes something from a lower layer but keeps them separate in terms of the encode/decoder.

from cn-cbor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.