Merge pull request #4264 from maximevince/zephyr-module-support

wolfSSL as a Zephyr module (without setup.sh)
pull/4267/head
David Garske 2021-08-04 12:26:14 -07:00 committed by GitHub
commit ed8edde9c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 238 additions and 345 deletions

View File

@ -38,7 +38,6 @@ include IDE/XilinxSDK/include.am
include IDE/VisualDSP/include.am
include IDE/QNX/include.am
include IDE/WINCE/include.am
include IDE/zephyr/include.am
EXTRA_DIST+= IDE/IAR-EWARM IDE/MDK-ARM IDE/MDK5-ARM IDE/MYSQL IDE/LPCXPRESSO IDE/HEXIWEAR IDE/Espressif
EXTRA_DIST+= IDE/OPENSTM32/README.md

View File

@ -1,41 +0,0 @@
Zephyr Project Port
===================
## Overview
This port is for Zephyr Project available [here](https://www.zephyrproject.org/).
It provides the following zephyr code.
- modules/crypto/wolfssl
- wolfssl library code
- zephyr/modules/crypto/wolfssl
- Configuration and make files for wolfSSL
- zephyr/samples/modules/wolfssl_test
- wolfcrypt unit test application
- zephyr/samples/modules/wolfssl_tls_sock
- socket based sample of TLS
- zephyr/samples/modules/wolfssl_tls_thread
- socket based sample of TLS using threads
## How to setup
### deploy wolfssl source to zephyr project
Specify the path of the zephyr project and execute `wolfssl/IDE/zephyr/setup.sh`.
```bash
./IDE/zephyr/setup.sh /path/to/zephyrproject
```
This script will deploy wolfssl's library code, configuration and samples as described in the Overview to the zephyr project.
## build & test
build and execute wolfssl_test
```
cd [zephyrproject]
west build -p auto -b qemu_x86 zephyr/samples/modules/wolfssl_test
west build -t run
```

View File

@ -1,33 +0,0 @@
# vim:ft=automake
# included from Top Level Makefile.am
# All paths should be given relative to the root
EXTRA_DIST+= IDE/zephyr/lib/settings/user_settings-tls-generic.h
EXTRA_DIST+= IDE/zephyr/lib/zephyr/module.yml
EXTRA_DIST+= IDE/zephyr/lib/install_lib.sh
EXTRA_DIST+= IDE/zephyr/lib/README
EXTRA_DIST+= IDE/zephyr/lib/user_settings.h
EXTRA_DIST+= IDE/zephyr/module/CMakeLists.txt
EXTRA_DIST+= IDE/zephyr/module/install_module.sh
EXTRA_DIST+= IDE/zephyr/module/Kconfig
EXTRA_DIST+= IDE/zephyr/module/Kconfig.tls-generic
EXTRA_DIST+= IDE/zephyr/module/zephyr_init.c
EXTRA_DIST+= IDE/zephyr/wolfssl_test/CMakeLists.txt
EXTRA_DIST+= IDE/zephyr/wolfssl_test/install_test.sh
EXTRA_DIST+= IDE/zephyr/wolfssl_test/prj.conf
EXTRA_DIST+= IDE/zephyr/wolfssl_test/README
EXTRA_DIST+= IDE/zephyr/wolfssl_test/sample.yaml
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_sock/src/tls_sock.c
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_sock/CMakeLists.txt
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_sock/install_sample.sh
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_sock/prj.conf
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_sock/README
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_sock/sample.yaml
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_thread/src/tls_threaded.c
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_thread/CMakeLists.txt
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_thread/install_sample.sh
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_thread/prj.conf
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_thread/README
EXTRA_DIST+= IDE/zephyr/wolfssl_tls_thread/sample.yaml
EXTRA_DIST+= IDE/zephyr/README.md
EXTRA_DIST+= IDE/zephyr/setup.sh

View File

@ -1,67 +0,0 @@
#!/bin/sh
WOLFSSL_SRC_DIR=../../..
if [ ! -d $WOLFSSL_SRC_DIR ]; then
echo "Directory does not exist: $WOLFSSL_SRC_DIR"
exit 1
fi
if [ ! -f $WOLFSSL_SRC_DIR/wolfssl/ssl.h ]; then
echo "Missing header file: $WOLFSSL_SRC_DIR/wolfssl/ssl.h"
exit 1
fi
ZEPHYR_DIR=
if [ $# -ne 1 ]; then
echo "Need location of zephyr project as a command line argument"
exit 1
else
ZEPHYR_DIR=$1
fi
if [ ! -d $ZEPHR_DIR ]; then
echo "Zephyr project directory does not exist: $ZEPHYR_DIR"
exit 1
fi
ZEPHYR_CRYPTO_DIR=$ZEPHYR_DIR/modules/crypto
if [ ! -d $ZEPHYR_CRYPTO_DIR ]; then
echo "Zephyr crypto directory does not exist: $ZEPHYR_CRYPTO_DIR"
exit 1
fi
ZEPHYR_WOLFSSL_DIR=$ZEPHYR_CRYPTO_DIR/wolfssl
ZEPHYR_WOLFSSL_LIB_DIR=$ZEPHYR_CRYPTO_DIR/wolfssl/wolfssl
echo "wolfSSL directory in Zephyr:"
echo " $ZEPHYR_WOLFSSL_DIR"
rm -rf $ZEPHYR_WOLFSSL_DIR
mkdir $ZEPHYR_WOLFSSL_DIR
mkdir $ZEPHYR_WOLFSSL_LIB_DIR
echo "Copy in Build files ..."
cp -r * $ZEPHYR_WOLFSSL_LIB_DIR/
rm $ZEPHYR_WOLFSSL_LIB_DIR/$0
mv $ZEPHYR_WOLFSSL_LIB_DIR/zephyr $ZEPHYR_WOLFSSL_DIR/zephyr
echo "Copy Source Code ..."
rm -rf $ZEPHYR_WOLFSSL_LIB_DIR/library
mkdir $ZEPHYR_WOLFSSL_LIB_DIR/library
mkdir $ZEPHYR_WOLFSSL_LIB_DIR/library/src
mkdir -p $ZEPHYR_WOLFSSL_LIB_DIR/library/wolfcrypt/src
cp -rf ${WOLFSSL_SRC_DIR}/src/*.c $ZEPHYR_WOLFSSL_LIB_DIR/library/src/
cp -rf ${WOLFSSL_SRC_DIR}/wolfcrypt/src/*.c $ZEPHYR_WOLFSSL_LIB_DIR/library/wolfcrypt/src/
cp -rf ${WOLFSSL_SRC_DIR}/wolfcrypt/src/*.i $ZEPHYR_WOLFSSL_LIB_DIR/library/wolfcrypt/src/
cp -rf ${WOLFSSL_SRC_DIR}/wolfcrypt/src/*.S $ZEPHYR_WOLFSSL_LIB_DIR/library/wolfcrypt/src/
echo "Copy Header Files ..."
rm -rf $ZEPHYR_WOLFSSL_LIB_DIR/include
mkdir $ZEPHYR_WOLFSSL_LIB_DIR/include
cp $ZEPHYR_WOLFSSL_LIB_DIR/user_settings.h $ZEPHYR_WOLFSSL_LIB_DIR/include/
cp -rf ${WOLFSSL_SRC_DIR}/wolfssl $ZEPHYR_WOLFSSL_LIB_DIR/include/
rm -f $ZEPHYR_WOLFSSL_LIB_DIR/include/wolfssl/options.h
touch $ZEPHYR_WOLFSSL_LIB_DIR/include/wolfssl/options.h
rm -rf $ZEPHYR_WOLFSSL_LIB_DIR/include/wolfssl/wolfcrypt/port
echo "Done"

View File

@ -1,3 +0,0 @@
build:
cmake-ext: True
kconfig-ext: True

View File

@ -1,122 +0,0 @@
zephyr_interface_library_named(wolfSSL)
if(CONFIG_WOLFSSL_BUILTIN)
target_compile_definitions(wolfSSL INTERFACE
WOLFSSL_OPTIONS_FILE="${CONFIG_WOLFSSL_OPTIONS_FILE}"
)
target_include_directories(wolfSSL INTERFACE
${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/include
${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/settings
)
zephyr_library()
zephyr_library_sources(zephyr_init.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/crl.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/internal.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/keys.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/ocsp.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/sniffer.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/ssl.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/tls13.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/tls.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/src/wolfio.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/aes.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/arc4.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/asm.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/asn.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/async.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/blake2b.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/camellia.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/chacha20_poly1305.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/chacha.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/cmac.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/coding.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/compress.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/cpuid.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/cryptocb.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/curve25519.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/des3.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/dh.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/dsa.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/ecc.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/ecc_fp.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/ed25519.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/error.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/fe_low_mem.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/fe_operations.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/fips.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/fips_test.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/ge_low_mem.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/ge_operations.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/hash.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/hc128.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/hmac.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/idea.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/integer.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/logging.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/md2.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/md4.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/md5.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/memory.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/misc.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/pkcs12.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/pkcs7.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/poly1305.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/pwdbased.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/rabbit.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/random.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/ripemd.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/rsa.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/selftest.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sha256.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sha3.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sha512.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sha.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/signature.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sp_arm32.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sp_arm64.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sp_armthumb.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sp_c32.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sp_c64.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sp_cortexm.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sp_int.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/sp_x86_64.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/srp.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/tfm.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/wc_encrypt.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/wc_pkcs11.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/wc_port.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/wolfcrypt_first.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/wolfcrypt_last.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/wolfevent.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library/wolfcrypt/src/wolfmath.c)
zephyr_library_link_libraries(wolfSSL)
add_definitions(-DWOLFSSL_USER_SETTINGS)
add_definitions(-DWOLFSSL_ZEPHYR)
include_directories("${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl/library")
else()
assert(CONFIG_WOLFSSL_LIBRARY "wolfSSL was enabled, but neither BUILTIN or LIBRARY was selected.")
# NB: CONFIG_WOLFSSL_LIBRARY is not regression tested and is
# therefore susceptible to bit rot
target_include_directories(wolfSSL INTERFACE
${CONFIG_WOLFSSL_INSTALL_PATH}
)
zephyr_link_libraries(
wolfssl_external
-L${CONFIG_WOLFSSL_INSTALL_PATH}
gcc
)
# Lib wolfssl depends on libgcc so to allow
# wolfssl to link with gcc we need to ensure it is placed
# after wolfssl_external on the linkers command line.
endif()
target_link_libraries(wolfSSL INTERFACE zephyr_interface)

View File

@ -1,42 +0,0 @@
#!/bin/sh
WOLFSSL_SRC_DIR=../../..
if [ ! -d $WOLFSSL_SRC_DIR ]; then
echo "Directory does not exist: $WOLFSSL_SRC_DIR"
exit 1
fi
if [ ! -f $WOLFSSL_SRC_DIR/wolfssl/ssl.h ]; then
echo "Missing header file: $WOLFSSL_SRC_DIR/wolfssl/ssl.h"
exit 1
fi
ZEPHYR_DIR=
if [ $# -ne 1 ]; then
echo "Need location of zephyr project as a command line argument"
exit 1
else
ZEPHYR_DIR=$1
fi
if [ ! -d $ZEPHR_DIR ]; then
echo "Zephyr project directory does not exist: $ZEPHYR_DIR"
exit 1
fi
ZEPHYR_MODULES_DIR=$ZEPHYR_DIR/zephyr/modules
if [ ! -d $ZEPHYR_MODULES_DIR ]; then
echo "Zephyr modules directory does not exist: $ZEPHYR_MODULES_DIR"
exit 1
fi
ZEPHYR_WOLFSSL_DIR=$ZEPHYR_MODULES_DIR/wolfssl
echo "wolfSSL directory in Zephyr:"
echo " $ZEPHYR_WOLFSSL_DIR"
rm -rf $ZEPHYR_WOLFSSL_DIR
mkdir $ZEPHYR_WOLFSSL_DIR
echo "Copy in Build files ..."
cp -r * $ZEPHYR_WOLFSSL_DIR/
rm $ZEPHYR_WOLFSSL_DIR/$0
echo "Done"

View File

@ -1,23 +0,0 @@
#!/bin/sh
# Check for zephyr directory on command line
if [ $# -ne 1 ]; then
echo "Usage: $0 'zephyr project root directory path'" 1>&2
exit 1
fi
ZEPHYR_DIR=$1
# Check zephyr directory exists
if [ ! -d $ZEPHR_DIR ]; then
echo "Zephyr project directory does not exist: $ZEPHYR_DIR"
exit 1
fi
cd `dirname $0`
(cd lib; ./install_lib.sh $ZEPHYR_DIR)
(cd module; ./install_module.sh $ZEPHYR_DIR)
(cd wolfssl_test; ./install_test.sh $ZEPHYR_DIR)
(cd wolfssl_tls_sock; ./install_sample.sh $ZEPHYR_DIR)
(cd wolfssl_tls_thread; ./install_sample.sh $ZEPHYR_DIR)

View File

@ -1,12 +0,0 @@
wolfSSL (formerly known as CyaSSL) and wolfCrypt are either licensed for use
under the GPLv2 or a standard commercial license. For our users who cannot use
wolfSSL under GPLv2, a commercial license to wolfSSL and wolfCrypt is available.
Please contact wolfSSL Inc. directly at:
Email: licensing@wolfssl.com
Phone: +1 425 245-8247
More information can be found on the wolfSSL website at www.wolfssl.com.

View File

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

View File

@ -0,0 +1,126 @@
if(CONFIG_WOLFSSL)
zephyr_interface_library_named(wolfSSL)
if(CONFIG_WOLFSSL_BUILTIN)
target_compile_definitions(wolfSSL INTERFACE
WOLFSSL_OPTIONS_FILE="${CONFIG_WOLFSSL_OPTIONS_FILE}"
)
target_include_directories(wolfSSL INTERFACE
${ZEPHYR_CURRENT_MODULE_DIR}
${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl
${ZEPHYR_CURRENT_MODULE_DIR}/zephyr
)
zephyr_library()
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/zephyr/zephyr_init.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/crl.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/internal.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/keys.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/ocsp.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/sniffer.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/ssl.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/tls13.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/tls.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/wolfio.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/aes.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/arc4.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/asm.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/asn.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/async.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/blake2b.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/camellia.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/chacha20_poly1305.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/chacha.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/cmac.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/coding.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/compress.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/cpuid.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/cryptocb.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/curve25519.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/des3.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/dh.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/dsa.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/ecc.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/ecc_fp.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/ed25519.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/error.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/fe_low_mem.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/fe_operations.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/fips.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/fips_test.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/ge_low_mem.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/ge_operations.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/hash.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/hc128.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/hmac.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/idea.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/integer.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/logging.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/md2.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/md4.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/md5.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/memory.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/misc.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/pkcs12.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/pkcs7.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/poly1305.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/pwdbased.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/rabbit.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/random.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/ripemd.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/rsa.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/selftest.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sha256.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sha3.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sha512.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sha.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/signature.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sp_arm32.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sp_arm64.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sp_armthumb.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sp_c32.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sp_c64.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sp_cortexm.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sp_int.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sp_x86_64.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/srp.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/tfm.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_encrypt.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_pkcs11.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_port.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wolfcrypt_first.c)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wolfcrypt_last.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wolfevent.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wolfmath.c)
zephyr_library_link_libraries(wolfSSL)
add_definitions(-DWOLFSSL_USER_SETTINGS)
add_definitions(-DWOLFSSL_ZEPHYR)
include_directories("${ZEPHYR_CURRENT_MODULE_DIR}/wolfssl")
else()
assert(CONFIG_WOLFSSL_LIBRARY "wolfSSL was enabled, but neither BUILTIN or LIBRARY was selected.")
# NB: CONFIG_WOLFSSL_LIBRARY is not regression tested and is
# therefore susceptible to bit rot
target_include_directories(wolfSSL INTERFACE
${CONFIG_WOLFSSL_INSTALL_PATH}
)
zephyr_link_libraries(
wolfssl_external
-L${CONFIG_WOLFSSL_INSTALL_PATH}
gcc
)
# Lib wolfssl depends on libgcc so to allow
# wolfssl to link with gcc we need to ensure it is placed
# after wolfssl_external on the linkers command line.
endif()
target_link_libraries(wolfSSL INTERFACE zephyr_interface)
endif()

74
zephyr/README.md 100644
View File

@ -0,0 +1,74 @@
Zephyr Project Port
===================
## Overview
This port is for the Zephyr RTOS Project, available [here](https://www.zephyrproject.org/).
It provides the following zephyr code.
- modules/crypto/wolfssl
- wolfssl library code
- modules/crypto/wolfssl/zephyr/
- Configuration and CMake files for wolfSSL as a Zephyr module
- modules/crypto/wolfssl/zephyr/samples/wolfssl_test
- wolfcrypt unit test application
- modules/crypto/wolfssl/zephyr/samples/wolfssl_tls_sock
- socket based sample of TLS
- modules/crypto/wolfssl/zephyr/samples/wolfssl_tls_thread
- socket based sample of TLS using threads
## How to setup as a Zephyr Module
### Modify your project's west manifest
Add wolfssl as a project:
```
manifest:
remotes:
# <your other remotes>
- name: wolfssl
url-base: https://github.com/wolfssl
projects:
# <your other projects>
- name: wolfssl
path: modules/crypto/wolfssl
revision: master
remote: wolfssl
```
Update west's modules:
```bash
west update
```
Now west recognizes 'wolfssl' as a module, and will include it's Kconfig and CMakeFiles.txt in the build system.
## Build & test
build and execute wolfssl_test
```
cd [zephyrproject]
west build -p auto -b qemu_x86 modules/crypto/wolfssl/zephyr/samples/wolfssl_test
west build -t run
```
### Run wolfSSL example wolfssl_tls_sock
```
cd [zephyrproject]
west build -p auto -b qemu_x86 modules/crypto/wolfssl/zephyr/samples/wolfssl_tls_sock
west build -t run
```
### Run wolfSSL example wolfssl_tls_thread
```
cd [zephyrproject]
west build -p auto -b qemu_x86 modules/crypto/wolfssl/zephyr/samples/wolfssl_tls_thread
west build -t run
```

32
zephyr/include.am 100644
View File

@ -0,0 +1,32 @@
# 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/user_settings.h
EXTRA_DIST+= zephyr/user_settings-tls-generic.h
EXTRA_DIST+= zephyr/README.md
EXTRA_DIST+= zephyr/samples/wolfssl_test/CMakeLists.txt
EXTRA_DIST+= zephyr/samples/wolfssl_test/README
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/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

View File

@ -0,0 +1,3 @@
build:
cmake: zephyr
kconfig: zephyr/Kconfig

View File

@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.13.1)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(wolfssl_test)
FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${ZEPHYR_WOLFSSL_MODULE_DIR}/wolfcrypt/test/test.c)
target_include_directories(app PRIVATE ${ZEPHYR_WOLFSSL_MODULE_DIR}/wolfcrypt/test)
target_sources(app PRIVATE ${app_sources})
add_definitions(-DWOLFSSL_USER_SETTINGS)

View File