Re: [PATCH v4 1/2] Import CBOR library
From: Alexander Graf
Date: Tue Oct 10 2023 - 03:55:57 EST
Hey Greg,
On 10.10.23 08:13, Greg Kroah-Hartman wrote:
On Mon, Oct 09, 2023 at 09:20:52PM +0000, Alexander Graf wrote:
To fully support the Nitro Secure Module communication protocol, we need
to encode and decode CBOR binary data. Import an MIT licensed library
from https://github.com/libmcu/cbor (commit f3d1696f886) so that we can
easily consume CBOR data.
What is "CBOR"? I don't see a description of it here.
CBOR is the "Concise Binary Object Representation"
(https://en.wikipedia.org/wiki/CBOR) binary format.
And I guess you are going to keep this in sync with upstream? Or do you
really need the full library here (you #ifdef the float stuff out), does
your module really need all of the functionality and complexity of this
library, or can it use just a much smaller one instead?
CBOR knows a total of 9 data types:
- Unsigned integers
- Signed integers
- Binary string
- UTF-8 string
- Arrays
- Maps (like a python dictionary)
- Semantic tag
- Bools
- Floats
Out of these, the NSM communication protocol uses all except Semantic
tags and Floats. The CBOR library that this patch imports does not have
special handling for Semantic tags, which leaves only floats which are
already #ifdef'ed out. That means there is not much to trim.
What you see here is what's needed to parse CBOR in kernel - if that's
what we want to do. I'm happy to rip it out again and make it a pure
user space problem to do CBOR :).
On top of the upstream code base, I added kernel module as well as
kernel header path awareness and made checkpatch happy.
If only the one module needs this, why not put it in the directory for
the module itself, and then when/if anyone else needs it, it could be
moved?
That sounds like a great idea! Let me do that :)
Alex
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879