Skip to content

Commit

Permalink
[ot] hw/opentitan: ot_otbn: compute checksum over LE values.
Browse files Browse the repository at this point in the history
The checksum computation is currently being computed over big-endian
order 48-bit values {imem, addr, value}, but the CRC32 checksum of an
OTBN application is actually computed over the values in little-endian
order. Replace the existing BE logic with little endian so that the
computed checksum is correct.
  • Loading branch information
AlexJones0 committed Dec 18, 2024
1 parent ec86037 commit 361c3d6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions hw/opentitan/ot_otbn.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,9 @@ static void ot_otbn_update_checksum(OtOTBNState *s, bool doi, uint32_t addr,
{
uint8_t buf[6];

/* BE or LE? */
stw_be_p(&buf[0], addr >> 2U);
buf[0] |= doi ? 0x80u : 0x00u;
stl_be_p(&buf[2], value);
stw_le_p(&buf[4], addr >> 2U);
buf[5] |= doi ? 0x80u : 0x00u;
stl_le_p(&buf[0], value);

s->load_checksum = crc32(s->load_checksum, buf, sizeof(buf));
}
Expand Down

0 comments on commit 361c3d6

Please sign in to comment.