diff --git a/wolfcrypt/src/port/af_alg/afalg_aes.c b/wolfcrypt/src/port/af_alg/afalg_aes.c index efbf635859..5ee66a3e98 100644 --- a/wolfcrypt/src/port/af_alg/afalg_aes.c +++ b/wolfcrypt/src/port/af_alg/afalg_aes.c @@ -146,6 +146,8 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, #endif aes->keylen = keylen; aes->rounds = keylen/4 + 6; + /* Mark key installed so the shared aes.c mode guards accept this context. */ + aes->keyInstalled = 1; #ifdef WOLFSSL_AES_COUNTER aes->left = 0; @@ -556,6 +558,8 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len) aes->keylen = len; aes->rounds = len/4 + 6; aes->dir = AES_ENCRYPTION; + /* Mark key installed so the shared aes.c mode guards accept this context. */ + aes->keyInstalled = 1; if (aes->rdFd > WC_SOCK_NOTSET) { (void)close(aes->rdFd); diff --git a/wolfcrypt/src/port/caam/caam_aes.c b/wolfcrypt/src/port/caam/caam_aes.c index 4ab3ee7f94..79e6a8056a 100644 --- a/wolfcrypt/src/port/caam/caam_aes.c +++ b/wolfcrypt/src/port/caam/caam_aes.c @@ -88,6 +88,8 @@ int wc_AesSetKey(Aes* aes, const byte* key, word32 len, default: return BAD_FUNC_ARG; } + /* Mark key installed so the shared aes.c mode guards accept this context. */ + aes->keyInstalled = 1; if ((ret = wc_AesSetIV(aes, iv)) != 0) { return ret; diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_aes.c b/wolfcrypt/src/port/devcrypto/devcrypto_aes.c index fe53360d58..916797bcf1 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_aes.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_aes.c @@ -123,6 +123,8 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, #endif aes->keylen = keylen; aes->rounds = keylen/4 + 6; + /* Mark key installed so the shared aes.c mode guards accept this context. */ + aes->keyInstalled = 1; #if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \ defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS) diff --git a/wolfcrypt/src/port/kcapi/kcapi_aes.c b/wolfcrypt/src/port/kcapi/kcapi_aes.c index 0aab365a3c..d2cd8be371 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_aes.c +++ b/wolfcrypt/src/port/kcapi/kcapi_aes.c @@ -208,6 +208,9 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len) if (ret == 0) { aes->keylen = len; aes->rounds = len/4 + 6; + /* Mark key installed so the shared aes.c mode guards accept this + * context. */ + aes->keyInstalled = 1; /* save key until type is known i.e. CBC, ECB, ... */ XMEMCPY((byte*)(aes->devKey), key, len); diff --git a/wolfcrypt/src/port/silabs/silabs_aes.c b/wolfcrypt/src/port/silabs/silabs_aes.c index 498acea21c..10b6995514 100644 --- a/wolfcrypt/src/port/silabs/silabs_aes.c +++ b/wolfcrypt/src/port/silabs/silabs_aes.c @@ -87,6 +87,9 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, aes->ctx.key.storage.location.buffer.pointer = (void*)aes->key; aes->ctx.key.storage.location.buffer.size = keylen; aes->ctx.key.size = keylen; + /* Mark key installed so the shared aes.c mode guards accept this + * context. */ + aes->keyInstalled = 1; } return ret; diff --git a/wolfcrypt/src/port/ti/ti-aes.c b/wolfcrypt/src/port/ti/ti-aes.c index 4718d97ab2..16385a1962 100644 --- a/wolfcrypt/src/port/ti/ti-aes.c +++ b/wolfcrypt/src/port/ti/ti-aes.c @@ -103,6 +103,8 @@ int wc_AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv, int dir) } aes->keylen = len; aes->rounds = len / 4 + 6; + /* Mark key installed so the shared aes.c mode guards accept this context. */ + aes->keyInstalled = 1; XMEMCPY(aes->key, key, len); #if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \