diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 3906e70a5..6972484f7 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -814,7 +814,7 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz, } if (ret == DRBG_SUCCESS) - ret = Hash_DRBG_Instantiate((DRBG_internal *)rng->drbg, + ret = Hash_DRBG_Instantiate((DRBG_internal *)rng->drbg, seed + SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ, nonce, nonceSz, rng->heap, devId); @@ -2583,6 +2583,18 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return 0; } +#elif defined(DOLPHIN_EMULATOR) + + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) + { + word32 i; + (void)os; + srand(time(NULL)); + for (i = 0; i < sz; i++) + output[i] = (byte)rand(); + return 0; + } + #elif defined(NO_DEV_RANDOM) #error "you need to write an os specific wc_GenerateSeed() here" diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index b74e2de90..efa3c430f 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -332,6 +332,10 @@ _Pragma("GCC diagnostic ignored \"-Wunused-function\""); #include "libntruencrypt/ntru_crypto.h" #endif +#ifdef DEVKITPRO + #include +#endif + #ifdef WOLFSSL_STATIC_MEMORY static WOLFSSL_HEAP_HINT* HEAP_HINT; #else @@ -1463,6 +1467,26 @@ initDefaultName(); tz.tz_dsttime = 0; os_settimeofday(&utctime, &tz); #endif +#ifdef DEVKITPRO + void *framebuffer; + GXRModeObj *rmode = NULL; + + VIDEO_Init(); + WPAD_Init(); + + rmode = VIDEO_GetPreferredMode(NULL); +#pragma GCC diagnostic ignored "-Wbad-function-cast" + framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); +#pragma GCC diagnostic pop + console_init(framebuffer,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); + + VIDEO_Configure(rmode); + VIDEO_SetNextFramebuffer(framebuffer); + VIDEO_SetBlack(FALSE); + VIDEO_Flush(); + VIDEO_WaitVSync(); + if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); +#endif #ifdef HAVE_WNR if (wc_InitNetRandom(wnrConfigFile, NULL, 5000) != 0) { @@ -1494,7 +1518,15 @@ initDefaultName(); if (wc_FreeNetRandom() < 0) err_sys("Failed to free netRandom context", -1005); #endif /* HAVE_WNR */ +#ifdef DOLPHIN_EMULATOR + /* Returning from main panics the emulator. Just hang + * and let the user force quit the emulator window. */ + printf("args.return_code: %d\n", args.return_code); + printf("Testing complete. You may close the window now\n"); + while (1); +#endif #ifndef WOLFSSL_ESPIDF + printf("Exiting main with return code: %d\n", args.return_code); return args.return_code; #endif } diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index aeaa6bfdf..116d4b07e 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -218,6 +218,11 @@ /* Uncomment next line if building for Linux Kernel Module */ /* #define WOLFSSL_LINUXKM */ +/* Uncomment next line if building for devkitPro */ +/* #define DEVKITPRO */ + +/* Uncomment next line if building for Dolphin Emulator */ +/* #define DOLPHIN_EMULATOR */ #include diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index a9b59b253..aea6f8c75 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -287,8 +287,7 @@ #ifdef DEVKITPRO /* from network.h */ - int net_send(int, const void*, int, unsigned int); - int net_recv(int, void*, int, unsigned int); + #include #define SEND_FUNCTION net_send #define RECV_FUNCTION net_recv #elif defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)