[PATCH] hw/misc/max78000_aes: Comment Internal Key Storage

Jackson Donaldson posted 1 patch 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250716002622.84685-1-jcksn@duck.com
hw/misc/max78000_aes.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] hw/misc/max78000_aes: Comment Internal Key Storage
Posted by Jackson Donaldson 4 months ago
Coverity Scan noted an unusual pattern in the
MAX78000 aes device, with duplicated calls to
set_decrypt. This commit adds a comment noting
why the implementation is correct.

Signed-off-by: Jackson Donaldson <jcksn@duck.com>
---
 hw/misc/max78000_aes.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/misc/max78000_aes.c b/hw/misc/max78000_aes.c
index 0bfb2f02b5..d883ddd2b6 100644
--- a/hw/misc/max78000_aes.c
+++ b/hw/misc/max78000_aes.c
@@ -79,6 +79,12 @@ static void max78000_aes_do_crypto(Max78000AesState *s)
         keydata += 8;
     }
 
+    /*
+     * The MAX78000 AES engine stores an internal key, which it uses only
+     * for decryption. This results in the slighly odd looking pairs of
+     * set_encrypt and set_decrypt calls below; s->internal_key is
+     * being stored for later use in both cases.
+     */
     AES_KEY key;
     if ((s->ctrl & TYPE) == 0) {
         AES_set_encrypt_key(keydata, keylen, &key);
-- 
2.34.1
Re: [PATCH] hw/misc/max78000_aes: Comment Internal Key Storage
Posted by Peter Maydell 4 months ago
On Wed, 16 Jul 2025 at 01:26, Jackson Donaldson <jackson88044@gmail.com> wrote:
>
> Coverity Scan noted an unusual pattern in the
> MAX78000 aes device, with duplicated calls to
> set_decrypt. This commit adds a comment noting
> why the implementation is correct.
>
> Signed-off-by: Jackson Donaldson <jcksn@duck.com>
> ---
>  hw/misc/max78000_aes.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/hw/misc/max78000_aes.c b/hw/misc/max78000_aes.c
> index 0bfb2f02b5..d883ddd2b6 100644
> --- a/hw/misc/max78000_aes.c
> +++ b/hw/misc/max78000_aes.c
> @@ -79,6 +79,12 @@ static void max78000_aes_do_crypto(Max78000AesState *s)
>          keydata += 8;
>      }
>
> +    /*
> +     * The MAX78000 AES engine stores an internal key, which it uses only
> +     * for decryption. This results in the slighly odd looking pairs of
> +     * set_encrypt and set_decrypt calls below; s->internal_key is
> +     * being stored for later use in both cases.
> +     */
>      AES_KEY key;
>      if ((s->ctrl & TYPE) == 0) {
>          AES_set_encrypt_key(keydata, keylen, &key);



Applied to target-arm.next, thanks.

-- PMM