Skip to content

Commit 88177f8

Browse files
AlexJones0jwnrt
authored andcommitted
[ot] hw/opentitan: ot_otbn: compute checksum over LE values.
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.
1 parent ba4a94b commit 88177f8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

hw/opentitan/ot_otbn.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,9 @@ static void ot_otbn_update_checksum(OtOTBNState *s, bool doi, uint32_t addr,
523523
{
524524
uint8_t buf[6];
525525

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

531530
s->load_checksum = crc32(s->load_checksum, buf, sizeof(buf));
532531
}

0 commit comments

Comments
 (0)