From 0a966e70e39d468ebf9234d4e3ba77abaacd2cda Mon Sep 17 00:00:00 2001 From: ccli8 Date: Thu, 25 Aug 2016 13:52:24 +0800 Subject: [PATCH] Organize NUC472 crypto files --- .../TARGET_NUC472/{ => crypto/aes}/aes_alt.c | 0 .../TARGET_NUC472/{ => crypto/aes}/aes_alt.h | 0 .../{crypto.c => crypto/crypto-misc.c} | 15 ++++++++------- .../{crypto.h => crypto/crypto-misc.h} | 10 ++++------ .../TARGET_NUC472/{ => crypto/des}/des_alt.c | 2 +- .../TARGET_NUC472/{ => crypto/des}/des_alt.h | 0 .../TARGET_NUC472/{ => crypto/sha}/sha1_alt.c | 6 +++--- .../TARGET_NUC472/{ => crypto/sha}/sha1_alt.h | 0 .../TARGET_NUC472/{ => crypto/sha}/sha1_alt_sw.c | 0 .../TARGET_NUC472/{ => crypto/sha}/sha1_alt_sw.h | 0 .../TARGET_NUC472/{ => crypto/sha}/sha256_alt.c | 6 +++--- .../TARGET_NUC472/{ => crypto/sha}/sha256_alt.h | 0 .../{ => crypto/sha}/sha256_alt_sw.c | 0 .../{ => crypto/sha}/sha256_alt_sw.h | 0 .../TARGET_NUC472/{ => crypto/sha}/sha_alt_hw.c | 2 +- .../TARGET_NUC472/{ => crypto/sha}/sha_alt_hw.h | 0 16 files changed, 20 insertions(+), 21 deletions(-) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/aes}/aes_alt.c (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/aes}/aes_alt.h (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{crypto.c => crypto/crypto-misc.c} (83%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{crypto.h => crypto/crypto-misc.h} (85%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/des}/des_alt.c (99%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/des}/des_alt.h (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha1_alt.c (96%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha1_alt.h (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha1_alt_sw.c (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha1_alt_sw.h (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha256_alt.c (97%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha256_alt.h (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha256_alt_sw.c (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha256_alt_sw.h (100%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha_alt_hw.c (99%) rename hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/{ => crypto/sha}/sha_alt_hw.h (100%) diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/aes_alt.c b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/aes/aes_alt.c similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/aes_alt.c rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/aes/aes_alt.c diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/aes_alt.h b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/aes/aes_alt.h similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/aes_alt.h rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/aes/aes_alt.h diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto.c b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.c similarity index 83% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto.c rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.c index 20f80783a5..7f6646f40b 100644 --- a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto.c +++ b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.c @@ -19,9 +19,10 @@ #include "mbed_assert.h" #include "nu_modutil.h" #include "nu_bitutil.h" +#include "crypto-misc.h" static int crypto_inited = 0; -static int crypto_sha_hw_avail = 1; +static int crypto_sha_avail = 1; void crypto_init(void) { @@ -42,10 +43,10 @@ void crypto_zeroize(void *v, size_t n) } } -int crypto_sha_hw_acquire(void) +int crypto_sha_acquire(void) { - if (crypto_sha_hw_avail) { - crypto_sha_hw_avail = 0; + if (crypto_sha_avail) { + crypto_sha_avail = 0; return 1; } else { @@ -54,9 +55,9 @@ int crypto_sha_hw_acquire(void) } -void crypto_sha_hw_release(void) +void crypto_sha_release(void) { - if (! crypto_sha_hw_avail) { - crypto_sha_hw_avail = 1; + if (! crypto_sha_avail) { + crypto_sha_avail = 1; } } diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto.h b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h similarity index 85% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto.h rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h index 2585a9936b..8d55449712 100644 --- a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto.h +++ b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h @@ -14,10 +14,8 @@ * limitations under the License. */ -#ifndef MBED_CRYPTO_H -#define MBED_CRYPTO_H - -#include "cmsis.h" +#ifndef MBED_CRYPTO_MISC_H +#define MBED_CRYPTO_MISC_H #ifdef __cplusplus extern "C" { @@ -25,8 +23,8 @@ extern "C" { void crypto_init(void); void crypto_zeroize(void *v, size_t n); -int crypto_sha_hw_acquire(void); -void crypto_sha_hw_release(void); +int crypto_sha_acquire(void); +void crypto_sha_release(void); #ifdef __cplusplus } diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/des_alt.c b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt.c similarity index 99% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/des_alt.c rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt.c index 867e27b5f9..fb75266a36 100644 --- a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/des_alt.c +++ b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt.c @@ -26,7 +26,7 @@ #include #include "mbedtls/des.h" #include "des_alt.h" -#include "crypto.h" +#include "crypto-misc.h" #include "nu_bitutil.h" #include "toolchain.h" diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/des_alt.h b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt.h similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/des_alt.h rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt.h diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt.c b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt.c similarity index 96% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt.c rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt.c index 374228406b..5f04716448 100644 --- a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt.c +++ b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt.c @@ -24,11 +24,11 @@ #if defined(MBEDTLS_SHA1_ALT) #include "sha1_alt.h" -#include "crypto.h" +#include "crypto-misc.h" void mbedtls_sha1_init(mbedtls_sha1_context *ctx) { - if (crypto_sha_hw_acquire()) { + if (crypto_sha_acquire()) { ctx->mbedtls_sha1_init = mbedtls_sha1_hw_init; ctx->mbedtls_sha1_free = mbedtls_sha1_hw_free; ctx->mbedtls_sha1_clone = mbedtls_sha1_hw_clone; @@ -59,7 +59,7 @@ void mbedtls_sha1_free(mbedtls_sha1_context *ctx) ctx->mbedtls_sha1_free(ctx); if (ctx->mbedtls_sha1_init == mbedtls_sha1_hw_init) { - crypto_sha_hw_release(); + crypto_sha_release(); } } diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt.h b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt.h similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt.h rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt.h diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt_sw.c b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt_sw.c similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt_sw.c rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt_sw.c diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt_sw.h b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt_sw.h similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt_sw.h rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt_sw.h diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt.c b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt.c similarity index 97% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt.c rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt.c index 80e19f7406..96859ef47b 100644 --- a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt.c +++ b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt.c @@ -24,11 +24,11 @@ #if defined(MBEDTLS_SHA256_ALT) #include "sha256_alt.h" -#include "crypto.h" +#include "crypto-misc.h" void mbedtls_sha256_init(mbedtls_sha256_context *ctx) { - if (crypto_sha_hw_acquire()) { + if (crypto_sha_acquire()) { ctx->mbedtls_sha256_init = mbedtls_sha256_hw_init; ctx->mbedtls_sha256_free = mbedtls_sha256_hw_free; ctx->mbedtls_sha256_clone = mbedtls_sha256_hw_clone; @@ -59,7 +59,7 @@ void mbedtls_sha256_free(mbedtls_sha256_context *ctx) ctx->mbedtls_sha256_free(ctx); if (ctx->mbedtls_sha256_init == mbedtls_sha256_hw_init) { - crypto_sha_hw_release(); + crypto_sha_release(); } } diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt.h b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt.h similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt.h rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt.h diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt_sw.c b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt_sw.c similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt_sw.c rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt_sw.c diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt_sw.h b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt_sw.h similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha256_alt_sw.h rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha256_alt_sw.h diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha_alt_hw.c b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha_alt_hw.c similarity index 99% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha_alt_hw.c rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha_alt_hw.c index 99151713be..0c71ae8787 100644 --- a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha_alt_hw.c +++ b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha_alt_hw.c @@ -38,7 +38,7 @@ #include "nu_bitutil.h" #include "mbed_assert.h" -#include "crypto.h" +#include "crypto-misc.h" #include diff --git a/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha_alt_hw.h b/hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha_alt_hw.h similarity index 100% rename from hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha_alt_hw.h rename to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha_alt_hw.h