Skip to content

[MLDSA-Support] Add MLDSA support to provisioning services (2/3)#293

Merged
willyzha merged 4 commits intolowRISC:mainfrom
willyzha:partial-mldsa-support-2
Mar 17, 2026
Merged

[MLDSA-Support] Add MLDSA support to provisioning services (2/3)#293
willyzha merged 4 commits intolowRISC:mainfrom
willyzha:partial-mldsa-support-2

Conversation

@willyzha
Copy link
Collaborator

Increase perso blob size limit to support larger MLDSA certificates.

The existing TLV structure allocated 12bits for data, which limits data to 4k. This is far too small for larger PQ algorithms.

This PR introduces a magic version component that if present as the first TLV in the blob will specify the version of the remainder of the blob. If the version TLV is not found it the perso blob will be assumed to use the legacy 16bit header for backwards compatibility.

This PR is chained on top of PR #292

@willyzha willyzha force-pushed the partial-mldsa-support-2 branch 7 times, most recently from 26c6820 to 24ca8bd Compare March 6, 2026 19:15
@willyzha willyzha requested a review from timothytrippel March 6, 2026 19:44
@willyzha willyzha marked this pull request as ready for review March 6, 2026 22:44
@willyzha
Copy link
Collaborator Author

willyzha commented Mar 6, 2026

@timothytrippel - I added definitions the increased TLV header, should we bring those same definitions over to the OpenTitan repo?

crthNameSizeFieldShift = crthSizeFieldWidth
crthNameSizeFieldWidth = 4
crthNameSizeFieldMask = (1 << crthNameSizeFieldWidth) - 1
sizeOfObjectHeaderV0 = 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should leave the comment saying where these originate from, and add a comment saying we need to update opentitan repo with new format (and file an issue in the opentitan repo to track this).

template="${CERTGEN_TEMPLATES[$i]}"
key="${CERTGEN_KEYS[$i]}"
endorsing_key="${CERTGEN_ENDORSING_KEYS[$i]}"
key_type="${CERTGEN_KEY_TYPES[$i]}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we consider it an error for the key type not to match the endorsing key type? is there a scenario we would ever want them not to match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it might make testing easier right now since OT firmware doesn't support producing MLDSA DeviceID public keys. For testing we can have the HSM certify the exiting ECDSA public keys with an MLDSA key from the HSM.

In the long term if we're ok with being prescriptive on exactly what algorithms we support we can probably enforce that the key_type == endorsing_key_type.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK lets file an issue to track updating this to trigger an error in the future then so we dont lose track

openssl x509 -req -engine "${ENGINE}" -keyform engine \
-in "${CSR_FILE}" \
-out "${CERT_FILE}" \
-days 7300 \
Copy link
Collaborator

Choose a reason for hiding this comment

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

this reminds me: can you file an issue to parameterize this in a follow-up PR? (so we don't forget)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

specifically parametrize the expiry?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes

@timothytrippel
Copy link
Collaborator

@timothytrippel - I added definitions the increased TLV header, should we bring those same definitions over to the OpenTitan repo?

Yes; let's file an issue over there to track and bring them over

Willy Zhang added 3 commits March 10, 2026 21:51
Signed-off-by: Willy Zhang <willyzhang@google.com>
Signed-off-by: Willy Zhang <willyzhang@google.com>
…sizing

Signed-off-by: Willy Zhang <willyzhang@google.com>
@willyzha willyzha force-pushed the partial-mldsa-support-2 branch from 24ca8bd to 307a341 Compare March 10, 2026 23:09
* Define perso blob version enum
* Remove isLegacyV0 helpers and use version helpers

Signed-off-by: Willy Zhang <willyzhang@google.com>
@willyzha
Copy link
Collaborator Author

@timothytrippel - I added definitions the increased TLV header, should we bring those same definitions over to the OpenTitan repo?

Yes; let's file an issue over there to track and bring them over

Filed lowRISC/opentitan#29432

@timothytrippel timothytrippel self-requested a review March 17, 2026 18:25
// - V1 Cert Header (32-bit)
size_t expected_size =
sizeof(perso_tlv_object_header_t) + sizeof(perso_tlv_cert_header_t) +
sizeof(perso_tlv_object_header_v0_t) + sizeof(uint16_t) +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is both the size of a v0 and v1 object added here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@willyzha did you see this?

@willyzha willyzha merged commit 6ff31b3 into lowRISC:main Mar 17, 2026
3 checks passed
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