lowRISC / lowRISC/opentitan

[opentitantool] Fix sha256 byte ordering

Open
#25,870 0 comments 0 reactions 1 assignee View on GitHub

@cfrantz is already working on this.

Since Jan 14, 2025.

SW:opentitantool Type:Bug
Dominant language
SystemVerilog
Stars
3.6k
Forks
1.1k
Avg merge
2d 22h
Merged PRs (30d)
141

Description

### Description

When opentitantool computes the SHA256 digest over a firmware image, it emits the SHA256 in reversed byte order.

This is a historical error related to the endianness selection in the OT HMAC peripheral. However, it has led to additional byte-reversal machinery being needed in hsmtool and other opentitantool commands. It has possibly resulted in a bug in the PreHashedSha256 mode of sphincsplus verification in the ROM.

1. Fix the output of the SHA256 digest from opentitantool
2. Fix the digest input in other opentitantool commands.
3. Fix the digest input in hsmtool.
4. Add an "input-bytes-reversed" flag if needed to compensate for the ROM implementation.
5. Fix occurrences of passing the `--little-endian` flag to hsmtool (consider the `input-bytes-reversed` case and the preferred representation of the signature output).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.