From 9a54cea78bb264ab3ac92e65b9b0a47218be84f7 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Mon, 27 Feb 2023 15:50:15 -0800 Subject: [PATCH] Fix AES-ECB with SECO --- wolfcrypt/src/port/caam/wolfcaam_seco.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/port/caam/wolfcaam_seco.c b/wolfcrypt/src/port/caam/wolfcaam_seco.c index 5329b1c82..0b66fd892 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_seco.c +++ b/wolfcrypt/src/port/caam/wolfcaam_seco.c @@ -869,8 +869,13 @@ static hsm_err_t wc_SEC_AES_Common(unsigned int args[4], CAAM_BUFFER* buf, if (err == HSM_NO_ERROR) { XMEMSET(&cipher_args, 0, sizeof(cipher_args)); cipher_args.key_identifier = args[3]; /* black key / HSM */ - cipher_args.iv = (uint8_t*)buf[1].TheAddress; - cipher_args.iv_size = buf[1].Length; + if (algo == HSM_CIPHER_ONE_GO_ALGO_AES_ECB) { + cipher_args.iv_size = 0; /* no iv with AES-ECB */ + } + else { + cipher_args.iv = (uint8_t*)buf[1].TheAddress; + cipher_args.iv_size = buf[1].Length; + } cipher_args.cipher_algo = algo; dir = args[0] & 0xFFFF; /* extract direction enc/dec from input args */ @@ -912,8 +917,8 @@ static hsm_err_t wc_SEC_AES_Common(unsigned int args[4], CAAM_BUFFER* buf, static hsm_err_t wc_SECO_AESECB(unsigned int args[4], CAAM_BUFFER* buf, int sz) { return wc_SEC_AES_Common(args, buf, sz, HSM_CIPHER_ONE_GO_ALGO_AES_ECB, - (uint8_t*)buf[2].TheAddress, buf[2].Length, - (uint8_t*)buf[3].TheAddress, buf[3].Length); + (uint8_t*)buf[1].TheAddress, buf[1].Length, + (uint8_t*)buf[2].TheAddress, buf[2].Length); }