Add functions to generate DICE ML-DSA UDS TBS certificate - #31050
Conversation
| assert_eq!(endorsed_cert, GOLDEN_ECDSA_ENDORSED_CERT_OUTPUT_DATA); | ||
| } | ||
|
|
||
| // TODO: Add golden tests for MLDSA certificates once end-to-end provisioning test supports it |
| #include "sw/device/lib/testing/test_framework/check.h" | ||
| #include "sw/device/lib/testing/test_framework/ottf_main.h" | ||
| #include "sw/device/silicon_creator/lib/cert/dice.h" | ||
| #include "sw/device/silicon_creator/lib/cert/dice_mldsa.h" |
There was a problem hiding this comment.
I feel we messed up the deps that embedpqc test depends on DICE. It should be DICE depends on embedpqc, but not the other way around. We also shouldn't separate the header to dice_mldsa_api to workaround this.
Instead, we could define the minimum stack size in embedpqc instead, and move the check to dice-related tests.
There was a problem hiding this comment.
That seems like a good idea. The stack use should be a property of the ML-DSA implementation being used, and should be independent of the DICE module.
There was a problem hiding this comment.
not in this PR probably. I think this could be done independently (by me or anybody else) in a different PR?
92e7f66 to
0cf11f6
Compare
0cf11f6 to
9df61e1
Compare
|
Rebased on top of latest commit on |
9df61e1 to
5887873
Compare
| * additional logic to run a cleanup operation in case of error. Any return | ||
| * value from the cleanup procedure is ignored | ||
| */ | ||
| #define HARDENED_RETURN_IF_ERROR_WITH_TRY_CLEANUP(expr_, try_cleanup_expr_) \ |
There was a problem hiding this comment.
This is fine, but I take exception with "TRY" in the name. Among the variety of error code types we have in opentitan, most testing code uses status_t and there is a TRY macro that operates on status_t-returning functions that works in a similar way to the ? operator in rust: TRY either yields the "value" of status_t or returns out of the function with the error value.
I don't want this macro to be confused with things that TRY.
There was a problem hiding this comment.
Ack. That's a fair point. Changed the identifier to HARDENED_RETURN_IF_ERROR_WITH_CLEANUP_ATTEMPT
This commit changes DICE UDS certificate template and code to support generating ML-DSA TBS certificates - Add selectors for public key in template: "ecdsa-p256", "mldsa-44", and "mldsa-87" - Add selectors for signature in template: "ecdsa-p256", and "mldsa-87" - Add function to fill in TBS template for UDS to generate TBS certificate with ML-DSA algorithms - Update certificate generation for UDS ECDSA certificate to select `ecdsa-p256` for public key and signature to support existing UDS certificates using ECDSA algorithm - Add a new header file specifically for ML-DSA DICE API Tested by running `//sw/host/provisioning/orchestrator/tests:e2e_emulation_dice_cwt_cw340_test`, `//sw/host/provisioning/orchestrator/tests:e2e_emulation_dice_mldsa_cw340_test`, `//sw/host/provisioning/orchestrator/tests:e2e_emulation_cw340_test`, and `//sw/host/provisioning/orchestrator/tests:e2e_multistage_emulation_tpm_cw340_test` targets locally Also tested that golden test for UDS certificate generation work by testing `//sw/host/ot_certs:ot_certs_e2e_test_tests/uds_golden_tests_test` target locally Signed-off-by: Lovepreet Singh <lpsingh@google.com>
This commit creates 2 scratch stacks for DICE ML-DSA operations: 32 KiB for ROM_EXT, and 24 KiB for perso firmware, since perso firmware currently doesn't have enough SRAM available for 32 KiB scratch stack and ROM_EXT might merge other data in the 32 KiB stack ML-DSA 44 and ML-DSA 87 tiny tests are also updated to test that the runtime stack use is less than size of both the stacks Tested by running `//sw/device/silicon_creator/rom_ext/e2e/attestation:print_mldsa_certs_test_fpga_cw340_rom_ext`, `//sw/device/silicon_creator/rom_ext/e2e/attestation:print_certs_test_fpga_cw340_rom_ext`, `//sw/device/tests/embedpqc:mldsa44_tiny_test_sim_qemu_rom_with_fake_keys`, and `//sw/device/tests/embedpqc:mldsa87_tiny_test_sim_qemu_rom_with_fake_keys` targets locally Signed-off-by: Lovepreet Singh <lpsingh@google.com>
Since `ft_personalize` binary will be generated for SKUs that don't need ML-DSA support, this commit creates an empty library that those SKUs can link to the binary Signed-off-by: Lovepreet Singh <lpsingh@google.com>
5887873 to
0cf11f6
Compare
|
Pushed incorrect commit by mistake. Pushing new changes again |
0cf11f6 to
d2906f0
Compare
|
Incorrect force push: https://github.com/lowRISC/opentitan/compare/58878737b33f3a557d421693bcf65f8a5bd87291..0cf11f6b02b7825ca6ae9b8feb1f1dbd7ee6c47d Comparison link for changes made to address the comment: https://github.com/lowRISC/opentitan/compare/58878737b33f3a557d421693bcf65f8a5bd87291..d2906f08659bcd3b5790ed4d74bc5f1d65d8cff6 |
This PR adds code to generate DICE UDS ML-DSA TBS certificates with either an ML-DSA 44 or ML-DSA 87 public keys, and ML-DSA 87 signature
hjsontemplate for UDS certificate generation to add selectors which choose between the public key algorithm and signature algorithm. It also adds a function thatft_personalizecan use for DICE UDS ML-DSA certificate generation with ML-DSA 44 public key. Golden data tests added in PR [dice,ot_certs] Refactor: Supporting code changes for generating UDS certificate with ML-DSA algorithms #30974 are used to check the UDS certificates with EC-DSA public key and signatures are not affectedft_personalize.Changes are on top of PR #30974 and PR #31038