add micrium current_time and use correct serial function

This commit is contained in:
Tesfa Mael
2018-11-18 23:37:22 -08:00
parent 061757c909
commit 2ad6ce351b
4 changed files with 97 additions and 20 deletions

View File

@ -19,7 +19,7 @@
#define TX_MSG "GET /index.html HTTP/1.0\r\n\r\n"
#define TX_MSG_SIZE sizeof(TX_MSG)
const CPU_CHAR google_certs_ca[]="\n\
const CPU_INT08U google_certs_ca[]="\n\
## Google Internet Authority G3 \n\
-----BEGIN CERTIFICATE-----\n\
MIIEXDCCA0SgAwIBAgINAeOpMBz8cgY4P5pTHTANBgkqhkiG9w0BAQsFADBMMSAw\n\

View File

@ -6,19 +6,21 @@
#endif
#define MICRIUM
#define WOLFSSL_MICRIUM_3_0
/* You can select one or all of the following tests */
#define WOLFSSL_WOLFCRYPT_TEST
#define WOLFSSL_BENCHMARK_TEST
/*
#define WOLFSSL_MICRIUM_CRYPTO_TEST
#define WOLFSSL_MICRIUM_CLIENT_TEST
#define WOLFSSL_MICRIUM_SERVER_TEST
*/
#define WOLFSSL_CLIENT_TEST
#define WOLFSSL_SERVER_TEST
/* test.h includes platform dependent header files.
When using Windows simulator, you must define USE_WINDOWS_API */
/* adjust x to seconds since Jan 01 1970. (UTC)
https://www.unixtimestamp.com/
*/
#define CURRENT_UNIX_TS 1542605837
/* When using Windows simulator, you must define USE_WINDOWS_API for test.h to build */
#ifdef _WIN32
define USE_WINDOWS_API
#define USE_WINDOWS_API
#endif
#define NO_FILESYSTEM
@ -39,11 +41,17 @@ define USE_WINDOWS_API
#define NO_WRITE_TEMP_FILES
/* no pow, no math.h */
#define WOLFSSL_DH_CONST
//#define WOLFSSL_DH_CONST
#define XSNPRINTF snprintf
//#define NO_ASN_TIME
#define HAVE_AESGCM
#define WOLFSSL_SHA512
#define HAVE_ECC
#define HAVE_CURVE25519
#define CURVE25519_SMALL
#define HAVE_ED25519
#ifdef __cplusplus
} /* extern "C" */

View File

@ -0,0 +1,59 @@
#include <includes.h> /* master includes from Micrium Freescale Kinetis K70*/
#include <wolfssl/ssl.h>
/*
* Description : This function runs wolfssl tests.
* Caller(s) : main() in app.c
* Note(s) : none.
*/
int wolfsslRunTests (void)
{
CLK_ERR err;
CLK_TS_SEC ts_unix_sec;
CPU_BOOLEAN valid;
static int initialized = 0;
if(!initialized) {
Clk_Init(&err);
if (err == CLK_ERR_NONE) {
APP_TRACE_INFO(("Clock module successfully initialized\n"));
} else {
APP_TRACE_INFO(("Clock module initialization failed\n"));
return -1;
}
valid = Clk_GetTS_Unix(&ts_unix_sec);
if (valid == DEF_OK) {
APP_TRACE_INFO(("Timestamp Unix = %u\n", ts_unix_sec));
} else {
APP_TRACE_INFO(("Get TS Unix error\n"));
}
#if defined(CURRENT_UNIX_TS)
valid = Clk_SetTS_Unix(CURRENT_UNIX_TS);
if (valid != DEF_OK) {
APP_TRACE_INFO(("Clk_SetTS_Unix error\n"));
return -1;
}
#endif
initialized = 1;
}
#if defined(WOLFSSL_WOLFCRYPT_TEST)
wolfcrypt_test(NULL);
#endif
#if defined(WOLFSSL_BENCHMARK_TEST)
benchmark_test(NULL);
#endif
#if defined(WOLFSSL_CLIENT_TEST)
wolfssl_client_test();
#endif
#if defined(WOLFSSL_SERVER_TEST)
wolfssl_server_test();
#endif
return 0;
}

View File

@ -60,6 +60,11 @@
#undef printf
#define printf PRINTF
#elif defined(MICRIUM)
#include <bsp_ser.h>
void BSP_Ser_Printf (CPU_CHAR* format, ...);
#undef printf
#define printf BSP_Ser_Printf
#else
#include <stdio.h>
#endif
@ -439,7 +444,7 @@ static const char* bench_Usage_msg1[][10] = {
"-<alg> アルゴリズムのベンチマークを実施します。\n 利用可能なアルゴリズムは下記を含みます:\n",
"-lng <num> 指定された言語でベンチマーク結果を表示します。\n 0: 英語、 1: 日本語\n",
"<num> ブロックサイズをバイト単位で指定します。\n",
},
},
};
static const char* bench_result_words1[][4] = {
@ -455,7 +460,7 @@ static const char* bench_result_words1[][4] = {
static const char* bench_desc_words[][9] = {
/* 0 1 2 3 4 5 6 7 8 */
{"public", "private", "key gen", "agree" , "sign", "verify", "encryption", "decryption", NULL}, /* 0 English */
{"公開鍵", "秘密鍵" ,"鍵生成" , "鍵共有" , "署名", "検証" , "暗号化" , "復号化" , NULL}, /* 1 Japanese */
{"公開鍵", "秘密鍵" ,"鍵生成" , "鍵共有" , "署名", "検証" , "暗号化" , "復号化" , NULL}, /* 1 Japanese */
};
#endif
@ -977,7 +982,7 @@ static void bench_stats_sym_finish(const char* desc, int doAsync, int count,
SHOW_INTEL_CYCLES_CSV(msg, sizeof(msg), countSz);
} else {
XSNPRINTF(msg, sizeof(msg), "%-16s%s %5.0f %s %s %5.3f %s, %8.3f %s/s",
desc, BENCH_ASYNC_GET_NAME(doAsync), blocks, blockType, word[0], total, word[1],
desc, BENCH_ASYNC_GET_NAME(doAsync), blocks, blockType, word[0], total, word[1],
persec, blockType);
SHOW_INTEL_CYCLES(msg, sizeof(msg), countSz);
}
@ -1637,11 +1642,9 @@ int benchmark_test(void *args)
(void)args;
printf(
"------------------------------------------------------------------------------"
"\n wolfSSL version %s\n"
"------------------------------------------------------------------------------"
"\n", LIBWOLFSSL_VERSION_STRING);
printf("------------------------------------------------------------------------------\n");
printf(" wolfSSL version %s\n", LIBWOLFSSL_VERSION_STRING);
printf("------------------------------------------------------------------------------\n");
ret = benchmark_init();
if (ret != 0)
@ -3854,7 +3857,6 @@ static void bench_rsa_helper(int doAsync, RsaKey rsaKey[BENCH_MAX_PENDING],
const int len = (int)XSTRLEN((char*)messageStr);
double start = 0.0f;
const char**desc = bench_desc_words[lng_index];
DECLARE_VAR_INIT(message, byte, len, messageStr, HEAP_HINT);
DECLARE_ARRAY(enc, byte, BENCH_MAX_PENDING, rsaKeySz/8, HEAP_HINT);
DECLARE_ARRAY(out, byte, BENCH_MAX_PENDING, rsaKeySz/8, HEAP_HINT);
@ -5040,6 +5042,14 @@ exit_ed_verify:
#elif defined(WOLFSSL_SGX)
double current_time(int reset);
#elif defined(MICRIUM)
double current_time(int reset)
{
CPU_ERR err;
(void)reset;
return (double) CPU_TS_Get32()/CPU_TS_TmrFreqGet(&err);
}
#else
#include <sys/time.h>