Merge pull request #7990 from buchstabenwurst/master

Add support for (DevkitPro)libnds
This commit is contained in:
JacobBarthelmeh 2024-09-25 15:52:34 -06:00 committed by GitHub
commit d72c0b372c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 88 additions and 3 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -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

36
IDE/NDS/README.md Normal file
View File

@ -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.

1
README
View File

@ -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

View File

@ -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

View File

@ -3817,7 +3817,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)
{

View File

@ -429,6 +429,13 @@ const byte const_byte_array[] = "A+Gd\0\0\0";
#ifdef DEVKITPRO
#include <wiiuse/wpad.h>
#endif
#ifdef NDS
#include <nds/ndstypes.h>
#include <nds/arm9/console.h>
#include <nds/arm9/input.h>
#include <nds/interrupts.h>
#include <fat.h>
#endif
#ifndef WOLFSSL_HAVE_ECC_KEY_GET_PRIV
/* FIPS build has replaced ecc.h. */
@ -2466,6 +2473,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) {
@ -2511,6 +2525,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",
@ -18083,6 +18109,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

View File

@ -3164,7 +3164,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 <sys/uio.h>
#endif
/* allow writev style writing */

View File

@ -203,7 +203,9 @@
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#ifndef NDS
#include <sys/ioctl.h>
#endif
#include <sys/time.h>
#include <sys/socket.h>
#ifdef HAVE_PTHREAD

View File

@ -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 */
@ -470,6 +473,16 @@
#include <nx_api.h>
#endif
#ifdef NDS
#include <stddef.h>
#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