-
Notifications
You must be signed in to change notification settings - Fork 771
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
base: master
Are you sure you want to change the base?
Conversation
@timothytrippel for viz. |
e6ba2ed
to
3567df4
Compare
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]>
3567df4
to
6c60a5c
Compare
return kErrorOk; \ | ||
} while (0) | ||
|
||
inline rom_error_t cbor_write_out_init(struct CborOut *p, void *buf, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
?
"//sw/device/silicon_creator/lib/cert:dice_keys", | ||
"//sw/device/silicon_creator/manuf/lib:flash_info_fields", |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Size of an attestation signature component in bits. | |
* Size of an ECDSA signature component in bits. |
Some DICE key creation constants and utilities are invoked by several modules.
Refactor them for a better code reuse.