Skip to content

[htool] Add missing RoT provisioning commands - #296

Open
willyzha wants to merge 4 commits into
google:mainfrom
willyzha:htool-provisioning-no-get-encryption-key
Open

willyzha wants to merge 4 commits into
google:mainfrom
willyzha:htool-provisioning-no-get-encryption-key

Conversation

@willyzha

Copy link
Copy Markdown

Add provisioning subcommands to htool:

  • provisioning write: Write a provisioning blob to RoT storage from a binary file.
  • provisioning store_secrets: Store encrypted secrets to the RoT from a binary file.
  • provisioning load_mldsa_key: Load an ML-DSA key onto the RoT from a binary file.
  • provisioning validate_and_sign: Add optional --output flag to save the signed payload.

Add provisioning subcommands to htool:
- provisioning write: Write a provisioning blob to RoT storage from a binary file.
- provisioning store_secrets: Store encrypted secrets to the RoT from a binary file.
- provisioning load_mldsa_key: Load an ML-DSA key onto the RoT from a binary file.
- provisioning validate_and_sign: Add optional --output flag to save the signed payload.
@willyzha
willyzha marked this pull request as ready for review September 15, 2026 16:30
Comment thread examples/host_commands.h Outdated
Comment thread examples/htool.c Outdated
Comment thread examples/htool.c Outdated
Comment thread examples/htool_provisioning.c Outdated
if (strlen(output_file) > 0) {
output_ptr = fopen(output_file, "wb");
if (output_ptr == NULL) {
printf("Error: %s, when attempting to open file: %s\n", strerror(errno),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I think that rest of the code prints error messages to stderr (example 1, example 2, example 3).

It is probably okay to leave this as it is for now to stay consistent with rest of the file, and change it later

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I updated this file to print errors to stderr.

Comment thread examples/htool_provisioning.h Outdated
- Document that the request header's `command` field holds a value
  from enum hoth_key_provisioning_command.
- Clarify that --key takes a raw 1312-byte ML-DSA-44 public key, not
  PEM or DER.
- Reword the store_secrets description: secrets are encrypted *with*
  the provisioning encryption key.
- Send error messages to stderr, consistent with the newer code in
  this file and the rest of the codebase.
Follows the convention used by chipinfo, payload_status and
opentitan_version: the host command codes and wire structs now live in
protocol/provisioning.h next to the code that uses them, and the device
I/O moves to protocol/provisioning.c.

examples/htool_provisioning.c keeps flag parsing, file I/O, the
security-version gate and user-facing output. Status codes, message text
and ordering are unchanged, so the existing tests pass with only the
crc32 -> libhoth_provisioning_crc32 rename. The rename is required
because protocol/provisioning.h is an installed header and a bare crc32
symbol would collide with zlib.

The mix of libhoth_hostcmd_exec (log read, validate-and-sign) and
libhoth_hostcmd_exec_v2 (write, commit, key provisioning) is carried
over as-is to keep this change behaviour-preserving.
@willyzha
willyzha force-pushed the htool-provisioning-no-get-encryption-key branch from ec78556 to 217ba3c Compare September 17, 2026 20:01
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