-
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,cwt] Add CWT implementation #24835
Conversation
I unintentionally close the former PR (#24824) while resolving the conflicts. WRT to the dup of #24754, the thought is to have a reference implementation & output, for cross checking against the auto-codegen. |
645bd60
to
682b807
Compare
I am not sure I understand why you want to have a manual C implementation. If you want to have a reference implementation and output, I would suggest to follow the same approach as for the X509 certificates: have a reference rust implementation (easier to review in my opinion) and check that the rust and autogenerated C implementation yield the same results. |
* Helper function to convert an attestation certificate signature from little | ||
* to big endian. | ||
*/ | ||
static void curr_tbs_signature_le_to_be_convert(ecdsa_p256_signature_t *sig) { |
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.
A similar function exists in https://cs.opensource.google/opentitan/opentitan/+/master:sw/device/silicon_creator/lib/cert/dice.c;drc=40107c126540a065de2de6c55c92a3f9f4ca5c49;l=122 ; lets move it to a util lib and share between dice.c and dice_cwt.c
@@ -149,6 +363,8 @@ rom_error_t dice_cdi_1_cert_build(hmac_digest_t *owner_measurement, | |||
cert_key_id_pair_t *key_ids, | |||
ecdsa_p256_public_key_t *cdi_1_pubkey, | |||
uint8_t *cert, size_t *cert_size) { | |||
// TODO(lowRISC/opentitan:#24281): implement body | |||
HARDENED_RETURN_IF_ERROR( | |||
dice_cdi_0_cert_build(owner_measurement, owner_security_version, key_ids, |
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.
The owner_manifest_measurement
is missing from the cert. This contains the measurement of the "owner configuration block", should this be included?
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.
Yep, it can be part of the "Authority Descriptor"
// CWT sizes | ||
enum { | ||
kCoseKeyEcP256SizeBytes = 77, | ||
kCdi0MaxPayloadSizeBytes = 448, |
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.
is Cdi1 the same max size?
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.
No, it'll be different if we include owner_manifest_measurement in the CSR.
These constants will be calculated against the template thus we don't need to define manually.
I agree with @pamaury here. The reference rust implementation would be more consistent with how the X.509 certs are implemented too, and we can reuse the rust implementation in host code to parse the device generated certs as well. Also there should be unittests generated for your device code as well to test its correctness. If this is really just a stepping stone until #24754 is implemented, and all the manually implemented code will be replaced shortly, could you please comment exactly the locations in the code that will be replaced by #24754? |
Thanks for the input. And to align with the X509 implementation (codegen, unit test, verifier), I'll set the manual CDI implementation to "draft" for now, till we complete all the related changes. |
682b807
to
8df6d0d
Compare
66a60c2
to
e94fabf
Compare
Verification result for this implementation.
|
@tommychiu-github What is the tool you used to verify this chain? the |
Yes, I'm using hwtrust tool from the Android source tree - https://source.corp.google.com/h/googleplex-android/platform/superproject/main/+/main:tools/security/remote_provisioning/hwtrust/src/;l=1 |
c9ed06e
to
9d93ac1
Compare
9d570ec
to
b26205b
Compare
b26205b
to
2c64cde
Compare
2c64cde
to
35f9a82
Compare
Add some helper functions and a CDI_* builder manually.
Some of the changes in the builder will be replaced by a following RP on opentitantool > codegen feature.