mirror of https://github.com/ARMmbed/mbed-os.git
Organize NUC472 crypto files
parent
2bcb1f7a16
commit
0a966e70e3
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
#include <string.h>
|
||||
#include "mbedtls/des.h"
|
||||
#include "des_alt.h"
|
||||
#include "crypto.h"
|
||||
#include "crypto-misc.h"
|
||||
#include "nu_bitutil.h"
|
||||
#include "toolchain.h"
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "nu_bitutil.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "crypto.h"
|
||||
#include "crypto-misc.h"
|
||||
|
||||
#include <string.h>
|
||||
|
Loading…
Reference in New Issue