From 3ed2085e77655b54c405d68ae3835814c17451fb Mon Sep 17 00:00:00 2001 From: Takashi Kojo Date: Thu, 24 Oct 2013 17:20:12 +0900 Subject: [PATCH] ctaocrypt/{benchmark,src,test} files fro MDK5 --- ctaocrypt/benchmark/benchmark.c | 17 ++++++++----- ctaocrypt/src/asn.c | 6 ++++- ctaocrypt/src/memory.c | 2 +- ctaocrypt/test/test.c | 43 ++++++++++++++++++--------------- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/ctaocrypt/benchmark/benchmark.c b/ctaocrypt/benchmark/benchmark.c index 5923191e8..9da12d50c 100644 --- a/ctaocrypt/benchmark/benchmark.c +++ b/ctaocrypt/benchmark/benchmark.c @@ -51,6 +51,12 @@ #include "cavium_common.h" #include "cavium_ioctl.h" #endif + +#if defined(CYASSL_MDK_ARM) + extern FILE * CyaSSL_fopen(const char *fname, const char *mode) ; + #define fopen CyaSSL_fopen +#endif + #if defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048) /* include test cert and key buffers for use with NO_FILESYSTEM */ #if defined(CYASSL_MDK_ARM) @@ -909,7 +915,7 @@ void bench_eccKeyGen(void) ecc_key genKey; double start, total, each, milliEach; int i; - const int genTimes = 100; + const int genTimes = 5; /* 256 bit */ start = current_time(1); @@ -933,7 +939,7 @@ void bench_eccKeyAgree(void) ecc_key genKey, genKey2; double start, total, each, milliEach; int i, ret; - const int agreeTimes = 100; + const int agreeTimes = 5; byte shared[1024]; byte sig[1024]; byte digest[32]; @@ -1011,13 +1017,13 @@ void bench_eccKeyAgree(void) double current_time(int reset) { + (void)reset; + static int init = 0; static LARGE_INTEGER freq; LARGE_INTEGER count; - (void)reset; - if (!init) { QueryPerformanceFrequency(&freq); init = 1; @@ -1060,10 +1066,9 @@ void bench_eccKeyAgree(void) double current_time(int reset) { - struct timeval tv; - (void) reset; + struct timeval tv; gettimeofday(&tv, 0); return (double)tv.tv_sec + (double)tv.tv_usec / 1000000; diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index 4b99b6760..ea319800b 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -106,7 +106,11 @@ #define XGMTIME(c) gmtime((c)) #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t)) #elif defined(CYASSL_MDK_ARM) - #include + #if defined(CYASSL_MDK5) + #include "cmsis_os.h" + #else + #include + #endif #undef RNG #include "cyassl_MDK_ARM.h" #undef RNG diff --git a/ctaocrypt/src/memory.c b/ctaocrypt/src/memory.c index 3638e081a..1058e6bc1 100644 --- a/ctaocrypt/src/memory.c +++ b/ctaocrypt/src/memory.c @@ -75,7 +75,7 @@ void* CyaSSL_Malloc(size_t size) #ifdef CYASSL_MALLOC_CHECK if (res == NULL) - printf("CyaSSL_malloc failed\n"); + puts("CyaSSL_malloc failed"); #endif return res; diff --git a/ctaocrypt/test/test.c b/ctaocrypt/test/test.c index da922c979..24e3caf7c 100644 --- a/ctaocrypt/test/test.c +++ b/ctaocrypt/test/test.c @@ -74,6 +74,12 @@ #include #endif +#if defined(CYASSL_MDK_ARM) + #include + #include + extern FILE * CyaSSL_fopen(const char *fname, const char *mode) ; + #define fopen CyaSSL_fopen +#endif #if defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048) /* include test cert and key buffers for use with NO_FILESYSTEM */ @@ -2465,24 +2471,23 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out) static const char* caKeyFile = "a:\\certs\\ca-key.der"; static const char* caCertFile = "a:\\certs\\ca-cert.pem"; #endif - #elif defined(CYASSL_MKD_SHELL) - static char* clientKey = "certs/client-key.der"; - static char* clientCert = "certs/client-cert.der"; - void set_clientKey(char *key) { clientKey = key ; } /* set by shell command */ - void set_clientCert(char *cert) { clientCert = cert ; } /* set by shell command */ - #ifdef CYASSL_CERT_GEN - static char* caKeyFile = "certs/ca-key.der"; - static char* caCertFile = "certs/ca-cert.pem"; - void set_caKeyFile (char * key) { caKeyFile = key ; } /* set by shell command */ - void set_caCertFile(char * cert) { caCertFile = cert ; } /* set by shell command */ - #endif - #else - static const char* clientKey = "./certs/client-key.der"; - static const char* clientCert = "./certs/client-cert.der"; - #ifdef CYASSL_CERT_GEN - static const char* caKeyFile = "./certs/ca-key.der"; - static const char* caCertFile = "./certs/ca-cert.pem"; - #endif +#elif !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048) && defined(CYASSL_MKD_SHELL) + static char* clientKey = "certs/client-key.der"; + static char* clientCert = "certs/client-cert.der"; + void set_clientKey(char *key) { clientKey = key ; } /* set by shell command */ + void set_clientCert(char *cert) { clientCert = cert ; } /* set by shell command */ + #ifdef CYASSL_CERT_GEN + static char* caKeyFile = "certs/ca-key.der"; + static char* caCertFile = "certs/ca-cert.pem"; + void set_caKeyFile (char * key) { caKeyFile = key ; } /* set by shell command */ + void set_caCertFile(char * cert) { caCertFile = cert ; } /* set by shell command */ + #endif +#elif !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048) + static const char* clientKey = "./certs/client-key.der"; + static const char* clientCert = "./certs/client-cert.der"; + #ifdef CYASSL_CERT_GEN + static const char* caKeyFile = "./certs/ca-key.der"; + static const char* caCertFile = "./certs/ca-cert.pem"; #endif #endif @@ -2723,7 +2728,7 @@ int rsa_test(void) int pemSz; size_t bytes3; word32 idx3 = 0; - FILE* file3 ; + FILE* file3 ; #ifdef CYASSL_TEST_CERT DecodedCert decode; #endif