diff --git a/.gitignore b/.gitignore index c542ec121b..8ef6f71b1b 100644 --- a/.gitignore +++ b/.gitignore @@ -245,6 +245,7 @@ linuxkm/libwolfssl.mod.c linuxkm/libwolfssl.lds linuxkm/module_exports.c linuxkm/linuxkm/get_thread_size +*.nds # autotools generated scripts/unit.test diff --git a/ChangeLog.md b/ChangeLog.md index bee6e614ee..424ed5611b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -49,6 +49,7 @@ Fixed in github pull request https://github.com/wolfSSL/wolfssl/pull/7702 * Support for NIST 800-56C Option 1 KDF, using the macro WC_KDF_NIST_SP_800_56C added (PR 7589) * AES-XTS streaming mode added, along with hardware acceleration and kernel module use (PR 7522, 7560, 7424) * PlatformIO FreeRTOS with ESP build and addition of benchmark and test example applications (PR 7528, 7413, 7559, 7542) +* Add support for (DevkitPro)libnds ## Enhancements and Optimizations diff --git a/IDE/NDS/README.md b/IDE/NDS/README.md new file mode 100644 index 0000000000..88e9dbf414 --- /dev/null +++ b/IDE/NDS/README.md @@ -0,0 +1,36 @@ +# wolfSSL for libnds + +## Requirements + +[Devkitpro](https://devkitpro.org/wiki/Getting_Started) with libnds. + + +## Building + +``` +$ ./configure \ + --host=arm-none-eabi \ + CC=$DEVKITARM/bin/arm-none-eabi-g++ \ + AR=$DEVKITARM/bin/arm-none-eabi-ar \ + STRIP=$DEVKITARM/bin/arm-none-eabi-strip \ + RANLIB=$DEVKITARM/bin/arm-none-eabi-ranlib \ + LIBS="-lfat -lnds9" \ + LDFLAGS="-L/opt/devkitpro/libnds/lib" \ + --prefix=$DEVKITPRO/portlibs/nds \ + CFLAGS="-march=armv5te -mtune=arm946e-s \ + --specs=ds_arm9.specs -DARM9 -DNDS \ + -DWOLFSSL_USER_IO \ + -I$DEVKITPRO/libnds/include" \ + --enable-fastmath --disable-benchmark \ + --disable-shared --disable-examples --disable-ecc +$ make +$ sudo make install +``` + +## Run the Tests + +To run the Crypttests type the following. +1. Run `$ ndstool -9 ./wolfcrypt/test/testwolfcrypt -c ./wolfcrypt/test/testwolfcrypt.nds` +2. copy `./certs` to `your_nds_sd_card/_nds/certs` + +3. Run the Rom (located in ./wolfcrypt/test/testwolfcrypt.nds) in an Emulator or real Hardware. diff --git a/README b/README index 261eb200d6..f144c7cd21 100644 --- a/README +++ b/README @@ -121,6 +121,7 @@ Fixed in github pull request https://github.com/wolfSSL/wolfssl/pull/7702 * Support for NIST 800-56C Option 1 KDF, using the macro WC_KDF_NIST_SP_800_56C added (PR 7589) * AES-XTS streaming mode added, along with hardware acceleration and kernel module use (PR 7522, 7560, 7424) * PlatformIO FreeRTOS with ESP build and addition of benchmark and test example applications (PR 7528, 7413, 7559, 7542) +* Add support for (DevkitPro)libnds ## Enhancements and Optimizations diff --git a/README.md b/README.md index 28aac26695..e18172c19f 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ Fixed in github pull request https://github.com/wolfSSL/wolfssl/pull/7702 * Support for NIST 800-56C Option 1 KDF, using the macro WC_KDF_NIST_SP_800_56C added (PR 7589) * AES-XTS streaming mode added, along with hardware acceleration and kernel module use (PR 7522, 7560, 7424) * PlatformIO FreeRTOS with ESP build and addition of benchmark and test example applications (PR 7528, 7413, 7559, 7542) +* Add support for (DevkitPro)libnds ## Enhancements and Optimizations diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index f1022edea4..9307c96852 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -3815,7 +3815,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return ret; } -#elif defined(DOLPHIN_EMULATOR) +#elif defined(DOLPHIN_EMULATOR) || defined (NDS) int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) { diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 9371810649..37dee8d75c 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -426,6 +426,13 @@ const byte const_byte_array[] = "A+Gd\0\0\0"; #ifdef DEVKITPRO #include #endif +#ifdef NDS + #include + #include + #include + #include + #include +#endif #ifndef WOLFSSL_HAVE_ECC_KEY_GET_PRIV /* FIPS build has replaced ecc.h. */ @@ -2457,6 +2464,13 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\ VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); #endif +#ifdef NDS + /* Init Console output */ + consoleDemoInit(); + + /* Init the Filesystem */ + fatInitDefault(); +#endif #ifdef HAVE_WNR if ((ret = wc_InitNetRandom(wnrConfigFile, NULL, 5000)) != 0) { @@ -2502,6 +2516,18 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\ while (1); #endif +#ifdef NDS + /* in Nintendo DS returning from main shuts down the Device without letting you see the Results. */ + printf("args.return_code: %d\n", args.return_code); + printf("Testing complete. Press Start to exit the Program\n"); + while(1) { + swiWaitForVBlank(); + scanKeys(); + int keys = keysDown(); + if(keys & KEY_START) break; + } +#endif + #if defined(WOLFSSL_ESPIDF) /* ESP_LOGI to print takes up a lot less memory than printf */ ESP_LOGI(ESPIDF_TAG, "Exiting main with return code: % d\n", @@ -17955,6 +17981,10 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void) #elif defined(_WIN32_WCE) #define CERT_PREFIX "\\windows\\" #define CERT_PATH_SEP "\\" +#elif defined(NDS) + #undef CERT_PREFIX + #define CERT_PREFIX "fat:/_nds/" + #define CERT_PATH_SEP "/" #endif #ifndef CERT_PREFIX diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 63b2a8ed55..38d7483c16 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -3127,7 +3127,7 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len, !defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_ROWLEY_ARM) && \ !defined(WOLFSSL_EMBOS) && !defined(WOLFSSL_FROSTED) && \ !defined(WOLFSSL_CHIBIOS) && !defined(WOLFSSL_CONTIKI) && \ - !defined(WOLFSSL_ZEPHYR) && !defined(NETOS) + !defined(WOLFSSL_ZEPHYR) && !defined(NETOS) && !defined(NDS) #include #endif /* allow writev style writing */ diff --git a/wolfssl/test.h b/wolfssl/test.h index 0fb23c1962..e3e3286399 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -203,7 +203,9 @@ #include #include #include - #include + #ifndef NDS + #include + #endif #include #include #ifdef HAVE_PTHREAD diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index a1e4b90040..e3cda9857c 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -262,6 +262,9 @@ /* Uncomment next line if building for Dolphin Emulator */ /* #define DOLPHIN_EMULATOR */ +/* Uncomment next line if building for NDS */ +/* #define NDS */ + /* Uncomment next line if using MAXQ1065 */ /* #define WOLFSSL_MAXQ1065 */ @@ -469,6 +472,16 @@ #include #endif + +#ifdef NDS + #include + #define SIZEOF_LONG_LONG 8 + #define socklen_t int + #define IPPROTO_UDP 17 + #define IPPROTO_TCP 6 + #define NO_WRITEV +#endif + #if defined(ARDUINO) #if defined(ESP32) #ifndef NO_ARDUINO_DEFAULT