From 6956420cc064f68c931a09d06425e6c72f0d377b Mon Sep 17 00:00:00 2001 From: Jens Wiklander Date: Fri, 12 May 2023 16:00:18 +0200 Subject: [PATCH] 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 Acked-By: Jerome Forissier --- lib/libmbedtls/mbedtls/library/cipher_wrap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/libmbedtls/mbedtls/library/cipher_wrap.c b/lib/libmbedtls/mbedtls/library/cipher_wrap.c index 40555cd9373..fb363145c5f 100644 --- a/lib/libmbedtls/mbedtls/library/cipher_wrap.c +++ b/lib/libmbedtls/mbedtls/library/cipher_wrap.c @@ -2071,6 +2071,11 @@ static void *kw_ctx_alloc(void) 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); @@ -2115,6 +2120,7 @@ static const mbedtls_cipher_base_t kw_aes_info = { kw_aes_setkey_wrap, kw_aes_setkey_unwrap, kw_ctx_alloc, + kw_ctx_clone, kw_ctx_free, };