#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#if defined(WOLFSSL_RENESAS_RX64_HASH)
#include <wolfssl/wolfcrypt/port/Renesas/renesas-rx64-hw-crypt.h>
#include <stdio.h>
static wolfSSL_Mutex rx64_hw_mutex;
static int rx64_hw_CryptHwMutexInit_ = 0;
int rx64_hw_lock(void)
{
int ret = 0;
WOLFSSL_MSG("enter rx64_hw_lock");
if (rx64_hw_CryptHwMutexInit_ == 0){
ret = wc_InitMutex(&rx64_hw_mutex);
if (ret == 0) {
rx64_hw_CryptHwMutexInit_ = 1;
} else {
WOLFSSL_MSG(" mutex initialization failed.");
return -1;
}
}
if (wc_LockMutex(&rx64_hw_mutex) != 0) {
return -1;
}
WOLFSSL_MSG("leave rx64_hw_lock");
return ret;
}
void rx64_hw_unlock(void)
{
WOLFSSL_MSG("enter rx64_hw_unlock");
wc_UnLockMutex(&rx64_hw_mutex);
WOLFSSL_MSG("leave rx64_hw_unlock");
}
void rx64_hw_Open(void)
{
int ret = -1;
if (rx64_hw_lock() == 0) {
R_Sha_Init();
rx64_hw_unlock();
ret = 0;
} else {
WOLFSSL_MSG("Failed to lock rx64 hw \n");
}
return ret;
}
void rx64_hw_Close(void)
{
if (rx64_hw_lock() == 0) {
R_Sha_Close();
rx64_hw_unlock();
} else {
WOLFSSL_MSG("Failed to unlock rx64 hw \n");
}
}
#endif