laurencelundblade / ctoken

Encodes and decodes CWT, EAT and similar format tokens. It supports COSE format signing and verification as well as the UCCS unsigned format.
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link
c cwt eat iot rfc-8392

ctoken

Ctoken is a library that implements CWT, EAT and UCCS:

These define a token format that is a list of label-value pairs called claims. They are usually signed with public key crypto using the COSE format.

This code only encodes and decodes the claims in the CBOR format. It doesn't create them as that is very dependent on the operating environment and such.

This relies on t_cose for the COSE-based signing format. t_cose can use OpenSSL crypto or MBed TLS crypto. Other crypto can be added through the t_cose crypto adaptor layer..

This relies on QCBOR for CBOR encoding and decoding.

See also xclaim, a command line tool for creating and displaying CWT, EAT and UCCS tokens. It is implemented using ctoken.

Cake Diagram

Claims Supported

EAT is an extension to CWT, so ctoken supports all the CWT claims. CWT was created for authentication, not attestation, so some of the CWT claims don't apply directly for attestation.

CWT Claims

The descriptions of these are in JWT. CWT is a CBOR version of JWT. Detailed descriptions of these claims are in RFC7915.

EAT Claims

Other claims are defined or in the process of being defined, but not yet implemented.

PSA Token Claims

Generic data types for claims

The ctoken library has some general functions for general data types. The values of many claims are one of these, so these are very useful. All that's needed beyond calling this is the label / key that identifies the particular claim.

Code Size

This implementation is intended for embedded use so code size and memory use are kept small. For the most part it is a very thin layer on top of QCBOR and t_cose. A lot of the functions are inline and don't really add any code size. The largest chunk of code is for EAT submodules.

Standards Status

CWT is a stable IETF standard described in RFC 8392. It is not expected to change, but new claims will be added to the IANA CWT registry.

EAT is an up and coming standard in development in the RATS working group. It is in flux and parts of it are likely to change. See draft-ietf-rats-eat-08

UCCS is a CWT that is not signed. See draft-birkholz-rats-uccs-02

PSA Token is also implemented here. It is a derivative of EAT and is also proposed as an IETF standard. It may also change. See draft-tschofenig-rats-psa-token-04

Code Status

This is a refactoring of the initial attestation code that was written for trustedfirmware.org. That code is well tested so most of this code is also well tested.