#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/random.h>
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
static int gTimeMs;
static int hw_get_time_sec(void)
{
#warning Must implement your own time source if validating certificates
return ++gTimeMs;
}
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;
int timeMs = gTimeMs;
(void)reset;
timeNow = (timeMs / 1000); timeNow += (double)(timeMs % 1000) / 1000; return timeNow;
}
#endif
static unsigned int gCounter;
unsigned int hw_rand(void)
{
#warning Must implement your own random source
return ++gCounter;
}
unsigned int my_rng_seed_gen(void)
{
return hw_rand();
}
int my_rng_gen_block(unsigned char* output, unsigned int sz)
{
uint32_t i = 0;
while (i < sz)
{
if( (i + sizeof(CUSTOM_RAND_TYPE)) > sz ||
((uint32_t)&output[i] % sizeof(CUSTOM_RAND_TYPE)) != 0
) {
output[i++] = (unsigned char)my_rng_seed_gen();
}
else {
*((CUSTOM_RAND_TYPE*)&output[i]) = my_rng_seed_gen();
i += sizeof(CUSTOM_RAND_TYPE);
}
}
return 0;
}
#ifdef XMALLOC_OVERRIDE
void *myMalloc(size_t n, void* heap, int type)
{
(void)n;
(void)heap;
(void)type;
#warning Must implement your own malloc
return NULL;
}
void myFree(void *p, void* heap, int type)
{
(void)p;
(void)heap;
(void)type;
#warning Must implement your own free
}
void *myRealloc(void *p, size_t n, void* heap, int type)
{
(void)p;
(void)n;
(void)heap;
(void)type;
#warning Must implement your own realloc
return NULL;
}
#endif