Skip to content

Commit 0a966e7

Browse files
committed
Organize NUC472 crypto files
1 parent 2bcb1f7 commit 0a966e7

File tree

16 files changed

+20
-21
lines changed

16 files changed

+20
-21
lines changed

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto.c renamed to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
#include "mbed_assert.h"
2020
#include "nu_modutil.h"
2121
#include "nu_bitutil.h"
22+
#include "crypto-misc.h"
2223

2324
static int crypto_inited = 0;
24-
static int crypto_sha_hw_avail = 1;
25+
static int crypto_sha_avail = 1;
2526

2627
void crypto_init(void)
2728
{
@@ -42,10 +43,10 @@ void crypto_zeroize(void *v, size_t n)
4243
}
4344
}
4445

45-
int crypto_sha_hw_acquire(void)
46+
int crypto_sha_acquire(void)
4647
{
47-
if (crypto_sha_hw_avail) {
48-
crypto_sha_hw_avail = 0;
48+
if (crypto_sha_avail) {
49+
crypto_sha_avail = 0;
4950
return 1;
5051
}
5152
else {
@@ -54,9 +55,9 @@ int crypto_sha_hw_acquire(void)
5455

5556
}
5657

57-
void crypto_sha_hw_release(void)
58+
void crypto_sha_release(void)
5859
{
59-
if (! crypto_sha_hw_avail) {
60-
crypto_sha_hw_avail = 1;
60+
if (! crypto_sha_avail) {
61+
crypto_sha_avail = 1;
6162
}
6263
}

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto.h renamed to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef MBED_CRYPTO_H
18-
#define MBED_CRYPTO_H
19-
20-
#include "cmsis.h"
17+
#ifndef MBED_CRYPTO_MISC_H
18+
#define MBED_CRYPTO_MISC_H
2119

2220
#ifdef __cplusplus
2321
extern "C" {
2422
#endif
2523

2624
void crypto_init(void);
2725
void crypto_zeroize(void *v, size_t n);
28-
int crypto_sha_hw_acquire(void);
29-
void crypto_sha_hw_release(void);
26+
int crypto_sha_acquire(void);
27+
void crypto_sha_release(void);
3028

3129
#ifdef __cplusplus
3230
}

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/des_alt.c renamed to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <string.h>
2727
#include "mbedtls/des.h"
2828
#include "des_alt.h"
29-
#include "crypto.h"
29+
#include "crypto-misc.h"
3030
#include "nu_bitutil.h"
3131
#include "toolchain.h"
3232

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/sha1_alt.c renamed to hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha1_alt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
#if defined(MBEDTLS_SHA1_ALT)
2525

2626
#include "sha1_alt.h"
27-
#include "crypto.h"
27+
#include "crypto-misc.h"
2828

2929
void mbedtls_sha1_init(mbedtls_sha1_context *ctx)
3030
{
31-
if (crypto_sha_hw_acquire()) {
31+
if (crypto_sha_acquire()) {
3232
ctx->mbedtls_sha1_init = mbedtls_sha1_hw_init;
3333
ctx->mbedtls_sha1_free = mbedtls_sha1_hw_free;
3434
ctx->mbedtls_sha1_clone = mbedtls_sha1_hw_clone;
@@ -59,7 +59,7 @@ void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
5959
ctx->mbedtls_sha1_free(ctx);
6060

6161
if (ctx->mbedtls_sha1_init == mbedtls_sha1_hw_init) {
62-
crypto_sha_hw_release();
62+
crypto_sha_release();
6363
}
6464
}
6565

0 commit comments

Comments
 (0)