123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #ifndef WOLFSSL_USER_SETTINGS
- #include <wolfssl/options.h>
- #endif
- #include <wolfssl/wolfcrypt/settings.h>
- #include <wolfssl/wolfcrypt/error-crypt.h>
- #include <wolfssl/wolfcrypt/random.h> /* for CUSTOM_RAND_TYPE */
- #include <wolfcrypt/test/test.h>
- #include <wolfcrypt/benchmark/benchmark.h>
- #include <stdint.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include <string.h>
- #include "Ifx_Types.h"
- #include "IfxStm.h"
- extern int send_UART(const char* str);
- static void my_logging_cb(const int logLevel, const char *const logMessage)
- {
- send_UART(logMessage);
- send_UART("\r\n");
- (void)logLevel;
- }
- static int hw_get_time_sec(void)
- {
-
- return IfxStm_get(&MODULE_STM0) / IfxStm_getFrequency(&MODULE_STM0);
- }
- unsigned long my_time(unsigned long* timer)
- {
- (void)timer;
- return hw_get_time_sec();
- }
- #ifndef WOLFCRYPT_ONLY
- unsigned int LowResTimer(void)
- {
- return hw_get_time_sec();
- }
- #endif
- #ifndef NO_CRYPT_BENCHMARK
- double current_time(int reset)
- {
- double timeNow;
- uint64_t timeMs, ticks = IfxStm_get(&MODULE_STM0);
- (void)reset;
- timeMs = ticks / (IfxStm_getFrequency(&MODULE_STM0) / 1000);
- timeNow = (timeMs / 1000);
- timeNow += (double)(timeMs % 1000) / 1000;
- return timeNow;
- }
- #endif
- static unsigned int gCounter;
- unsigned int hw_rand(void)
- {
-
- return ++gCounter;
- }
- unsigned int my_rng_seed_gen(void)
- {
- return hw_rand();
- }
- typedef struct func_args {
- int argc;
- char** argv;
- int return_code;
- } func_args;
- void run_wolf_tests(void)
- {
- func_args args;
- #ifdef DEBUG_WOLFSSL
- wolfSSL_Debugging_ON();
- #endif
- wolfSSL_SetLoggingCb(my_logging_cb);
-
- #ifdef WOLFCRYPT_ONLY
- wolfCrypt_Init();
- #else
- wolfSSL_Init();
- #endif
- memset(&args, 0, sizeof(args));
- args.return_code = NOT_COMPILED_IN;
- printf("Running wolfCrypt Tests...\n");
- #ifndef NO_CRYPT_TEST
- args.return_code = 0;
- wolfcrypt_test(&args);
- printf("Crypt Test: Return code %d\n", args.return_code);
- #else
- args.return_code = NOT_COMPILED_IN;
- #endif
- printf("Running wolfCrypt Benchmarks...\n");
- #ifndef NO_CRYPT_BENCHMARK
- args.return_code = 0;
- benchmark_test(&args);
- #else
- args.return_code = NOT_COMPILED_IN;
- #endif
- printf("Benchmark Test: Return code %d\n", args.return_code);
- #ifdef WOLFCRYPT_ONLY
- wolfCrypt_Cleanup();
- #else
- wolfSSL_Cleanup();
- #endif
- }
|