Skip to content

[ot] hw/opentitan: ot_aes: preserve external state when a new message is started #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

luismarques
Copy link

The AES block does not clear the CPU-visible registers when starting a new message. Only "the state registers inside the cipher core are cleared with PRD during the last round of every encryption/decryption."

Fixing this allows the OpenTitan aes_test.c test to pass, as more recent versions of it check the IV register state at the end of the test.

… is started

The AES block does not clear the CPU-visible registers when starting a
new message. Only "the state registers inside the cipher core are cleared
with PRD during the last round of every encryption/decryption."

Fixing this allows the OpenTitan `aes_test.c` test to pass, as more recent
versions of it check the IV register state at the end of the test.

Signed-off-by: Luís Marques <luismarques@lowrisc.org>
Copy link

@rivos-eblot rivos-eblot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rivos-eblot
Copy link

I'm not sure how the PR title relates to its content.

@luismarques
Copy link
Author

luismarques commented Jan 16, 2025

I'm not sure how the PR title relates to its content.

Although state internal to the AES block is reset when a new message is started, other state (state that is externally visible) is not reset / randomized. The IV and keyshare registers are part of the externally visible state. Does that make sense?

See https://opentitan.org/book/hw/ip/aes/doc/theory_of_operation.html#clearing-registers-with-pseudo-random-data

In addition, the state registers inside the cipher core are cleared with PRD during the last round of every encryption/decryption.

@rivos-eblot
Copy link

Does that make sense?

Yes thanks.

@luismarques luismarques merged commit 878918f into lowRISC:dev/ot-earlgrey-1.0.0-updates Jan 16, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants