Import mbedtls-2.16.5

Imports Mbed TLS 2.16.5 from https://github.com/ARMmbed/mbedtls.git
commit 0fce215851cc ("Merge pull request #3053 from
yanesca/bump-version-2.16.5") (tag mbedtls-2.16.5).

Certain files will bever be needed and are thus removed:
 rm -f .gitignore .globalrc .pylintrc .travis.yml
 rm -f CMakeLists.txt DartConfiguration.tcl Makefile
 rm -f include/{.gitignore,CMakeLists.txt}
 rm -f library/{.gitignore,CMakeLists.txt,Makefile}
 rm -rf .git .github configs docs doxygen programs scripts tests visualc

This is a complete overwrite of previous code so earlier changes in the
branch import/mbedtls-2.16.0 will be added on top of this commit to bring
the changes forward.

Signed-off-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/lib/libmbedtls/mbedtls/library/cipher_wrap.c b/lib/libmbedtls/mbedtls/library/cipher_wrap.c
index df55bbd..6dd8c5d 100644
--- a/lib/libmbedtls/mbedtls/library/cipher_wrap.c
+++ b/lib/libmbedtls/mbedtls/library/cipher_wrap.c
@@ -1,4 +1,3 @@
-// SPDX-License-Identifier: Apache-2.0
 /**
  * \file cipher_wrap.c
  *
@@ -7,6 +6,7 @@
  * \author Adriaan de Jong <dejong@fox-it.com>
  *
  *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ *  SPDX-License-Identifier: Apache-2.0
  *
  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
  *  not use this file except in compliance with the License.
@@ -29,8 +29,6 @@
 #include MBEDTLS_CONFIG_FILE
 #endif
 
-#include <string.h>
-
 #if defined(MBEDTLS_CIPHER_C)
 
 #include "mbedtls/cipher_internal.h"
@@ -99,11 +97,6 @@
     return( ctx );
 }
 
-static void gcm_ctx_clone( void *dst, const void *src )
-{
-    memcpy( dst, src, sizeof( mbedtls_gcm_context ) );
-}
-
 static void gcm_ctx_free( void *ctx )
 {
     mbedtls_gcm_free( ctx );
@@ -123,11 +116,6 @@
     return( ctx );
 }
 
-static void ccm_ctx_clone( void *dst, const void *src )
-{
-    memcpy( dst, src, sizeof( mbedtls_ccm_context ) );
-}
-
 static void ccm_ctx_free( void *ctx )
 {
     mbedtls_ccm_free( ctx );
@@ -232,11 +220,6 @@
     return( aes );
 }
 
-static void aes_ctx_clone( void *dst, const void *src )
-{
-    memcpy( dst, src, sizeof( mbedtls_aes_context ) );
-}
-
 static void aes_ctx_free( void *ctx )
 {
     mbedtls_aes_free( (mbedtls_aes_context *) ctx );
@@ -267,7 +250,6 @@
     aes_setkey_enc_wrap,
     aes_setkey_dec_wrap,
     aes_ctx_alloc,
-    aes_ctx_clone,
     aes_ctx_free
 };
 
@@ -562,7 +544,6 @@
     gcm_aes_setkey_wrap,
     gcm_aes_setkey_wrap,
     gcm_ctx_alloc,
-    gcm_ctx_clone,
     gcm_ctx_free,
 };
 
@@ -632,7 +613,6 @@
     ccm_aes_setkey_wrap,
     ccm_aes_setkey_wrap,
     ccm_ctx_alloc,
-    ccm_ctx_clone,
     ccm_ctx_free,
 };
 
@@ -736,11 +716,6 @@
     return( ctx );
 }
 
-static void camellia_ctx_clone( void *dst, const void *src )
-{
-    memcpy( dst, src, sizeof( mbedtls_camellia_context ) );
-}
-
 static void camellia_ctx_free( void *ctx )
 {
     mbedtls_camellia_free( (mbedtls_camellia_context *) ctx );
@@ -771,7 +746,6 @@
     camellia_setkey_enc_wrap,
     camellia_setkey_dec_wrap,
     camellia_ctx_alloc,
-    camellia_ctx_clone,
     camellia_ctx_free
 };
 
@@ -945,7 +919,6 @@
     gcm_camellia_setkey_wrap,
     gcm_camellia_setkey_wrap,
     gcm_ctx_alloc,
-    gcm_ctx_clone,
     gcm_ctx_free,
 };
 
@@ -1015,7 +988,6 @@
     ccm_camellia_setkey_wrap,
     ccm_camellia_setkey_wrap,
     ccm_ctx_alloc,
-    ccm_ctx_clone,
     ccm_ctx_free,
 };
 
@@ -1525,11 +1497,6 @@
     return( des );
 }
 
-static void des_ctx_clone( void *dst, const void *src )
-{
-    memcpy( dst, src, sizeof( mbedtls_des_context ) );
-}
-
 static void des_ctx_free( void *ctx )
 {
     mbedtls_des_free( (mbedtls_des_context *) ctx );
@@ -1549,11 +1516,6 @@
     return( des3 );
 }
 
-static void des3_ctx_clone( void *dst, const void *src )
-{
-    memcpy( dst, src, sizeof( mbedtls_des3_context ) );
-}
-
 static void des3_ctx_free( void *ctx )
 {
     mbedtls_des3_free( (mbedtls_des3_context *) ctx );
@@ -1584,7 +1546,6 @@
     des_setkey_enc_wrap,
     des_setkey_dec_wrap,
     des_ctx_alloc,
-    des_ctx_clone,
     des_ctx_free
 };
 
@@ -1636,7 +1597,6 @@
     des3_set2key_enc_wrap,
     des3_set2key_dec_wrap,
     des3_ctx_alloc,
-    des3_ctx_clone,
     des3_ctx_free
 };
 
@@ -1688,7 +1648,6 @@
     des3_set3key_enc_wrap,
     des3_set3key_dec_wrap,
     des3_ctx_alloc,
-    des3_ctx_clone,
     des3_ctx_free
 };
 
@@ -1774,11 +1733,6 @@
     return( ctx );
 }
 
-static void blowfish_ctx_clone( void *dst, const void *src )
-{
-    memcpy( dst, src, sizeof( mbedtls_blowfish_context ) );
-}
-
 static void blowfish_ctx_free( void *ctx )
 {
     mbedtls_blowfish_free( (mbedtls_blowfish_context *) ctx );
@@ -1809,7 +1763,6 @@
     blowfish_setkey_wrap,
     blowfish_setkey_wrap,
     blowfish_ctx_alloc,
-    blowfish_ctx_clone,
     blowfish_ctx_free
 };
 
@@ -1896,11 +1849,6 @@
     return( ctx );
 }
 
-static void arc4_ctx_clone( void *dst, const void *src )
-{
-    memcpy( dst, src, sizeof( mbedtls_arc4_context ) );
-}
-
 static void arc4_ctx_free( void *ctx )
 {
     mbedtls_arc4_free( (mbedtls_arc4_context *) ctx );
@@ -1931,7 +1879,6 @@
     arc4_setkey_wrap,
     arc4_setkey_wrap,
     arc4_ctx_alloc,
-    arc4_ctx_clone,
     arc4_ctx_free
 };
 
@@ -2128,12 +2075,6 @@
     return( (void *) 1 );
 }
 
-static void null_ctx_clone( void *dst, const void *src )
-{
-    ((void) dst);
-    ((void) src);
-}
-
 static void null_ctx_free( void *ctx )
 {
     ((void) ctx);
@@ -2163,7 +2104,6 @@
     null_setkey,
     null_setkey,
     null_ctx_alloc,
-    null_ctx_clone,
     null_ctx_free
 };