4 ms·
wolfSSL releases a new product; wolfCOSE a zero alloc C embbedded COSE stack
- magicalhippo 6mo agoFor those of us not in the loop, COSE[1] is CBOR Object Signing and Encryption, with CBOR being a binary JSON alternative. It is patterned off JOSE, the JSON standards which includes favorites like JWK. [1]: https://www.rfc-editor.org/info/rfc9052/ https://www.rfc-editor.org/info/rfc9052/
- mgaunard 6mo agoso some sort of JWT alternative?
- SV_BubbleTime 6mo agoFor the most part yes. JWT is a part of JOSE. For most things CBOR, think binary JSON. I love me some CBOR, but Carl isn’t very adventurous in deviating from JSON (rightfully!) so I don’t expect a lot new in COSE if you have worked with JOSE. Other than the tagged data types, the main inconpatibiiiry in CBOR to JSON is that CBOR map keys can be integers and in JSON must be strings.
- formerly_proven 6mo agoCBOR and COSE are pretty bad formats. The original "rationale" for CBOR was that messagepack didn't distinguish bytes and strings, which was added around ~2013. Afterwards CBOR was changed up a bit from messagepack and became a decidedly worse format. And COSE just goes against every other principle of well-engineered crypto, but that's not particularly surprising giving it is a JOSE derivative. A good zero-order classifier for "is this signing format a dumpster fire" is whether the spec mentions canonical encodings.
- forty 6mo agoMoving to something else that JSON for this kind of thing is reasonable given the issues with parsing JSON which can cause 2 implementation to interpret it in 2 different ways. https://seriot.ch/security/parsing_json.html https://seriot.ch/security/parsing_json.html
- camgunz 6mo agoCBOR has other ways it's unsuitable; the spec has a whole section about it: https://datatracker.ietf.org/doc/html/rfc9052#name-cbor-encoding-restrictions https://datatracker.ietf.org/doc/html/rfc9052#name-cbor-enco...
- Asmod4n 6mo agoCOSE was invented to solve that gap wasn’t it.
- throwaway2037 6mo agoThis is a great blog and an incredible piece of research. Re-reading again today, makes me think of Emil Stenström's recently effort to use an LLM to write an HTML5 parser in pure Python [1] using the official HTML5 spec and their test cases. [2] Later, Simon Willison used an LLM to convert the pure Python source to JavaScript. [3] It seems reasonable to ask an LLM to write a "perfect" JSON parser given the RFC spec and massive test pack from seriot.ch. Regarding the "minefield" of JSON parsing, I used to lean on Google's Gson (Java) a lot in my early days. I thought Jackson FasterXML was "too complex". Later, I realised the mind-boggling number of configuration options was weirdly more sustainable (but more complex!), because I could carefully control each JSON parser/generator edge case. [1] https://github.com/EmilStenstrom/justhtml https://github.com/EmilStenstrom/justhtml [2] https://simonwillison.net/2025/Dec/14/justhtml/ https://simonwillison.net/2025/Dec/14/justhtml/ [3] https://simonwillison.net/2025/Dec/15/porting-justhtml/ https://simonwillison.net/2025/Dec/15/porting-justhtml/
- Neywiny 6mo ago2 things of notice in the readme as recently I've been in the efficient binary communication hunt: 1. .text size without clarifying the architecture, flags, and compiler is meaningless unless it's all rodata (and it's not) 2. Saying it takes 0 .bss and .data just means it allocates everything elsewhere and that can be helpful to know. Of course in compilation that'll also be dependent on how and for what it's built. To say it's zero alloc is incorrect or at best misleading. Here's a line of code that allocates a ton of stuff on the stack: https://github.com/wolfSSL/wolfCOSE/blob/b90b34abcba90aa7b8a895f4038616f3eb140308/src/wolfcose.c#L6125 https://github.com/wolfSSL/wolfCOSE/blob/b90b34abcba90aa7b8a... (previously pointed to another line but it was diluting my thesis). Anyone in embedded who's had to increase stack size to use a fancy function knows what I'm talking about. I'm looking at you, sscanf. Some of this code will allocate hundreds if not low thousands of bytes onto the stack. Which is maybe fine but don't say it's zero alloc just because it's all on the stack.
- wmwragg 6mo agoMy understanding of zero alloc is that there are no heap allocations i.e. use of a form of malloc. At least that has always been my experience, use of the stack is perfectly fine
- dezgeg 6mo agoSome stricter interpretations also require that maximum stack usage can be statically analyzed (ie. no recursion, no function pointers, no VLAs/alloca).
- uecker 6mo agoVLA usage can also be analyzed (e.g. when bounded in a simple way by a function argumen) and then may allow reduced stack usage compared to fixed-size arrays sized for a worst case.
- Asmod4n 6mo agoVLAs aren’t a mandatory part of any c standard and as such there are platforms which haven’t implemented them, such as windows.
- bigfootIRL712 6mo ago[dead]
- aidangarske 6mo ago[flagged]