-
Notifications
You must be signed in to change notification settings - Fork 9
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
[ot] hw/opentitan: ot_aes: fix IV updates in CFB mode #107
base: ot-earlgrey-9.2.0
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also update something I missed from the previous AES MR circa line 441:
trace_ot_aes_init("iv");
if (randomize) {
ot_aes_randomize(s, r->iv, ARRAY_SIZE(r->iv));
}
with something like
if (randomize) {
trace_ot_aes_init("iv randomize");
ot_aes_randomize(s, r->iv, ARRAY_SIZE(r->iv));
} else {
trace_ot_aes_init("iv");
}
to differentiate both kinds. Thanks
Might be worth updating the file header as well? from * Copyright (c) 2022-2024 Rivos, Inc. to * Copyright (c) 2022-2024 Rivos, Inc.
* Copyright (c) 2025 lowRISC contributors. or the like |
b5c2edb
to
e8b3509
Compare
I've checked that OpenSSL returns the expected output IV value, so this seems to be a libtomcrypt oddity. |
No changes in libtomcrypt AES implementation for about 1.5 years. |
In AES CFB mode after a block operation the IV registers are updated with the ciphertext from the previous block operation. See: - https://opentitan.org/book/hw/ip/aes/doc/theory_of_operation.html#datapath-architecture-and-operation - https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_feedback_(CFB) LibTomCrypt does not provide this, so we just read it directly from our own data. Previously, we were using the updated IV value that LibTomCrypt provides, which is instead updated to be the output of the block operation (without the XOR with the plaintext). This fix allows the aes_functest to pass. Signed-off-by: Luís Marques <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The QEMU CI is broken. Let's merge this after fixing it and letting it run. |
In AES CFB mode after a block operation the IV registers are updated with the ciphertext from the previous block operation. See:
LibTomCrypt does not provide this, so we just read it directly from our own data. Previously, we were using the updated IV value that LibTomCrypt provides, which is instead updated to be the output of the block operation (without the XOR with the plaintext).
This fix allows the aes_functest to pass.