From 2058e5d0bfb89941fca176b3ea710bc2b179627d Mon Sep 17 00:00:00 2001 From: Jade Philipoom Date: Thu, 4 Jan 2024 10:34:54 +0100 Subject: [PATCH] removeme, test Signed-off-by: Jade Philipoom --- sw/device/lib/crypto/impl/aes.c | 4 ++-- sw/device/lib/crypto/impl/aes_gcm/aes_gcm.h | 2 +- sw/device/lib/crypto/include/aes.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sw/device/lib/crypto/impl/aes.c b/sw/device/lib/crypto/impl/aes.c index f27675c8aa2fb6..024fb66064d650 100644 --- a/sw/device/lib/crypto/impl/aes.c +++ b/sw/device/lib/crypto/impl/aes.c @@ -49,7 +49,7 @@ static_assert(sizeof(crypto_key_config_t) % sizeof(uint32_t) == 0, static inline void gcm_context_save(aes_gcm_context_t *internal_ctx, aes_gcm_ctx_t *api_ctx) { hardened_memcpy(api_ctx->data, (uint32_t *)internal_ctx, - ARRAYSIZE(api_ctx->data)); + ARRAYSIZE(internal_ctx->data)); } /** @@ -61,7 +61,7 @@ static inline void gcm_context_save(aes_gcm_context_t *internal_ctx, static inline void gcm_context_restore(aes_gcm_ctx_t *api_ctx, aes_gcm_context_t *internal_ctx) { hardened_memcpy((uint32_t *)internal_ctx, api_ctx->data, - ARRAYSIZE(api_ctx->data)); + ARRAYSIZE(internal_ctx->data)); } /** diff --git a/sw/device/lib/crypto/impl/aes_gcm/aes_gcm.h b/sw/device/lib/crypto/impl/aes_gcm/aes_gcm.h index 15a07aab628241..58d4b678b52adc 100644 --- a/sw/device/lib/crypto/impl/aes_gcm/aes_gcm.h +++ b/sw/device/lib/crypto/impl/aes_gcm/aes_gcm.h @@ -65,7 +65,7 @@ typedef struct aes_gcm_context { * Current context for the tag's ongoing GHASH computation. */ ghash_context_t ghash_ctx; -} aes_gcm_context_t; +} __attribute__((aligned(sizeof(uint32_t)))) aes_gcm_context_t; /** * AES-GCM authenticated encryption as defined in NIST SP800-38D, algorithm 4. diff --git a/sw/device/lib/crypto/include/aes.h b/sw/device/lib/crypto/include/aes.h index 5d110ca3851576..06a0fb2cc92149 100644 --- a/sw/device/lib/crypto/include/aes.h +++ b/sw/device/lib/crypto/include/aes.h @@ -83,7 +83,7 @@ typedef enum aes_padding { * change.  */ typedef struct aes_gcm_ctx { - uint32_t data[92]; + uint32_t data[120]; } aes_gcm_ctx_t; /**