Skip to content

Commit

Permalink
[ot] hw/opentitan: ot_hmac: Small HMAC updates
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
AlexJones0 committed Dec 11, 2024
1 parent e135b04 commit 149aa81
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hw/opentitan/ot_hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ static uint64_t ot_hmac_regs_read(void *opaque, hwaddr addr, unsigned size)
val32 |= R_STATUS_FIFO_FULL_MASK;
}
}
if (!(s->regs->cmd)) {
val32 |= R_STATUS_HMAC_IDLE_MASK;
}
} break;
case R_ERR_CODE:
val32 = s->regs->err_code;
Expand Down Expand Up @@ -610,8 +613,10 @@ static void ot_hmac_regs_write(void *opaque, hwaddr addr, uint64_t value,
}

s->regs->cfg =
val32 & (R_CFG_HMAC_EN_MASK | R_CFG_SHA_EN_MASK |
R_CFG_ENDIAN_SWAP_MASK | R_CFG_DIGEST_SWAP_MASK);
val32 &
(R_CFG_HMAC_EN_MASK | R_CFG_SHA_EN_MASK | R_CFG_ENDIAN_SWAP_MASK |
R_CFG_DIGEST_SWAP_MASK | R_CFG_KEY_SWAP_MASK |
R_CFG_DIGEST_SIZE_MASK | R_CFG_KEY_LENGTH_MASK);

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

0 comments on commit 149aa81

Please sign in to comment.