Browse Source

Add nuttx integration (#6043)

John Bland 1 year ago
parent
commit
e9aeb1a857
52 changed files with 567 additions and 51 deletions
  1. 1 1
      IDE/zephyr/README.md
  2. 2 1
      Makefile.am
  3. 10 0
      RTOS/nuttx/include.am
  4. 2 0
      RTOS/nuttx/wolfssl/.gitignore
  5. 108 0
      RTOS/nuttx/wolfssl/Kconfig
  6. 35 0
      RTOS/nuttx/wolfssl/Make.defs
  7. 175 0
      RTOS/nuttx/wolfssl/Makefile
  8. 98 0
      RTOS/nuttx/wolfssl/README.md
  9. 11 0
      RTOS/nuttx/wolfssl/setup-wolfssl.sh
  10. 65 0
      RTOS/nuttx/wolfssl/user_settings.h
  11. 0 0
      RTOS/zephyr/CMakeLists.txt
  12. 0 0
      RTOS/zephyr/Kconfig
  13. 0 0
      RTOS/zephyr/Kconfig.tls-generic
  14. 0 0
      RTOS/zephyr/README.md
  15. 45 0
      RTOS/zephyr/include.am
  16. 0 0
      RTOS/zephyr/module.yml
  17. 0 0
      RTOS/zephyr/nrf5340dk_nrf5340_user_settings.h
  18. 0 0
      RTOS/zephyr/samples/wolfssl_benchmark/CMakeLists.txt
  19. 0 0
      RTOS/zephyr/samples/wolfssl_benchmark/README
  20. 0 0
      RTOS/zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp.conf
  21. 0 0
      RTOS/zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
  22. 0 0
      RTOS/zephyr/samples/wolfssl_benchmark/install_test.sh
  23. 0 0
      RTOS/zephyr/samples/wolfssl_benchmark/prj.conf
  24. 0 0
      RTOS/zephyr/samples/wolfssl_benchmark/sample.yaml
  25. 0 0
      RTOS/zephyr/samples/wolfssl_test/CMakeLists.txt
  26. 0 0
      RTOS/zephyr/samples/wolfssl_test/README
  27. 0 0
      RTOS/zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp.conf
  28. 0 0
      RTOS/zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
  29. 0 0
      RTOS/zephyr/samples/wolfssl_test/install_test.sh
  30. 0 0
      RTOS/zephyr/samples/wolfssl_test/prj.conf
  31. 0 0
      RTOS/zephyr/samples/wolfssl_test/sample.yaml
  32. 0 0
      RTOS/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt
  33. 0 0
      RTOS/zephyr/samples/wolfssl_tls_sock/README
  34. 0 0
      RTOS/zephyr/samples/wolfssl_tls_sock/install_sample.sh
  35. 0 0
      RTOS/zephyr/samples/wolfssl_tls_sock/prj.conf
  36. 0 0
      RTOS/zephyr/samples/wolfssl_tls_sock/sample.yaml
  37. 0 0
      RTOS/zephyr/samples/wolfssl_tls_sock/src/tls_sock.c
  38. 0 0
      RTOS/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt
  39. 0 0
      RTOS/zephyr/samples/wolfssl_tls_thread/README
  40. 0 0
      RTOS/zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp.conf
  41. 0 0
      RTOS/zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
  42. 0 0
      RTOS/zephyr/samples/wolfssl_tls_thread/install_sample.sh
  43. 0 0
      RTOS/zephyr/samples/wolfssl_tls_thread/prj.conf
  44. 0 0
      RTOS/zephyr/samples/wolfssl_tls_thread/sample.yaml
  45. 0 0
      RTOS/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c
  46. 0 0
      RTOS/zephyr/user_settings-tls-generic.h
  47. 0 0
      RTOS/zephyr/user_settings.h
  48. 0 0
      RTOS/zephyr/wolfssl/options.h
  49. 0 0
      RTOS/zephyr/zephyr_init.c
  50. 2 2
      src/tls13.c
  51. 13 2
      wolfcrypt/test/test.c
  52. 0 45
      zephyr/include.am

+ 1 - 1
IDE/zephyr/README.md

@@ -1,3 +1,3 @@
 # Zephyr
 
-Zephyr Project Port has been moved to [wolfssl/zephyr](../../zephyr/README.md)
+Zephyr Project Port has been moved to [wolfssl/RTOS/zephyr](../../RTOS/zephyr/README.md)

+ 2 - 1
Makefile.am

@@ -179,7 +179,8 @@ include tests/include.am
 include sslSniffer/sslSnifferTest/include.am
 include rpm/include.am
 include linuxkm/include.am
-include zephyr/include.am
+include RTOS/zephyr/include.am
+include RTOS/nuttx/include.am
 
 # Exclude references to non-DFSG sources from build files
 if !BUILD_DISTRO

+ 10 - 0
RTOS/nuttx/include.am

@@ -0,0 +1,10 @@
+# vim:ft=automake
+# included from Top Level Makefile.am
+# All paths should be given relative to the rootEXTRA_DIST+= nuttx/include.am
+EXTRA_DIST+= RTOS/nuttx/wolfssl/.gitignore
+EXTRA_DIST+= RTOS/nuttx/wolfssl/README.md
+EXTRA_DIST+= RTOS/nuttx/wolfssl/Kconfig
+EXTRA_DIST+= RTOS/nuttx/wolfssl/Makefile
+EXTRA_DIST+= RTOS/nuttx/wolfssl/setup-wolfssl.sh
+EXTRA_DIST+= RTOS/nuttx/wolfssl/user_settings.h
+EXTRA_DIST+= RTOS/nuttx/wolfssl/Make.defs

+ 2 - 0
RTOS/nuttx/wolfssl/.gitignore

@@ -0,0 +1,2 @@
+/wolfssl
+/*.zip

+ 108 - 0
RTOS/nuttx/wolfssl/Kconfig

@@ -0,0 +1,108 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menuconfig CRYPTO_WOLFSSL
+	bool "wolfSSL SSL/TLS Cryptography Library"
+	default n
+	---help---
+		Enable support for wolfSSL
+
+if CRYPTO_WOLFSSL
+
+config WOLFSSL_VERSION
+	string "wolfSSL Version"
+	default "5.5.4"
+
+menuconfig WOLFCRYPT_APPS
+	tristate "wolfCrypt applications"
+	default n
+	---help---
+		Enable wolfCrypt applications
+
+if WOLFCRYPT_APPS
+
+config WOLFSSL_DEFAULT_TASK_STACKSIZE
+	int "wolfSSL app default stack size"
+	default 16384
+
+config WOLFCRYPT_APP_BENCHMARK
+	bool "wolfCrypt Benchmark application"
+	default n
+	---help---
+		Enable the wolfCrypt benchmark application
+
+if WOLFCRYPT_APP_BENCHMARK
+
+config WOLFCRYPT_APP_BENCHMARK_PROGNAME
+	string "Program name"
+	default "wolfcrypt_benchmark"
+	---help---
+		This is the name of the program that will be used when the NSH ELF
+		program is installed.
+
+config WOLFCRYPT_APP_BENCHMARK_PRIORITY
+	int "wolfcrypt benchmark task priority"
+	default 100
+
+config WOLFCRYPT_APP_BENCHMARK_STACKSIZE
+	int "wolfcrypt benchmark stack size"
+	default WOLFSSL_DEFAULT_TASK_STACKSIZE
+
+endif
+
+config WOLFCRYPT_APP_SELFTEST
+	bool "wolfCrypt Self Test application"
+	default n
+	---help---
+		Enable the wolfCrypt self-test app
+
+if WOLFCRYPT_APP_SELFTEST
+
+config WOLFCRYPT_APP_SELFTEST_PROGNAME
+	string "Program name"
+	default "wolfcrypt_test"
+	---help---
+		This is the name of the program that will be used when the NSH ELF
+		program is installed.
+
+config WOLFCRYPT_APP_SELFTEST_PRIORITY
+	int "wolfcrypt self-test task priority"
+	default 100
+
+config WOLFCRYPT_APP_SELFTEST_STACKSIZE
+	int "wolfcrypt self-test stack size"
+	default WOLFSSL_DEFAULT_TASK_STACKSIZE
+
+endif
+
+config WOLFSSL_APP_CLIENT_SERVER
+	bool "wolfSSL client and server example"
+	default n
+	---help---
+		runs both a tls client and server in the same task that connect to one
+		another, requires local loopback
+
+if WOLFSSL_APP_CLIENT_SERVER
+
+config WOLFSSL_APP_CLIENT_SERVER_PROGNAME
+	string "Program name"
+	default "wolfssl_client_server"
+	---help---
+		This is the name of the program that will be used when the NSH ELF
+		program is installed.
+
+config WOLFSSL_APP_CLIENT_SERVER_PRIORITY
+	int "wolfssl client server task priority"
+	default 100
+
+config WOLFSSL_APP_CLIENT_SERVER_STACKSIZE
+	int "wolfssl client server stack size"
+	default WOLFSSL_DEFAULT_TASK_STACKSIZE
+
+endif
+
+endif
+
+endif # CRYPTO_WOLFSSL

+ 35 - 0
RTOS/nuttx/wolfssl/Make.defs

@@ -0,0 +1,35 @@
+############################################################################
+# apps/crypto/wolfssl/Make.defs
+#
+# Copyright (C) 2006-2023 wolfSSL Inc.
+#
+# This file is part of wolfSSL. (formerly known as CyaSSL)
+#
+# wolfSSL is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# wolfSSL is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+############################################################################
+
+ifeq ($(CONFIG_CRYPTO_WOLFSSL),y)
+CONFIGURED_APPS += $(APPDIR)/crypto/wolfssl
+
+CFLAGS += ${INCDIR_PREFIX}${APPDIR}/crypto/wolfssl
+CFLAGS += ${INCDIR_PREFIX}${APPDIR}/crypto/wolfssl/wolfssl
+CFLAGS += ${DEFINE_PREFIX}WOLFSSL_CONFIG_FILE="<crypto/wolfssl_config.h>"
+
+CXXFLAGS += ${INCDIR_PREFIX}${APPDIR}/crypto/wolfssl
+CXXFLAGS += ${INCDIR_PREFIX}${APPDIR}/crypto/wolfssl/wolfssl
+CXXFLAGS += ${DEFINE_PREFIX}WOLFSSL_CONFIG_FILE="<crypto/wolfssl_config.h>"
+
+endif

+ 175 - 0
RTOS/nuttx/wolfssl/Makefile

@@ -0,0 +1,175 @@
+############################################################################
+# apps/crypto/wolfssl/Makefile
+#
+# Copyright (C) 2006-2023 wolfSSL Inc.
+#
+# This file is part of wolfSSL. (formerly known as CyaSSL)
+#
+# wolfSSL is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# wolfSSL is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+# wolfSSL SSL/TLS crypto library
+
+# Set up build configuration and environment
+https://github.com/wolfSSL/wolfssl/archive/refs/tags/v5.5.4-stable.zip
+WOLFSSL_URL ?= "https://github.com/wolfSSL/wolfssl/archive/refs/tags"
+
+WOLFSSL_VERSION = $(patsubst "%",%,$(strip $(CONFIG_WOLFSSL_VERSION)))
+WOLFSSL_ZIP = v$(WOLFSSL_VERSION)-stable.zip
+
+WOLFSSL_UNPACKNAME = wolfssl
+WOLFSSL_EXAMPLESNAME = wolfssl-examples
+UNPACK ?= unzip -q -o
+
+# WOLFSSL TLS FILES
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/crl.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/internal.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/keys.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/ocsp.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/sniffer.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/ssl.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/tls.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/tls13.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/wolfio.c
+
+# wolfCrypt Core (FIPS validated crypto available contact fips@wolfssl.com)
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/aes.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/cmac.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/des3.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/dh.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/ecc.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/hmac.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/random.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/rsa.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sha.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sha256.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sha512.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sha3.c
+
+# wolfCrypt Additional
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/asm.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/asn.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/blake2s.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/chacha.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/chacha20_poly1305.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/coding.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/compress.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/cpuid.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/cryptocb.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/curve25519.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/curve448.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/ecc_fp.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/eccsi.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/ed25519.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/ed448.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/error.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/fe_448.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/fe_low_mem.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/fe_operations.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/ge_448.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/ge_low_mem.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/ge_operations.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/hash.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/kdf.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/integer.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/logging.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/md5.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/memory.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/pkcs12.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/pkcs7.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/poly1305.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/pwdbased.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/rc2.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sakke.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/signature.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/srp.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_arm32.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_arm64.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_armthumb.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_c32.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_c64.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_cortexm.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_dsp32.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_int.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/sp_x86_64.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/tfm.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wc_dsp.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wc_encrypt.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wc_pkcs11.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wc_port.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wolfevent.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wolfmath.c
+
+
+CFLAGS += -DWOLFSSL_USER_SETTINGS
+
+
+ifneq ($(CONFIG_WOLFCRYPT_APPS),)
+
+MODULE = $(CONFIG_WOLFSSL_APPS)
+
+ifeq ($(CONFIG_WOLFCRYPT_APP_BENCHMARK),y)
+
+PROGNAME  += $(CONFIG_WOLFCRYPT_APP_BENCHMARK_PROGNAME)
+PRIORITY  += $(CONFIG_WOLFCRYPT_APP_BENCHMARK_PRIORITY)
+STACKSIZE += $(CONFIG_WOLFCRYPT_APP_BENCHMARK_STACKSIZE)
+
+CFLAGS += -I$(WOLFSSL_UNPACKNAME)
+CFLAGS += -I$(WOLFSSL_UNPACKNAME)/../ # To reach user_settings.h
+MAINSRC += $(WOLFSSL_UNPACKNAME)/wolfcrypt/benchmark/benchmark.c
+
+endif
+
+ifeq ($(CONFIG_WOLFCRYPT_APP_SELFTEST),y)
+
+PROGNAME  += $(CONFIG_WOLFCRYPT_APP_SELFTEST_PROGNAME)
+PRIORITY  += $(CONFIG_WOLFCRYPT_APP_SELFTEST_PRIORITY)
+STACKSIZE += $(CONFIG_WOLFCRYPT_APP_SELFTEST_STACKSIZE)
+
+CFLAGS += -I$(WOLFSSL_UNPACKNAME)
+CFLAGS += -I$(WOLFSSL_UNPACKNAME)/../ # To reach user_settings.h
+MAINSRC += $(WOLFSSL_UNPACKNAME)/wolfcrypt/test/test.c
+
+endif
+
+ifeq ($(CONFIG_WOLFSSL_APP_CLIENT_SERVER),y)
+
+PROGNAME  += $(CONFIG_WOLFSSL_APP_CLIENT_SERVER_PROGNAME)
+PRIORITY  += $(CONFIG_WOLFSSL_APP_CLIENT_SERVER_PRIORITY)
+STACKSIZE += $(CONFIG_WOLFSSL_APP_CLIENT_SERVER_STACKSIZE)
+
+CFLAGS += -I$(WOLFSSL_UNPACKNAME)
+CFLAGS += -I$(WOLFSSL_UNPACKNAME)/../ # To reach user_settings.h
+MAINSRC += $(WOLFSSL_EXAMPLESNAME)/embedded/tls-client-server.c
+
+endif
+
+endif
+
+$(WOLFSSL_ZIP):
+	@echo "Downloading: $(WOLFSSL_ZIP)"
+	$(Q) curl -O -L $(CONFIG_WOLFSSL_URL)/$(WOLFSSL_ZIP)
+
+$(WOLFSSL_UNPACKNAME): $(WOLFSSL_ZIP)
+	@echo "Unpacking: $(WOLFSSL_ZIP) -> $(WOLFSSL_UNPACKNAME)"
+	$(Q) $(UNPACK) $(WOLFSSL_ZIP)
+	$(Q) mv	wolfssl-$(WOLFSSL_VERSION) $(WOLFSSL_UNPACKNAME)
+	$(Q) touch $(WOLFSSL_UNPACKNAME)
+
+
+include $(APPDIR)/Application.mk

+ 98 - 0
RTOS/nuttx/wolfssl/README.md

@@ -0,0 +1,98 @@
+# NuttX + wolfSSL
+
+## Installation
+
+### Installing from nuttx-apps
+
+Clone wolfssl into the the the crypto/wolfssl folder
+
+```
+git clone https://github.com/wolfSSL/wolfssl.git apps/crypto/wolfssl/wolfssl
+```
+
+Skip to step 6
+
+### Installing from wolfssl
+
+1) Create working directory (e.g. ~/nuttxspace):
+    ```
+    $ cd ~
+    $ mkdir nuttxspace
+    ```
+2) Install dependencies:
+    ```
+    $ cd ~/nuttxspace
+    $ sudo apt install -y bison flex gettext texinfo libncurses5-dev libncursesw5-dev gperf automake libtool pkg-config build-essential gperf genromfs libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev libexpat-dev gcc-multilib g++-multilib picocom u-boot-tools util-linux
+    $ sudo apt install -y kconfig-frontends
+    $ sudo apt install -y gcc-arm-none-eabi binutils-arm-none-eabi
+    ```
+3) Clone nuttx and nuttx-apps into working directory:
+    ```
+    $ git clone https://github.com/apache/nuttx.git nuttx
+    $ git clone https://github.com/apache/nuttx-apps apps
+    ```
+4) Copy this directory into the working directory applications:
+    ```
+    $ cp -R RTOS/nuttx/wolfssl ~/nuttxspace/apps/crypto/wolfssl
+    ```
+5) Setup wolfSSL in preparation for the build, `WOLFSSL_DIR` must be the path to the original wolfssl repo:
+    ```
+    $ cd ~/nuttxspace/apps/crypto/wolfssl
+    $ WOLFSSL_DIR=<path-to-wolfssl-repo> ./setup-wolfssl.sh
+    ```
+6) Setup baseline NuttX configuration (board + NuttX Shell):
+    ```
+    $ cd ~/nuttxspace/nuttx
+    $ ./tools/configure.sh -l <board>:nsh
+    ```
+   If you are using wolfSSL for TLS you should use the `netnsh` target if your board supports it
+   ```
+    $ ./tools/configure.sh -l <board>:netnsh
+   ```
+> **EXAMPLES:**
+>   - For NuttX Simulator: `$ ./tools/configure.sh sim:nsh`
+>   - For BL602 (RISC-V): `$ ./tools/configure.sh -l bl602evb:nsh`
+>   - For NUCLEO-L552ZE-Q (Cortex-M33): `$ ./tools/configure.sh -l nucleo-l552ze:nsh`
+>   - For NUCLEO-H753ZI: `$ ./tools/configure.sh -l nucleo-h743zi:nsh`
+>   - For NUCLEO-F756ZG: `./tools/configure.sh -l nucleo-144:f746-nsh`
+
+7) Start custom configuration system:
+    ```
+    $ make menuconfig
+    ```
+8) Configure NuttX to enable the wolfSSL crypto library test applications:
+    - From main menu select: **Application Configuration > Cryptography Library Support**
+    - Enable and then select **wolfSSL SSL/TLS Cryptography Library**
+    - Enable and then select **wolfSSL applications**
+    - Enable applications:
+        - **wolfCrypt Benchmark application**
+        - **wolfCrypt Test application**
+        - **wolfSSL client and server example**
+    - Select Save from bottom menu, saving to `.config` file
+    - Exit configuration tool
+
+    If you are using wolfSSL for TLS you should use the `netnsh` target and should enable an NTP or some for of system time keeping so that wolfSSL has the current date to check certificates. You will also need to set the right networking settings for NuttX to connect to the internet.
+9) Build NuttX and wolfSSL:
+    ```
+    $ make
+    ```
+10) Flash the target
+    ### Simulator
+      ./nuttx
+    ### STM32 Targets (address may vary)
+      STM32_Programmer_CLI -c port=swd -d ./nuttx.bin 0x08000000
+11) Connect to the target with a serial monitoring tool, the device on linux is usually /dev/ttyACM0 but it may vary
+    - minicom -D /dev/ttyACM0
+12) Run the wolfcrypt benchmark and/or test in the NuttX Shell:
+    ```
+    nsh> wolfcrypt_test
+    nsh> wolfcrypt_benchmark
+    nsh> wolfssl_client_server
+    ```
+## Notes
+- Developed using the following targets:
+    - STM NUCLEO-L552ZE-Q (Cortex-M33)
+    - STM NUCLEO-H753ZI
+    - STM NUCLEO-F756ZG
+    - DT-BL10 / BL602 (RISC-V)
+    - NuttX simulator

+ 11 - 0
RTOS/nuttx/wolfssl/setup-wolfssl.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e # exit on any command failure
+if [ ! -d wolfssl ]; then
+    if [ -z $WOLFSSL_DIR ]; then
+        echo "Failed to find WOLFSSL_DIR, please set it and run again"
+    else
+        git clone $WOLFSSL_DIR
+        git clone https://github.com/wolfssl/wolfssl-examples
+    fi
+fi

+ 65 - 0
RTOS/nuttx/wolfssl/user_settings.h

@@ -0,0 +1,65 @@
+#include <nuttx/config.h>
+
+/* Library */
+#define SINGLE_THREADED
+#define WOLFSSL_SMALL_STACK
+
+/* Environment */
+#define NO_FILESYSTEM
+#define HAVE_STRINGS_H
+#define WOLF_C99
+
+/* Math */
+#if defined(CONFIG_ARCH_CHIP_STM32L552ZE) || defined(CONFIG_ARCH_CHIP_STM32F746ZG) || defined(CONFIG_ARCH_CHIP_STM32H743ZI)
+    #define WOLFSSL_SP
+    #define WOLFSSL_SP_SMALL
+    #define WOLFSSL_HAVE_SP_RSA
+    #define WOLFSSL_HAVE_SP_DH
+    #define WOLFSSL_HAVE_SP_ECC
+    #define WOLFSSL_SP_MATH
+    #define SP_WORD_SIZE 32
+    #define WOLFSSL_SP_ASM
+    #define WOLFSSL_SP_ARM_CORTEX_M_ASM
+#else
+    #define WOLFSSL_SP_MATH_ALL
+#endif
+
+/* Crypto */
+#define HAVE_ECC
+#define ECC_TIMING_RESISTANT
+#define WC_RSA_BLINDING
+#undef  RSA_LOW_MEM
+#define NO_MD4
+#define NO_DSA
+
+/* RNG */
+#define WOLFSSL_GENSEED_FORTEST
+
+/* Applications */
+#define NO_MAIN_FUNCTION
+#define BENCH_EMBEDDED
+#define WOLFSSL_BENCHMARK_FIXED_UNITS_MB
+
+/* Development */
+/*#define DEBUG_WOLFSSL*/
+
+#define HAVE_TLS_EXTENSIONS
+#define HAVE_SUPPORTED_CURVES
+#define HAVE_ENCRYPT_THEN_MAC
+#define HAVE_EXTENDED_MASTER
+#define WOLFSSL_TLS13
+#define HAVE_AESGCM
+#define HAVE_HKDF
+#define HAVE_DH
+#define HAVE_FFDHE_2048
+#define HAVE_DH_DEFAULT_PARAMS
+#define WC_RSA_PSS
+#define HAVE_AEAD
+#define WOLFSSL_SHA224
+#define WOLFSSL_SHA384
+#define WOLFSSL_SHA512
+#define WOLFSSL_SHA3
+#define HAVE_POLY1305
+#define HAVE_CHACHA
+#define HAVE_ENCRYPT_THEN_MAC
+#define NO_OLD_TLS

+ 0 - 0
zephyr/CMakeLists.txt → RTOS/zephyr/CMakeLists.txt


+ 0 - 0
zephyr/Kconfig → RTOS/zephyr/Kconfig


+ 0 - 0
zephyr/Kconfig.tls-generic → RTOS/zephyr/Kconfig.tls-generic


+ 0 - 0
zephyr/README.md → RTOS/zephyr/README.md


+ 45 - 0
RTOS/zephyr/include.am

@@ -0,0 +1,45 @@
+# vim:ft=automake
+# included from Top Level Makefile.am
+# All paths should be given relative to the root
+
+EXTRA_DIST+= RTOS/zephyr/CMakeLists.txt
+EXTRA_DIST+= RTOS/zephyr/Kconfig
+EXTRA_DIST+= RTOS/zephyr/Kconfig.tls-generic
+EXTRA_DIST+= RTOS/zephyr/zephyr_init.c
+EXTRA_DIST+= RTOS/zephyr/module.yml
+EXTRA_DIST+= RTOS/zephyr/wolfssl/options.h
+EXTRA_DIST+= RTOS/zephyr/nrf5340dk_nrf5340_user_settings.h
+EXTRA_DIST+= RTOS/zephyr/user_settings.h
+EXTRA_DIST+= RTOS/zephyr/user_settings-tls-generic.h
+EXTRA_DIST+= RTOS/zephyr/README.md
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_benchmark/
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_benchmark/CMakeLists.txt
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_benchmark/README
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_benchmark/install_test.sh
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_benchmark/prj.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_benchmark/sample.yaml
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_test/CMakeLists.txt
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_test/README
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_test/install_test.sh
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_test/prj.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_test/sample.yaml
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_sock/README
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_sock/install_sample.sh
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_sock/prj.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_sock/sample.yaml
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_sock/src
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_sock/src/tls_sock.c
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/README
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/install_sample.sh
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/prj.conf
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/sample.yaml
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/src
+EXTRA_DIST+= RTOS/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c

+ 0 - 0
zephyr/module.yml → RTOS/zephyr/module.yml


+ 0 - 0
zephyr/nrf5340dk_nrf5340_user_settings.h → RTOS/zephyr/nrf5340dk_nrf5340_user_settings.h


+ 0 - 0
zephyr/samples/wolfssl_benchmark/CMakeLists.txt → RTOS/zephyr/samples/wolfssl_benchmark/CMakeLists.txt


+ 0 - 0
zephyr/samples/wolfssl_benchmark/README → RTOS/zephyr/samples/wolfssl_benchmark/README


+ 0 - 0
zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp.conf → RTOS/zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp.conf


+ 0 - 0
zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp_ns.conf → RTOS/zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp_ns.conf


+ 0 - 0
zephyr/samples/wolfssl_benchmark/install_test.sh → RTOS/zephyr/samples/wolfssl_benchmark/install_test.sh


+ 0 - 0
zephyr/samples/wolfssl_benchmark/prj.conf → RTOS/zephyr/samples/wolfssl_benchmark/prj.conf


+ 0 - 0
zephyr/samples/wolfssl_benchmark/sample.yaml → RTOS/zephyr/samples/wolfssl_benchmark/sample.yaml


+ 0 - 0
zephyr/samples/wolfssl_test/CMakeLists.txt → RTOS/zephyr/samples/wolfssl_test/CMakeLists.txt


+ 0 - 0
zephyr/samples/wolfssl_test/README → RTOS/zephyr/samples/wolfssl_test/README


+ 0 - 0
zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp.conf → RTOS/zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp.conf


+ 0 - 0
zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp_ns.conf → RTOS/zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp_ns.conf


+ 0 - 0
zephyr/samples/wolfssl_test/install_test.sh → RTOS/zephyr/samples/wolfssl_test/install_test.sh


+ 0 - 0
zephyr/samples/wolfssl_test/prj.conf → RTOS/zephyr/samples/wolfssl_test/prj.conf


+ 0 - 0
zephyr/samples/wolfssl_test/sample.yaml → RTOS/zephyr/samples/wolfssl_test/sample.yaml


+ 0 - 0
zephyr/samples/wolfssl_tls_sock/CMakeLists.txt → RTOS/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt


+ 0 - 0
zephyr/samples/wolfssl_tls_sock/README → RTOS/zephyr/samples/wolfssl_tls_sock/README


+ 0 - 0
zephyr/samples/wolfssl_tls_sock/install_sample.sh → RTOS/zephyr/samples/wolfssl_tls_sock/install_sample.sh


+ 0 - 0
zephyr/samples/wolfssl_tls_sock/prj.conf → RTOS/zephyr/samples/wolfssl_tls_sock/prj.conf


+ 0 - 0
zephyr/samples/wolfssl_tls_sock/sample.yaml → RTOS/zephyr/samples/wolfssl_tls_sock/sample.yaml


+ 0 - 0
zephyr/samples/wolfssl_tls_sock/src/tls_sock.c → RTOS/zephyr/samples/wolfssl_tls_sock/src/tls_sock.c


+ 0 - 0
zephyr/samples/wolfssl_tls_thread/CMakeLists.txt → RTOS/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt


+ 0 - 0
zephyr/samples/wolfssl_tls_thread/README → RTOS/zephyr/samples/wolfssl_tls_thread/README


+ 0 - 0
zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp.conf → RTOS/zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp.conf


+ 0 - 0
zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp_ns.conf → RTOS/zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp_ns.conf


+ 0 - 0
zephyr/samples/wolfssl_tls_thread/install_sample.sh → RTOS/zephyr/samples/wolfssl_tls_thread/install_sample.sh


+ 0 - 0
zephyr/samples/wolfssl_tls_thread/prj.conf → RTOS/zephyr/samples/wolfssl_tls_thread/prj.conf


+ 0 - 0
zephyr/samples/wolfssl_tls_thread/sample.yaml → RTOS/zephyr/samples/wolfssl_tls_thread/sample.yaml


+ 0 - 0
zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c → RTOS/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c


+ 0 - 0
zephyr/user_settings-tls-generic.h → RTOS/zephyr/user_settings-tls-generic.h


+ 0 - 0
zephyr/user_settings.h → RTOS/zephyr/user_settings.h


+ 0 - 0
zephyr/wolfssl/options.h → RTOS/zephyr/wolfssl/options.h


+ 0 - 0
zephyr/zephyr_init.c → RTOS/zephyr/zephyr_init.c


+ 2 - 2
src/tls13.c

@@ -103,9 +103,9 @@
     #include <errno.h>
 #endif
 
-#if defined(__MACH__) || defined(__FreeBSD__)
+#if defined(__MACH__) || defined(__FreeBSD__) || defined(__INCLUDE_NUTTX_CONFIG_H)
 #include <sys/time.h>
-#endif /* __MACH__ || __FreeBSD__ */
+#endif /* __MACH__ || __FreeBSD__ || __INCLUDE_NUTTX_CONFIG_H */
 
 
 #include <wolfssl/internal.h>

+ 13 - 2
wolfcrypt/test/test.c

@@ -577,7 +577,11 @@ WOLFSSL_TEST_SUBROUTINE int logging_test(void);
 #if !defined(NO_ASN) && !defined(NO_ASN_TIME)
 WOLFSSL_TEST_SUBROUTINE int time_test(void);
 #endif
+#if defined(__INCLUDE_NUTTX_CONFIG_H)
+WOLFSSL_TEST_SUBROUTINE int wolfcrypt_mutex_test(void);
+#else
 WOLFSSL_TEST_SUBROUTINE int mutex_test(void);
+#endif
 #if defined(USE_WOLFSSL_MEMORY) && !defined(FREERTOS)
 WOLFSSL_TEST_SUBROUTINE int memcb_test(void);
 #endif
@@ -1474,7 +1478,11 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
         TEST_PASS("time test passed!\n");
 #endif
 
-    if ( (ret = mutex_test()) != 0)
+#if defined(__INCLUDE_NUTTX_CONFIG_H)
+    if ((ret = wolfcrypt_mutex_test()) != 0)
+#else
+    if ((ret = mutex_test()) != 0)
+#endif
         return err_sys("mutex    test failed!\n", ret);
     else
         TEST_PASS("mutex    test passed!\n");
@@ -42834,8 +42842,11 @@ WOLFSSL_TEST_SUBROUTINE int logging_test(void)
     return 0;
 }
 
-
+#if defined(__INCLUDE_NUTTX_CONFIG_H)
+WOLFSSL_TEST_SUBROUTINE int wolfcrypt_mutex_test(void)
+#else
 WOLFSSL_TEST_SUBROUTINE int mutex_test(void)
+#endif
 {
 #ifdef WOLFSSL_PTHREADS
     wolfSSL_Mutex m;

+ 0 - 45
zephyr/include.am

@@ -1,45 +0,0 @@
-# vim:ft=automake
-# included from Top Level Makefile.am
-# All paths should be given relative to the root
-
-EXTRA_DIST+= zephyr/CMakeLists.txt
-EXTRA_DIST+= zephyr/Kconfig
-EXTRA_DIST+= zephyr/Kconfig.tls-generic
-EXTRA_DIST+= zephyr/zephyr_init.c
-EXTRA_DIST+= zephyr/module.yml
-EXTRA_DIST+= zephyr/wolfssl/options.h
-EXTRA_DIST+= zephyr/nrf5340dk_nrf5340_user_settings.h
-EXTRA_DIST+= zephyr/user_settings.h
-EXTRA_DIST+= zephyr/user_settings-tls-generic.h
-EXTRA_DIST+= zephyr/README.md
-EXTRA_DIST+= zephyr/samples/wolfssl_benchmark/
-EXTRA_DIST+= zephyr/samples/wolfssl_benchmark/CMakeLists.txt
-EXTRA_DIST+= zephyr/samples/wolfssl_benchmark/README
-EXTRA_DIST+= zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_benchmark/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_benchmark/install_test.sh
-EXTRA_DIST+= zephyr/samples/wolfssl_benchmark/prj.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_benchmark/sample.yaml
-EXTRA_DIST+= zephyr/samples/wolfssl_test/CMakeLists.txt
-EXTRA_DIST+= zephyr/samples/wolfssl_test/README
-EXTRA_DIST+= zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_test/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_test/install_test.sh
-EXTRA_DIST+= zephyr/samples/wolfssl_test/prj.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_test/sample.yaml
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_sock/CMakeLists.txt
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_sock/README
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_sock/install_sample.sh
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_sock/prj.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_sock/sample.yaml
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_sock/src
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_sock/src/tls_sock.c
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/CMakeLists.txt
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/README
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/boards/nrf5340dk_nrf5340_cpuapp_ns.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/install_sample.sh
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/prj.conf
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/sample.yaml
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/src
-EXTRA_DIST+= zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c