Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dice] Refactor some dice related constants and APIs #25023

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tommychiu-github
Copy link
Contributor

Some DICE key creation constants and utilities are invoked by several modules.
Refactor them for a better code reuse.

@tommychiu-github tommychiu-github requested a review from a team as a code owner November 6, 2024 04:19
@tommychiu-github tommychiu-github requested review from pamaury and removed request for a team November 6, 2024 04:19
@tommychiu-github
Copy link
Contributor Author

@timothytrippel for viz.

It'll be invoked by several modules, so move it to base:util library for
code reuse.

Signed-off-by: Tommy Chiu <[email protected]>
Both X509 and CWT DICE implementations need these definitions. Move it
out from the original source file for code reuse.

Signed-off-by: Tommy Chiu <[email protected]>
The autogen source from templates needs some more APIs to utilize the
Cbor structure, including
- calculate the size of a given cbor argument
- add a bstr/tstr header with size, and rewind the cursor
- copy the war data from input pointer to the CborOut buffer

Signed-off-by: Tommy Chiu <[email protected]>
return kErrorOk; \
} while (0)

inline rom_error_t cbor_write_out_init(struct CborOut *p, void *buf,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want to keep all of these inline functions in the header file and mark then static inline. You can still share them with everything that include the header. It ensure they get inlined without LTO: https://stackoverflow.com/a/47821267 (applies to all inline functions)

CborWriteBstr(data_size, data, p);
CBOR_CHECK_OVERFLOWED_AND_RETURN(p);
}
rom_error_t cbor_write_out_init(struct CborOut *p, void *buf,
Copy link
Contributor

Choose a reason for hiding this comment

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

all functions prototypes in the header file should have doxygen style comments: https://cs.opensource.google/opentitan/opentitan/+/master:sw/device/lib/testing/i2c_testutils.h;l=158

CborWriteBstr(data_size, data, p);
CBOR_CHECK_OVERFLOWED_AND_RETURN(p);
}
rom_error_t cbor_write_out_init(struct CborOut *p, void *buf,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
rom_error_t cbor_write_out_init(struct CborOut *p, void *buf,
OT_WARN_UNUSED
rom_error_t cbor_write_out_init(struct CborOut *p, void *buf,

?

Comment on lines +134 to +135
"//sw/device/silicon_creator/lib/cert:dice_keys",
"//sw/device/silicon_creator/manuf/lib:flash_info_fields",
Copy link
Contributor

Choose a reason for hiding this comment

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

why are these two deps needed here?

kUtilEcdsaP256SignatureComponentBytes =
kUtilEcdsaP256SignatureComponentBits / 8,
/**
* Size of an attestation signature component in 32b words.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Size of an attestation signature component in 32b words.
* Size of an ECDSA signature component in 32b words.

*/
kUtilEcdsaP256SignatureComponentBits = 256,
/**
* Size of an attestation signature component in bytes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Size of an attestation signature component in bytes.
* Size of an ECDSA signature component in bytes.

@@ -12,6 +12,23 @@
extern "C" {
#endif

enum {
/**
* Size of an attestation signature component in bits.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Size of an attestation signature component in bits.
* Size of an ECDSA signature component in bits.

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