wolfSSL as a Zephyr module

pull/4264/head
Maxime Vincent 2021-07-29 11:11:20 +02:00
parent 0ec848e2bd
commit 9d562a59bc
34 changed files with 265 additions and 311 deletions

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

@ -0,0 +1,123 @@
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)

136
zephyr/README.md 100644
View File

@ -0,0 +1,136 @@
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 - automated
### 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
```
## How to setup - step by step
export ZEPHYR_DIR=<Zephyr project directory>
export WOLFSSL_DIR=<wolfSSL directory>
### Install wolfSSL library code
```
(cd lib; ./install_lib.sh $ZEPHYR_DIR)
```
or
```
mkdir -p $ZEPHYR_DIR/modules/crypto/wolfssl/wolfssl/library/src
mkdir -p $ZEPHYR_DIR/modules/crypto/wolfssl/wolfssl/library/wolfcrypt/src
mkdir -p $ZEPHYR_DIR/modules/crypto/wolfssl/wolfssl/include
cp -r lib/* $ZEPHYR_DIR/modules/crypto/wolfssl
mv $ZEPHYR_DIR/modules/crypto/wolfssl/wolfssl/zephyr $ZEPHYR_DIR/modules/crypto/wolfssl/zephyr
cp -rf $WOLFSSL_DIR/src/*.c $ZEPHYR_DIR/modules/crypto/wolfssl/wolfssl/library/src/
cp -rf $WOLFSSL_DIR/wolfcrypt/src/*.c $ZEPHYR_DIR/modules/crypto/wolfssl/wolfssl/library/wolfcrypt/src/
cp -rf $WOLFSSL_DIR/wolfcrypt/src/*.i $ZEPHYR_DIR/modules/crypto/wolfssl/wolfssl/library/wolfcrypt/src/
cp -rf $WOLFSSL_DIR/wolfcrypt/src/*.S $ZEPHYR_DIR/modules/crypto/wolfssl/wolfssl/library/wolfcrypt/src/
cp lib/user_settings.h $ZEPHYR_DIR/modules/crypto/wolfssl/include
cp -rf $WOLFSSL_DIR/wolfssl $ZEPHYR_DIR/modules/crypto/wolfssl/include
rm -f $ZEPHYR_DIR/modules/crypto/wolfssl/include/wolfssl/options.h
touch $ZEPHYR_DIR/modules/crypto/wolfssl/include/wolfssl/options.h
rm -rf $ZEPHYR_DIR/modules/crypto/wolfssl/include/wolfssl/wolfcrypt/port
```
### Install wolfSSL mdule (build system hooks)
```
(cd module; ./install_module.sh $ZEPHYR_DIR)
```
or
```
mkdir $ZEPHYR_DIR/zephyr/modules/crypto/wolfssl;
cp module/* $ZEPHYR_DIR/zephyr/modules/crypto/wolfssl/
```
### Add wolfSSL to west
Add the following lines in 'projects' to: $ZEPHYR_DIR/zephyr/west.yml
```
- name: wolfssl
path: modules/crypto/wolfssl
```
### Install wolfSSL example wolfssl_test
```
(cd wolfssl_test; ./install_test.sh $ZEPHYR_DIR)
```
or
```
cp wolfssl_test $ZEPHYR_DIR/zephyr/samples/modules
mkdir $ZEPHYR_DIR/zephyr/samples/modules/src
cp $WOLFSSL_DIR/wolfcrypt/test/test.c $ZEPHYR_DIR/zephyr/samples/modules/src
cp $WOLFSSL_DIR/wolfcrypt/test/test.h $ZEPHYR_DIR/zephyr/samples/modules/src
```
### Install wolfSSL example wolfssl_tls_sock
```
(cd wolfssl_tls_sock; ./install_sample.sh $ZEPHYR_DIR)
```
or
```
cp wolfssl_tls_sock $ZEPHYR_DIR/zephyr/samples/modules
```
### Install wolfSSL example wolfssl_tls_thread
```
(cd wolfssl_tls_thread; ./install_sample.sh $ZEPHYR_DIR)
```
or
```
cp wolfssl_tls_thread $ZEPHYR_DIR/zephyr/samples/modules
```

View File

@ -31,3 +31,4 @@ 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
EXTRA_DIST+= IDE/zephyr/wolfssl_zephyr.diff

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