libmbedtls: fix cipher_wrap.c for chacha20 and chachapoly

For chacha20 and chachapoly, the *_ctx_clone() function is missing
and therefore the wrong function pointers are assigned to
.ctx_clone_func and .ctx_free_func when MBEDTLS_CHACHA20_C
or MBEDTLS_CHACHAPOLY_C is enabled.

Signed-off-by: Simon Ott <simon.ott@aisec.fraunhofer.de>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
diff --git a/lib/libmbedtls/mbedtls/library/cipher_wrap.c b/lib/libmbedtls/mbedtls/library/cipher_wrap.c
index 51def60..4b9d356 100644
--- a/lib/libmbedtls/mbedtls/library/cipher_wrap.c
+++ b/lib/libmbedtls/mbedtls/library/cipher_wrap.c
@@ -1986,6 +1986,11 @@
     return( ctx );
 }
 
+static void chacha20_ctx_clone( void *dst, const void *src )
+{
+    memcpy( dst, src, sizeof( mbedtls_chacha20_context ) );
+}
+
 static void chacha20_ctx_free( void *ctx )
 {
     mbedtls_chacha20_free( (mbedtls_chacha20_context *) ctx );
@@ -2016,6 +2021,7 @@
     chacha20_setkey_wrap,
     chacha20_setkey_wrap,
     chacha20_ctx_alloc,
+    chacha20_ctx_clone,
     chacha20_ctx_free
 };
 static const mbedtls_cipher_info_t chacha20_info = {
@@ -2058,6 +2064,11 @@
     return( ctx );
 }
 
+static void chachapoly_ctx_clone( void *dst, const void *src )
+{
+    memcpy( dst, src, sizeof( mbedtls_chachapoly_context ) );
+}
+
 static void chachapoly_ctx_free( void *ctx )
 {
     mbedtls_chachapoly_free( (mbedtls_chachapoly_context *) ctx );
@@ -2088,6 +2099,7 @@
     chachapoly_setkey_wrap,
     chachapoly_setkey_wrap,
     chachapoly_ctx_alloc,
+    chachapoly_ctx_clone,
     chachapoly_ctx_free
 };
 static const mbedtls_cipher_info_t chachapoly_info = {