From 12536436f8a587acaa92c10dd12bca392738559e Mon Sep 17 00:00:00 2001 From: ccli8 Date: Wed, 24 May 2017 15:11:47 +0800 Subject: [PATCH] [M487] Conform to mbed TLS H/W acceleration support released with mbed OS 5.3 --- .../TARGET_NUMAKER_PFM_M487/mbedtls_device.h | 31 +++++++++++++++++++ .../TARGET_NUVOTON/TARGET_M480}/aes/aes_alt.c | 4 +-- .../TARGET_NUVOTON/TARGET_M480}/aes/aes_alt.h | 12 ++++++- .../TARGET_NUVOTON/TARGET_M480}/crypto-misc.c | 0 .../TARGET_NUVOTON/TARGET_M480}/crypto-misc.h | 0 .../TARGET_NUVOTON/TARGET_M480}/des/des_alt.c | 8 +---- .../TARGET_NUVOTON/TARGET_M480}/des/des_alt.h | 2 ++ .../TARGET_M480}/des/des_alt_sw.c | 5 --- .../TARGET_M480}/des/des_alt_sw.h | 0 .../TARGET_M480}/sha/sha1_alt.c | 5 --- .../TARGET_M480}/sha/sha1_alt.h | 0 .../TARGET_M480}/sha/sha1_alt_sw.c | 6 ---- .../TARGET_M480}/sha/sha1_alt_sw.h | 0 .../TARGET_M480}/sha/sha256_alt.c | 5 --- .../TARGET_M480}/sha/sha256_alt.h | 0 .../TARGET_M480}/sha/sha256_alt_sw.c | 6 ---- .../TARGET_M480}/sha/sha256_alt_sw.h | 0 .../TARGET_M480}/sha/sha512_alt.c | 5 --- .../TARGET_M480}/sha/sha512_alt.h | 0 .../TARGET_M480}/sha/sha512_alt_sw.c | 10 ++---- .../TARGET_M480}/sha/sha512_alt_sw.h | 0 .../TARGET_M480}/sha/sha_alt_hw.c | 15 ++++----- .../TARGET_M480}/sha/sha_alt_hw.h | 8 +++++ targets/targets.json | 1 + 24 files changed, 66 insertions(+), 57 deletions(-) create mode 100644 features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/TARGET_NUMAKER_PFM_M487/mbedtls_device.h rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/aes/aes_alt.c (99%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/aes/aes_alt.h (97%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/crypto-misc.c (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/crypto-misc.h (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/des/des_alt.c (98%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/des/des_alt.h (99%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/des/des_alt_sw.c (99%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/des/des_alt_sw.h (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha1_alt.c (96%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha1_alt.h (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha1_alt_sw.c (98%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha1_alt_sw.h (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha256_alt.c (96%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha256_alt.h (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha256_alt_sw.c (98%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha256_alt_sw.h (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha512_alt.c (96%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha512_alt.h (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha512_alt_sw.c (98%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha512_alt_sw.h (100%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha_alt_hw.c (97%) rename {targets/TARGET_NUVOTON/TARGET_M480/crypto => features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480}/sha/sha_alt_hw.h (91%) diff --git a/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/TARGET_NUMAKER_PFM_M487/mbedtls_device.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/TARGET_NUMAKER_PFM_M487/mbedtls_device.h new file mode 100644 index 0000000000..22396dfea2 --- /dev/null +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/TARGET_NUMAKER_PFM_M487/mbedtls_device.h @@ -0,0 +1,31 @@ +/* mbed Microcontroller Library + * Copyright (c) 2015-2016 Nuvoton + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MBEDTLS_DEVICE_H +#define MBEDTLS_DEVICE_H + +#define MBEDTLS_DES_ALT + +#define MBEDTLS_SHA1_ALT +#define MBEDTLS_SHA256_ALT +#define MBEDTLS_SHA512_ALT + +#define MBEDTLS_AES_ALT +#define MBEDTLS_AES_SETKEY_ENC_ALT +#define MBEDTLS_AES_SETKEY_DEC_ALT +#define MBEDTLS_AES_ENCRYPT_ALT +#define MBEDTLS_AES_DECRYPT_ALT + +#endif /* MBEDTLS_DEVICE_H */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/aes/aes_alt.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.c similarity index 99% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/aes/aes_alt.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.c index 6dda342893..5525534ae5 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/aes/aes_alt.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.c @@ -35,7 +35,7 @@ #include "mbedtls/aes.h" #include "M480.h" -#include "toolchain.h" +#include "mbed_toolchain.h" #include "mbed_assert.h" //static int aes_init_done = 0; @@ -135,7 +135,7 @@ void mbedtls_aes_init( mbedtls_aes_context *ctx ) /* Unlock protected registers */ SYS_UnlockReg(); - CLK_EnableModuleClock(CRYPTO_MODULE); + CLK_EnableModuleClock(CRPT_MODULE); /* Lock protected registers */ SYS_LockReg(); diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/aes/aes_alt.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.h similarity index 97% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/aes/aes_alt.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.h index 25a8ca5311..f0fec3122a 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/aes/aes_alt.h +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.h @@ -20,7 +20,16 @@ * * This file is part of mbed TLS (https://tls.mbed.org) */ +#ifndef MBEDTLS_AES_ALT_H +#define MBEDTLS_AES_ALT_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_AES_ALT) // Regular implementation // @@ -270,5 +279,6 @@ void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, #endif /* MBEDTLS_AES_ALT */ +#endif /* MBEDTLS_AES_C */ - +#endif /* aes_alt.h */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/crypto-misc.c similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/crypto-misc.c diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/crypto-misc.h similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/crypto-misc.h diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.c similarity index 98% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.c index 05a9ab262c..e4e9fd4023 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.c @@ -14,9 +14,6 @@ * limitations under the License. */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -31,7 +28,7 @@ #include "des_alt.h" #include "crypto-misc.h" #include "nu_bitutil.h" -#include "toolchain.h" +#include "mbed_toolchain.h" // Must be a multiple of 64-bit block size #define MAXSIZE_DMABUF (8 * 5) @@ -411,6 +408,3 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S #endif /* MBEDTLS_DES_ALT */ #endif /* MBEDTLS_DES_C */ - -#endif /* MBED_CONF_RTOS_PRESENT */ - diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.h similarity index 99% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.h index 4676ab93e1..b783889d53 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt.h +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.h @@ -23,6 +23,7 @@ #include MBEDTLS_CONFIG_FILE #endif +#if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_DES_ALT) #include @@ -276,5 +277,6 @@ void mbedtls_des_setkey( uint32_t SK[32], #endif #endif /* MBEDTLS_DES_ALT */ +#endif /* MBEDTLS_DES_C */ #endif /* des_alt.h */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt_sw.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt_sw.c similarity index 99% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt_sw.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt_sw.c index 59a94d0164..1e51151c86 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt_sw.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt_sw.c @@ -25,9 +25,6 @@ * http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -798,5 +795,3 @@ int mbedtls_des3_sw_crypt_cbc( mbedtls_des3_sw_context *ctx, #endif /* MBEDTLS_DES_ALT */ #endif /* MBEDTLS_DES_C */ - -#endif /* MBED_CONF_RTOS_PRESENT */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt_sw.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt_sw.h similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/des/des_alt_sw.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt_sw.h diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.c similarity index 96% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.c index dfa8cda864..de6ff01415 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.c @@ -14,9 +14,6 @@ * limitations under the License. */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -139,5 +136,3 @@ void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64 #endif /* MBEDTLS_SHA1_ALT */ #endif /* MBEDTLS_SHA1_C */ - -#endif /* MBED_CONF_RTOS_PRESENT */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.h similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.h diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt_sw.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt_sw.c similarity index 98% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt_sw.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt_sw.c index 18b0c496c6..cc7ff7f074 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt_sw.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt_sw.c @@ -24,9 +24,6 @@ * http://www.itl.nist.gov/fipspubs/fip180-1.htm */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -344,7 +341,4 @@ void mbedtls_sha1_sw_finish( mbedtls_sha1_sw_context *ctx, unsigned char output[ } #endif /* MBEDTLS_SHA1_ALT */ - #endif /* MBEDTLS_SHA1_C */ - -#endif /* MBED_CONF_RTOS_PRESENT */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt_sw.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt_sw.h similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha1_alt_sw.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt_sw.h diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.c similarity index 96% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.c index 955c5d1fb2..de337ac525 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.c @@ -14,9 +14,6 @@ * limitations under the License. */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -140,5 +137,3 @@ void mbedtls_sha256_process(mbedtls_sha256_context *ctx, const unsigned char dat #endif /* MBEDTLS_SHA256_ALT */ #endif /* MBEDTLS_SHA256_C */ - -#endif /* MBED_CONF_RTOS_PRESENT */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.h similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.h diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt_sw.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt_sw.c similarity index 98% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt_sw.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt_sw.c index a6db9b136b..2062643335 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt_sw.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt_sw.c @@ -24,9 +24,6 @@ * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -318,7 +315,4 @@ void mbedtls_sha256_sw_finish( mbedtls_sha256_sw_context *ctx, unsigned char out } #endif /* MBEDTLS_SHA256_ALT */ - #endif /* MBEDTLS_SHA256_C */ - -#endif /* MBED_CONF_RTOS_PRESENT */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt_sw.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt_sw.h similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha256_alt_sw.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt_sw.h diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.c similarity index 96% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.c index b33cc49dc6..365d172b54 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.c @@ -14,9 +14,6 @@ * limitations under the License. */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -141,5 +138,3 @@ void mbedtls_sha512_process(mbedtls_sha512_context *ctx, const unsigned char dat #endif /* MBEDTLS_SHA512_ALT */ #endif /* MBEDTLS_SHA512_C */ - -#endif /* MBED_CONF_RTOS_PRESENT */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.h similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.h diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt_sw.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt_sw.c similarity index 98% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt_sw.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt_sw.c index 515c654ef2..1f8387445c 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt_sw.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt_sw.c @@ -24,17 +24,14 @@ * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else #include MBEDTLS_CONFIG_FILE #endif -#if defined(MBEDTLS_SHA256_C) -#if defined(MBEDTLS_SHA256_ALT) +#if defined(MBEDTLS_SHA512_C) +#if defined(MBEDTLS_SHA512_ALT) #include "mbedtls/sha512.h" @@ -357,7 +354,4 @@ void mbedtls_sha512_sw_finish( mbedtls_sha512_sw_context *ctx, unsigned char out } #endif /* MBEDTLS_SHA512_ALT */ - #endif /* MBEDTLS_SHA512_C */ - -#endif /* MBED_CONF_RTOS_PRESENT */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt_sw.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt_sw.h similarity index 100% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha512_alt_sw.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt_sw.h diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha_alt_hw.c b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha_alt_hw.c similarity index 97% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha_alt_hw.c rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha_alt_hw.c index 76701c7433..3ce29e213d 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha_alt_hw.c +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha_alt_hw.c @@ -14,9 +14,6 @@ * limitations under the License. */ -/* Compatible with mbed OS 2 which doesn't support mbedtls */ -#if MBED_CONF_RTOS_PRESENT - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -51,6 +48,7 @@ void crypto_sha_getinternstate(unsigned char output[], size_t olen); #endif /* MBEDTLS_SHA1_ALT || MBEDTLS_SHA256_ALT || MBEDTLS_SHA512_ALT */ +#if defined(MBEDTLS_SHA1_C) #if defined(MBEDTLS_SHA1_ALT) void mbedtls_sha1_hw_init(crypto_sha_context *ctx) @@ -123,7 +121,9 @@ void mbedtls_sha1_hw_process(crypto_sha_context *ctx, const unsigned char data[6 } #endif /* MBEDTLS_SHA1_ALT */ +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) #if defined(MBEDTLS_SHA256_ALT) void mbedtls_sha256_hw_init(crypto_sha_context *ctx) @@ -197,9 +197,10 @@ void mbedtls_sha256_hw_process(crypto_sha_context *ctx, const unsigned char data } #endif /* MBEDTLS_SHA256_ALT */ +#endif /* MBEDTLS_SHA256_C */ - +#if defined(MBEDTLS_SHA512_C) #if defined(MBEDTLS_SHA512_ALT) void mbedtls_sha512_hw_init(crypto_sha_context *ctx) @@ -273,7 +274,9 @@ void mbedtls_sha512_hw_process(crypto_sha_context *ctx, const unsigned char data } #endif /* MBEDTLS_SHA512_ALT */ +#endif /* MBEDTLS_SHA512_C */ +#if defined(MBEDTLS_SHA1_C) || defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA512_C) #if defined(MBEDTLS_SHA1_ALT) || defined(MBEDTLS_SHA256_ALT) || defined(MBEDTLS_SHA512_ALT) void crypto_sha_update(crypto_sha_context *ctx, const unsigned char *input, size_t ilen) @@ -431,8 +434,6 @@ void crypto_sha_getinternstate(unsigned char output[], size_t olen) } #endif /* MBEDTLS_SHA1_ALT || MBEDTLS_SHA256_ALT || MBEDTLS_SHA512_ALT */ - #endif /* MBEDTLS_SHA1_C || MBEDTLS_SHA256_C || MBEDTLS_SHA512_C */ -#endif /* MBED_CONF_RTOS_PRESENT */ - +#endif /* MBEDTLS_SHA1_C || MBEDTLS_SHA256_C || MBEDTLS_SHA512_C */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha_alt_hw.h b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha_alt_hw.h similarity index 91% rename from targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha_alt_hw.h rename to features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha_alt_hw.h index 732db1b6c9..527a38e657 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/crypto/sha/sha_alt_hw.h +++ b/features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha_alt_hw.h @@ -23,6 +23,7 @@ #endif #if defined(MBEDTLS_SHA1_C) || defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA512_C) +#if defined(MBEDTLS_SHA1_ALT) || defined(MBEDTLS_SHA256_ALT) || defined(MBEDTLS_SHA512_ALT) #include #include @@ -50,6 +51,7 @@ void crypto_sha_update(crypto_sha_context *ctx, const unsigned char *input, size void crypto_sha_update_nobuf(crypto_sha_context *ctx, const unsigned char *input, size_t ilen, int islast); void crypto_sha_getinternstate(unsigned char output[], size_t olen); +#if defined(MBEDTLS_SHA1_C) #if defined(MBEDTLS_SHA1_ALT) void mbedtls_sha1_hw_init( crypto_sha_context *ctx ); @@ -62,7 +64,9 @@ void mbedtls_sha1_hw_finish( crypto_sha_context *ctx, unsigned char output[20] ) void mbedtls_sha1_hw_process( crypto_sha_context *ctx, const unsigned char data[64] ); #endif /* MBEDTLS_SHA1_ALT */ +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA256_C) #if defined(MBEDTLS_SHA256_ALT) void mbedtls_sha256_hw_init( crypto_sha_context *ctx ); @@ -76,7 +80,9 @@ void mbedtls_sha256_hw_finish( crypto_sha_context *ctx, unsigned char output[32] void mbedtls_sha256_hw_process( crypto_sha_context *ctx, const unsigned char data[64] ); #endif /* MBEDTLS_SHA256_ALT */ +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA512_C) #if defined(MBEDTLS_SHA512_ALT) void mbedtls_sha512_hw_init( crypto_sha_context *ctx ); @@ -90,11 +96,13 @@ void mbedtls_sha512_hw_finish( crypto_sha_context *ctx, unsigned char output[64] void mbedtls_sha512_hw_process( crypto_sha_context *ctx, const unsigned char data[128] ); #endif /* MBEDTLS_SHA512_ALT */ +#endif /* MBEDTLS_SHA512_C */ #ifdef __cplusplus } #endif +#endif /* MBEDTLS_SHA1_ALT || MBEDTLS_SHA256_ALT || MBEDTLS_SHA512_ALT */ #endif /* MBEDTLS_SHA1_C || MBEDTLS_SHA256_C || MBEDTLS_SHA512_C*/ #endif /* sha_alt.h */ diff --git a/targets/targets.json b/targets/targets.json index cb67bd0fa0..ddb2f84c3c 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -3264,6 +3264,7 @@ "is_disk_virtual": true, "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], "inherits": ["Target"], + "macros_add": ["MBEDTLS_CONFIG_HW_SUPPORT"], "device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "TRNG", "CAN", "FLASH"], "features": [], "release_versions": ["5"],