Skip to content

Commit b439c6e

Browse files
committed
[ot] hw/opentitan: Small HMAC updates
Reports `IDLE` in the status register if no command is currently being processed (i.e. no START/CONTINUE/PROCESS/STOP in progress). Allows the new KEY_SWAP, DIGEST_SIZE and KEY_LENGTH fields of the config registers to be written to by stopping them from being masked out. Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
1 parent d43044a commit b439c6e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hw/opentitan/ot_hmac.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ static uint64_t ot_hmac_regs_read(void *opaque, hwaddr addr, unsigned size)
486486
val32 |= R_STATUS_FIFO_FULL_MASK;
487487
}
488488
}
489+
if (!(s->regs->cmd)) {
490+
val32 |= R_STATUS_HMAC_IDLE_MASK;
491+
}
489492
} break;
490493
case R_ERR_CODE:
491494
val32 = s->regs->err_code;
@@ -610,8 +613,10 @@ static void ot_hmac_regs_write(void *opaque, hwaddr addr, uint64_t value,
610613
}
611614

612615
s->regs->cfg =
613-
val32 & (R_CFG_HMAC_EN_MASK | R_CFG_SHA_EN_MASK |
614-
R_CFG_ENDIAN_SWAP_MASK | R_CFG_DIGEST_SWAP_MASK);
616+
val32 &
617+
(R_CFG_HMAC_EN_MASK | R_CFG_SHA_EN_MASK | R_CFG_ENDIAN_SWAP_MASK |
618+
R_CFG_DIGEST_SWAP_MASK | R_CFG_KEY_SWAP_MASK |
619+
R_CFG_DIGEST_SIZE_MASK | R_CFG_KEY_LENGTH_MASK);
615620

616621
/* clear digest when SHA is disabled */
617622
if (!(s->regs->cfg & R_CFG_SHA_EN_MASK)) {

0 commit comments

Comments
 (0)