libmbedtls: fix cipher_wrap.c for NIST AES Key Wrap mode
For AES Key Wrap mode, the *_ctx_clone() function is missing and
therefore the wrong function pointers are assigned to .ctx_clone_func
and .ctx_free_func when MBEDTLS_NIST_KW_C is enabled.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-By: Jerome Forissier <jerome.forissier@linaro.org>
[tve: rebased onto mbedtls-3.6.0]
Signed-off-by: Tom Van Eyck <tom.vaneyck@kuleuven.be>
[sby: rebased onto mbedtls-3.6.2]
Signed-off-by: Sungbae Yoo <sungbaey@nvidia.com>
diff --git a/lib/libmbedtls/mbedtls/library/cipher_wrap.c b/lib/libmbedtls/mbedtls/library/cipher_wrap.c
index ee0b802..b570241 100644
--- a/lib/libmbedtls/mbedtls/library/cipher_wrap.c
+++ b/lib/libmbedtls/mbedtls/library/cipher_wrap.c
@@ -2191,6 +2191,11 @@
return ctx;
}
+static void kw_ctx_clone(void *dst, const void *src)
+{
+ memcpy(dst, src, sizeof(mbedtls_nist_kw_context));
+}
+
static void kw_ctx_free(void *ctx)
{
mbedtls_nist_kw_free(ctx);
@@ -2235,6 +2240,7 @@
kw_aes_setkey_wrap,
kw_aes_setkey_unwrap,
kw_ctx_alloc,
+ kw_ctx_clone,
kw_ctx_free,
};