Skip to content

Service messages#76

Merged
werwurm merged 47 commits intomainfrom
werwurm/service_messages
Sep 26, 2025
Merged

Service messages#76
werwurm merged 47 commits intomainfrom
werwurm/service_messages

Conversation

@werwurm
Copy link
Contributor

@werwurm werwurm commented Sep 26, 2025

Implements marshalling and unmarshalling for DICE service messages using
CBOR encoding.

Similar to n20_stream_t which offers safe writing to a buffer
n20_istream_t offers a safe way to read from a buffer lowering the risk
for out of bounds access.
Add primitives for parsing CBOR headers, extracting slices of
octet and text strings, and recursively skipping unknown fields.
Implements marshalling and unmarshalling for DICE service messages using
CBOR encoding.
Move certificate format enum to nat20/constants.h
n20_istream_get_slice now returns a boolean and fills an n20_slice_t
structure, which allows for more consistent control flow.
This patch also adds the n20_istream_get_string_slice variant, which
fills an n20_string_slice_t structure instead.

Complete test coverage for stream module.
@github-actions
Copy link

LCOV of commit 1721d1c during lcov-test-coverage-report #38

Summary coverage rate:
  lines......: 96.1% (2420 of 2517 lines)
  functions..: 99.5% (194 of 195 functions)
  branches...: 87.3% (1373 of 1573 branches)

Files changed coverage rate: n/a

Copy link

@azsteinb azsteinb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stamp

@werwurm werwurm merged commit ab73ebc into main Sep 26, 2025
13 checks passed
Copy link

@azsteinb azsteinb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. Haven't dived deep into the service tests yet.

Comment on lines 228 to 253

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff is not in the other PR, but lgtm

Comment on lines 163 to 188
@@ -121,6 +172,7 @@ enum n20_error_s {
* if the context given is valid.
*/
n20_error_crypto_invalid_context_e = 0x1001,

/**
* @brief Indicates that an input key argument was NULL.
*
@@ -132,6 +184,7 @@ enum n20_error_s {
* @sa n20_crypto_context_t.sign
*/
n20_error_crypto_unexpected_null_key_in_e = 0x1002,

/**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the hex value errors specifically only for crypto errors?

Comment on lines 269 to 283

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused parsing the values in the vectors. What does the 0xf6 mean here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vs the 0x40

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, wait, I understand it now. Disregard.

Comment on lines 120 to 126

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I understand these values are pretty clear in the cbor parsing world, but it may be worth creating constants for better legibility from those not super familiar with cbor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants