mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #170 from dgarske/master
Fixes initialization of the Crypto HW protection, which could leak a …pull/171/head
commit
e76f95465d
|
@ -1263,12 +1263,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||||
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL) && !defined(STACK_TRAP)
|
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL) && !defined(STACK_TRAP)
|
||||||
wolfSSL_Debugging_ON();
|
wolfSSL_Debugging_ON();
|
||||||
#endif
|
#endif
|
||||||
if (CurrentDir("_build"))
|
ChangeToWolfRoot();
|
||||||
ChangeDirBack(1);
|
|
||||||
else if (CurrentDir("client"))
|
|
||||||
ChangeDirBack(2);
|
|
||||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
|
||||||
ChangeDirBack(3);
|
|
||||||
|
|
||||||
#ifdef HAVE_STACK_SIZE
|
#ifdef HAVE_STACK_SIZE
|
||||||
StackSizeCheck(&args, client_test);
|
StackSizeCheck(&args, client_test);
|
||||||
|
|
|
@ -261,10 +261,7 @@ void echoclient_test(void* args)
|
||||||
CyaSSL_Debugging_ON();
|
CyaSSL_Debugging_ON();
|
||||||
#endif
|
#endif
|
||||||
#ifndef CYASSL_TIRTOS
|
#ifndef CYASSL_TIRTOS
|
||||||
if (CurrentDir("echoclient"))
|
ChangeToWolfRoot();
|
||||||
ChangeDirBack(2);
|
|
||||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
|
||||||
ChangeDirBack(3);
|
|
||||||
#endif
|
#endif
|
||||||
echoclient_test(&args);
|
echoclient_test(&args);
|
||||||
|
|
||||||
|
|
|
@ -393,10 +393,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
||||||
#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
|
#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
|
||||||
CyaSSL_Debugging_ON();
|
CyaSSL_Debugging_ON();
|
||||||
#endif
|
#endif
|
||||||
if (CurrentDir("echoserver"))
|
ChangeToWolfRoot();
|
||||||
ChangeDirBack(2);
|
|
||||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
|
||||||
ChangeDirBack(3);
|
|
||||||
echoserver_test(&args);
|
echoserver_test(&args);
|
||||||
CyaSSL_Cleanup();
|
CyaSSL_Cleanup();
|
||||||
|
|
||||||
|
|
|
@ -908,12 +908,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||||
#if defined(DEBUG_CYASSL) && !defined(WOLFSSL_MDK_SHELL)
|
#if defined(DEBUG_CYASSL) && !defined(WOLFSSL_MDK_SHELL)
|
||||||
CyaSSL_Debugging_ON();
|
CyaSSL_Debugging_ON();
|
||||||
#endif
|
#endif
|
||||||
if (CurrentDir("_build"))
|
ChangeToWolfRoot();
|
||||||
ChangeDirBack(1);
|
|
||||||
else if (CurrentDir("server"))
|
|
||||||
ChangeDirBack(2);
|
|
||||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
|
||||||
ChangeDirBack(3);
|
|
||||||
|
|
||||||
#ifdef HAVE_STACK_SIZE
|
#ifdef HAVE_STACK_SIZE
|
||||||
StackSizeCheck(&args, server_test);
|
StackSizeCheck(&args, server_test);
|
||||||
|
|
|
@ -60,10 +60,7 @@ int unit_test(int argc, char** argv)
|
||||||
#endif /* HAVE_CAVIUM */
|
#endif /* HAVE_CAVIUM */
|
||||||
|
|
||||||
#ifndef WOLFSSL_TIRTOS
|
#ifndef WOLFSSL_TIRTOS
|
||||||
if (CurrentDir("tests") || CurrentDir("_build"))
|
ChangeToWolfRoot();
|
||||||
ChangeDirBack(1);
|
|
||||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
|
||||||
ChangeDirBack(3);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ApiTest();
|
ApiTest();
|
||||||
|
|
|
@ -29,24 +29,6 @@
|
||||||
#include <wolfssl/test.h>
|
#include <wolfssl/test.h>
|
||||||
#include "wolfcrypt/test/test.h"
|
#include "wolfcrypt/test/test.h"
|
||||||
|
|
||||||
/* This function changes the current directory to the wolfssl root */
|
|
||||||
static void ChangeDirToRoot(void)
|
|
||||||
{
|
|
||||||
/* Normal Command Line=_build, Visual Studio=testsuite */
|
|
||||||
if (CurrentDir("testsuite") || CurrentDir("_build")) {
|
|
||||||
ChangeDirBack(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Xcode: To output application to correct location: */
|
|
||||||
/* 1. Xcode->Preferences->Locations->Locations */
|
|
||||||
/* 2. Derived Data Advanced -> Custom */
|
|
||||||
/* 3. Relative to Workspace, Build/Products */
|
|
||||||
/* Build/Products/Debug or Build/Products/Release */
|
|
||||||
else if (CurrentDir("Debug") || CurrentDir("Release")) {
|
|
||||||
ChangeDirBack(5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef SINGLE_THREADED
|
#ifndef SINGLE_THREADED
|
||||||
|
|
||||||
|
@ -118,7 +100,7 @@ int testsuite_test(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(WOLFSSL_TIRTOS)
|
#if !defined(WOLFSSL_TIRTOS)
|
||||||
ChangeDirToRoot();
|
ChangeToWolfRoot();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_TIRTOS
|
#ifdef WOLFSSL_TIRTOS
|
||||||
|
@ -431,7 +413,7 @@ int main(int argc, char** argv)
|
||||||
server_args.argc = argc;
|
server_args.argc = argc;
|
||||||
server_args.argv = argv;
|
server_args.argv = argv;
|
||||||
|
|
||||||
ChangeDirToRoot();
|
ChangeToWolfRoot();
|
||||||
|
|
||||||
wolfcrypt_test(&server_args);
|
wolfcrypt_test(&server_args);
|
||||||
if (server_args.return_code != 0) return server_args.return_code;
|
if (server_args.return_code != 0) return server_args.return_code;
|
||||||
|
|
|
@ -45,6 +45,11 @@
|
||||||
*/
|
*/
|
||||||
int wolfcrypt_Init()
|
int wolfcrypt_Init()
|
||||||
{
|
{
|
||||||
|
#if WOLFSSL_CRYPT_HW_MUTEX
|
||||||
|
/* If crypto hardware mutex protection is enabled, then initialize it */
|
||||||
|
wolfSSL_CryptHwMutexInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* if defined have fast RSA then initialize Intel IPP */
|
/* if defined have fast RSA then initialize Intel IPP */
|
||||||
#ifdef HAVE_FAST_RSA
|
#ifdef HAVE_FAST_RSA
|
||||||
WOLFSSL_MSG("Setting up IPP Library");
|
WOLFSSL_MSG("Setting up IPP Library");
|
||||||
|
|
|
@ -1160,87 +1160,49 @@ static INLINE int OpenNitroxDevice(int dma_mode,int dev_id)
|
||||||
#endif /* HAVE_CAVIUM */
|
#endif /* HAVE_CAVIUM */
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_API
|
/* Wolf Root Directory Helper */
|
||||||
|
|
||||||
/* do back x number of directories */
|
|
||||||
static INLINE void ChangeDirBack(int x)
|
|
||||||
{
|
|
||||||
char path[MAX_PATH];
|
|
||||||
XMEMSET(path, 0, MAX_PATH);
|
|
||||||
XSTRNCAT(path, ".\\", MAX_PATH);
|
|
||||||
while (x-- > 0) {
|
|
||||||
XSTRNCAT(path, "..\\", MAX_PATH);
|
|
||||||
}
|
|
||||||
SetCurrentDirectoryA(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* does current dir contain str */
|
|
||||||
static INLINE int CurrentDir(const char* str)
|
|
||||||
{
|
|
||||||
char path[MAX_PATH];
|
|
||||||
char* baseName;
|
|
||||||
|
|
||||||
GetCurrentDirectoryA(sizeof(path), path);
|
|
||||||
|
|
||||||
baseName = strrchr(path, '\\');
|
|
||||||
if (baseName)
|
|
||||||
baseName++;
|
|
||||||
else
|
|
||||||
baseName = path;
|
|
||||||
|
|
||||||
if (strstr(baseName, str))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_FS)
|
|
||||||
/* KEIL-RL File System does not support relative directry */
|
/* KEIL-RL File System does not support relative directry */
|
||||||
#elif defined(WOLFSSL_TIRTOS)
|
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_FS) && !defined(WOLFSSL_TIRTOS)
|
||||||
#else
|
|
||||||
|
|
||||||
#ifndef MAX_PATH
|
#ifndef MAX_PATH
|
||||||
#define MAX_PATH 256
|
#define MAX_PATH 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* do back x number of directories */
|
/* Maximum depth to search for WolfSSL root */
|
||||||
static INLINE void ChangeDirBack(int x)
|
#define MAX_WOLF_ROOT_DEPTH 5
|
||||||
|
|
||||||
|
static INLINE int ChangeToWolfRoot(void)
|
||||||
{
|
{
|
||||||
|
#if !defined(NO_FILESYSTEM)
|
||||||
|
int depth;
|
||||||
|
XFILE file;
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
XMEMSET(path, 0, MAX_PATH);
|
XMEMSET(path, 0, MAX_PATH);
|
||||||
XSTRNCAT(path, "./", MAX_PATH);
|
|
||||||
while (x-- > 0) {
|
for(depth = 0; depth <= MAX_WOLF_ROOT_DEPTH; depth++) {
|
||||||
XSTRNCAT(path, "../", MAX_PATH);
|
file = XFOPEN(ntruKey, "rb");
|
||||||
|
if (file != XBADFILE) {
|
||||||
|
XFCLOSE(file);
|
||||||
|
return depth;
|
||||||
}
|
}
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
XSTRNCAT(path, "..\\", MAX_PATH);
|
||||||
|
SetCurrentDirectoryA(path);
|
||||||
|
#else
|
||||||
|
XSTRNCAT(path, "../", MAX_PATH);
|
||||||
if (chdir(path) < 0) {
|
if (chdir(path) < 0) {
|
||||||
printf("chdir to %s failed\n", path);
|
printf("chdir to %s failed\n", path);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* does current dir contain str */
|
err_sys("wolf root not found");
|
||||||
static INLINE int CurrentDir(const char* str)
|
return -1;
|
||||||
{
|
#else
|
||||||
char path[MAX_PATH];
|
|
||||||
char* baseName;
|
|
||||||
|
|
||||||
if (getcwd(path, sizeof(path)) == NULL) {
|
|
||||||
printf("no current dir?\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif /* !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_FS) && !defined(WOLFSSL_TIRTOS) */
|
||||||
baseName = strrchr(path, '/');
|
|
||||||
if (baseName)
|
|
||||||
baseName++;
|
|
||||||
else
|
|
||||||
baseName = path;
|
|
||||||
|
|
||||||
if (strstr(baseName, str))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* USE_WINDOWS_API */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_WOLFSSL_MEMORY
|
#ifdef USE_WOLFSSL_MEMORY
|
||||||
|
|
Loading…
Reference in New Issue