Zephyr Project: update port to work with latest

pull/4174/head
Sean Parkinson 2021-06-30 10:29:54 +10:00
parent 80480e5d1f
commit d1fb736136
24 changed files with 265 additions and 234 deletions

View File

@ -7,13 +7,15 @@ This port is for Zephyr Project available [here](https://www.zephyrproject.org/)
It provides the following zephyr code.
- zephyr/ext/lib/crypto/wolfssl
- wolfssl library
- zephyr/samples/crypto/wolfssl_test
- 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/crypto/wolfssl_tls_sock
- zephyr/samples/modules/wolfssl_tls_sock
- socket based sample of TLS
- zephyr/samples/crypto/wolfssl_tls_thread
- zephyr/samples/modules/wolfssl_tls_thread
- socket based sample of TLS using threads
## How to setup
@ -25,17 +27,15 @@ Specify the path of the zephyr project and execute `wolfssl/IDE/zephyr/setup.sh
./IDE/zephyr/setup.sh /path/to/zephyrproject
```
This script will deploy wolfssl's library code and samples as described in the Overview to the zephyr project.
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]/zephyr/samples/crypto/wolfssl_test
mkdir build && cd build
cmake -GNinja -DBOARD=qemu_x86 ..
ninja
ninja run
cd [zephyrproject]
west build -p auto -b qemu_x86 zephyr/samples/modules/wolfssl_test
west build -t run
```

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
include
settings
)
zephyr_library()
zephyr_library_sources(zephyr_init.c)
zephyr_library_sources(library/src/crl.c)
zephyr_library_sources(library/src/internal.c)
zephyr_library_sources(library/src/keys.c)
zephyr_library_sources(library/src/ocsp.c)
zephyr_library_sources(library/src/sniffer.c)
zephyr_library_sources(library/src/ssl.c)
zephyr_library_sources(library/src/tls13.c)
zephyr_library_sources(library/src/tls.c)
zephyr_library_sources(library/src/wolfio.c)
zephyr_library_sources(library/wolfcrypt/src/aes.c)
zephyr_library_sources(library/wolfcrypt/src/arc4.c)
zephyr_library_sources(library/wolfcrypt/src/asm.c)
zephyr_library_sources(library/wolfcrypt/src/asn.c)
zephyr_library_sources(library/wolfcrypt/src/async.c)
zephyr_library_sources(library/wolfcrypt/src/blake2b.c)
zephyr_library_sources(library/wolfcrypt/src/camellia.c)
zephyr_library_sources(library/wolfcrypt/src/chacha20_poly1305.c)
zephyr_library_sources(library/wolfcrypt/src/chacha.c)
zephyr_library_sources(library/wolfcrypt/src/cmac.c)
zephyr_library_sources(library/wolfcrypt/src/coding.c)
zephyr_library_sources(library/wolfcrypt/src/compress.c)
zephyr_library_sources(library/wolfcrypt/src/cpuid.c)
zephyr_library_sources(library/wolfcrypt/src/cryptocb.c)
zephyr_library_sources(library/wolfcrypt/src/curve25519.c)
zephyr_library_sources(library/wolfcrypt/src/des3.c)
zephyr_library_sources(library/wolfcrypt/src/dh.c)
zephyr_library_sources(library/wolfcrypt/src/dsa.c)
zephyr_library_sources(library/wolfcrypt/src/ecc.c)
zephyr_library_sources(library/wolfcrypt/src/ecc_fp.c)
zephyr_library_sources(library/wolfcrypt/src/ed25519.c)
zephyr_library_sources(library/wolfcrypt/src/error.c)
zephyr_library_sources(library/wolfcrypt/src/fe_low_mem.c)
zephyr_library_sources(library/wolfcrypt/src/fe_operations.c)
#zephyr_library_sources(library/wolfcrypt/src/fips.c)
#zephyr_library_sources(library/wolfcrypt/src/fips_test.c)
zephyr_library_sources(library/wolfcrypt/src/ge_low_mem.c)
zephyr_library_sources(library/wolfcrypt/src/ge_operations.c)
zephyr_library_sources(library/wolfcrypt/src/hash.c)
zephyr_library_sources(library/wolfcrypt/src/hc128.c)
zephyr_library_sources(library/wolfcrypt/src/hmac.c)
zephyr_library_sources(library/wolfcrypt/src/idea.c)
zephyr_library_sources(library/wolfcrypt/src/integer.c)
zephyr_library_sources(library/wolfcrypt/src/logging.c)
zephyr_library_sources(library/wolfcrypt/src/md2.c)
zephyr_library_sources(library/wolfcrypt/src/md4.c)
zephyr_library_sources(library/wolfcrypt/src/md5.c)
zephyr_library_sources(library/wolfcrypt/src/memory.c)
#zephyr_library_sources(library/wolfcrypt/src/misc.c)
zephyr_library_sources(library/wolfcrypt/src/pkcs12.c)
zephyr_library_sources(library/wolfcrypt/src/pkcs7.c)
zephyr_library_sources(library/wolfcrypt/src/poly1305.c)
zephyr_library_sources(library/wolfcrypt/src/pwdbased.c)
zephyr_library_sources(library/wolfcrypt/src/rabbit.c)
zephyr_library_sources(library/wolfcrypt/src/random.c)
zephyr_library_sources(library/wolfcrypt/src/ripemd.c)
zephyr_library_sources(library/wolfcrypt/src/rsa.c)
#zephyr_library_sources(library/wolfcrypt/src/selftest.c)
zephyr_library_sources(library/wolfcrypt/src/sha256.c)
zephyr_library_sources(library/wolfcrypt/src/sha3.c)
zephyr_library_sources(library/wolfcrypt/src/sha512.c)
zephyr_library_sources(library/wolfcrypt/src/sha.c)
zephyr_library_sources(library/wolfcrypt/src/signature.c)
zephyr_library_sources(library/wolfcrypt/src/sp_arm32.c)
zephyr_library_sources(library/wolfcrypt/src/sp_arm64.c)
zephyr_library_sources(library/wolfcrypt/src/sp_armthumb.c)
zephyr_library_sources(library/wolfcrypt/src/sp_c32.c)
zephyr_library_sources(library/wolfcrypt/src/sp_c64.c)
zephyr_library_sources(library/wolfcrypt/src/sp_cortexm.c)
zephyr_library_sources(library/wolfcrypt/src/sp_int.c)
zephyr_library_sources(library/wolfcrypt/src/sp_x86_64.c)
zephyr_library_sources(library/wolfcrypt/src/srp.c)
zephyr_library_sources(library/wolfcrypt/src/tfm.c)
zephyr_library_sources(library/wolfcrypt/src/wc_encrypt.c)
zephyr_library_sources(library/wolfcrypt/src/wc_pkcs11.c)
zephyr_library_sources(library/wolfcrypt/src/wc_port.c)
#zephyr_library_sources(library/wolfcrypt/src/wolfcrypt_first.c)
#zephyr_library_sources(library/wolfcrypt/src/wolfcrypt_last.c)
zephyr_library_sources(library/wolfcrypt/src/wolfevent.c)
zephyr_library_sources(library/wolfcrypt/src/wolfmath.c)
zephyr_library_link_libraries(wolfSSL)
add_definitions(-DWOLFSSL_USER_SETTINGS)
add_definitions(-DWOLFSSL_ZEPHYR)
include_directories("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(
mbedtls_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

@ -22,42 +22,45 @@ if [ ! -d $ZEPHR_DIR ]; then
echo "Zephyr project directory does not exist: $ZEPHYR_DIR"
exit 1
fi
ZEPHYR_CRYPTO_DIR=$ZEPHYR_DIR/zephyr/ext/lib/crypto
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_DIR/
rm $ZEPHYR_WOLFSSL_DIR/$0
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_DIR/library
mkdir $ZEPHYR_WOLFSSL_DIR/library
mkdir $ZEPHYR_WOLFSSL_DIR/library/src
mkdir -p $ZEPHYR_WOLFSSL_DIR/library/wolfcrypt/src
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_DIR/library/src/
cp -rf ${WOLFSSL_SRC_DIR}/wolfcrypt/src/*.c $ZEPHYR_WOLFSSL_DIR/library/wolfcrypt/src/
cp -rf ${WOLFSSL_SRC_DIR}/wolfcrypt/src/*.i $ZEPHYR_WOLFSSL_DIR/library/wolfcrypt/src/
cp -rf ${WOLFSSL_SRC_DIR}/wolfcrypt/src/*.S $ZEPHYR_WOLFSSL_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_DIR/include
mkdir $ZEPHYR_WOLFSSL_DIR/include
rm -rf $ZEPHYR_WOLFSSL_LIB_DIR/include
mkdir $ZEPHYR_WOLFSSL_LIB_DIR/include
cp $ZEPHYR_WOLFSSL_DIR/user_settings.h $ZEPHYR_WOLFSSL_DIR/include/
cp -rf ${WOLFSSL_SRC_DIR}/wolfssl $ZEPHYR_WOLFSSL_DIR/include/
rm -f $ZEPHYR_WOLFSSL_DIR/include/wolfssl/options.h
touch $ZEPHYR_WOLFSSL_DIR/include/wolfssl/options.h
rm -rf $ZEPHYR_WOLFSSL_DIR/include/wolfssl/wolfcrypt/port
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

@ -146,7 +146,7 @@ extern "C" {
#define WOLFSSL_HAVE_SP_ECC
#endif
#if 0
#if defined(CONFIG_WOLFSSL_DEBUG)
#undef DEBUG_WOLFSSL
#define DEBUG_WOLFSSL
#endif

View File

@ -131,7 +131,7 @@ extern "C" {
#define WOLFSSL_HAVE_SP_ECC
#endif
#if 0
#if defined(CONFIG_WOLFSSL_DEBUG)
#undef DEBUG_WOLFSSL
#define DEBUG_WOLFSSL
#endif

View File

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

View File

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

@ -16,15 +16,25 @@
# limitations under the License.
#
config ZEPHYR_WOLFSSL_MODULE
bool
config WOLFSSL_PROMPTLESS
bool
help
Symbol to disable the prompt for WOLFSSL selection.
This symbol may be used internally in a Kconfig tree to hide the
wolfSSL menu prompt and instead handle the selection of WOLFSSL from
dependent sub-configurations and thus preven stuck symbol behavior.
menuconfig WOLFSSL
bool "wolfSSL Support"
bool "wolfSSL Support" if !WOLFSSL_PROMPTLESS
help
This option enables the wolfSSL cryptography library.
if WOLFSSL
choice
choice WOLFSSL_IMPLEMENTATION
prompt "Select implementation"
default WOLFSSL_BUILTIN
@ -52,9 +62,7 @@ config WOLFSSL_SETTINGS_FILE
special TLS usage, use available Kconfig settings, or select an
alternative config.
if WOLFSSL_BUILTIN && WOLFSSL_SETTINGS_FILE = "user_settings-tls-generic.h"
source "ext/lib/crypto/wolfssl/Kconfig.tls-generic"
endif
rsource "Kconfig.tls-generic"
config WOLFSSL_DEBUG
bool "wolfSSL debug activation"
@ -75,7 +83,6 @@ config WOLFSSL_INSTALL_PATH
config APP_LINK_WITH_WOLFSSL
bool "Link 'app' with WOLFSSL"
default y
depends on WOLFSSL
help
Add WOLFSSL header files to the 'app' include path. It may be
disabled if the include paths for WOLFSSL are causing aliasing

View File

@ -0,0 +1,42 @@
#!/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

@ -9,7 +9,7 @@
#include "user_settings.h"
#include "wolfssl/ssl.h"
static int _wolfssl_init(struct device *device)
static int _wolfssl_init(const struct device *device)
{
ARG_UNUSED(device);

View File

@ -16,6 +16,7 @@ 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

@ -22,12 +22,12 @@ if [ ! -d $ZEPHR_DIR ]; then
echo "Zephyr project directory does not exist: $ZEPHYR_DIR"
exit 1
fi
ZEPHYR_CRYPTO_DIR=$ZEPHYR_DIR/zephyr/samples/crypto
if [ ! -d $ZEPHYR_CRYPTO_DIR ]; then
echo "Zephyr crypto directory does not exist: $ZEPHYR_CRYPTO_DIR"
ZEPHYR_SAMPLES_DIR=$ZEPHYR_DIR/zephyr/samples/modules
if [ ! -d $ZEPHYR_SAMPLES_DIR ]; then
echo "Zephyr samples/modules directory does not exist: $ZEPHYR_SAMPLES_DIR"
exit 1
fi
ZEPHYR_WOLFSSL_DIR=$ZEPHYR_CRYPTO_DIR/wolfssl_test
ZEPHYR_WOLFSSL_DIR=$ZEPHYR_SAMPLES_DIR/wolfssl_test
echo "wolfSSL directory:"
echo " $ZEPHYR_WOLFSSL_DIR"

View File

@ -1,25 +1,16 @@
# Kernel options
CONFIG_MAIN_STACK_SIZE=32768
CONFIG_ENTROPY_GENERATOR=y
CONFIG_POSIX_API=y
CONFIG_INIT_STACKS=y
#CONFIG_FLOAT=y
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=8192
# Networking
CONFIG_NETWORKING=y
CONFIG_NET_TEST=y
CONFIG_NET_LOOPBACK=y
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_SOCKETS=y
CONFIG_DNS_RESOLVER=y
# Logging
CONFIG_PRINTK=y
CONFIG_WOLFSSL_DEBUG=y
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=16384
# TLS configuration
CONFIG_WOLFSSL=y
CONFIG_WOLFSSL_BUILTIN=y
# Logging
CONFIG_PRINTK=y
CONFIG_WOLFSSL_DEBUG=y
# Entropy
CONFIG_ENTROPY_GENERATOR=y
CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR=y

View File

@ -1,9 +1,7 @@
common:
harness: crypto
tags: crypto
sample:
description: wolfSSL test application
name: wolfSSL Test
min_flash: 65
min_ram: 36
tags: crypto wolfssl userspace random
tests:
test:
crypto.wolfssl_test:
platform_whitelist: qemu_x86

View File

@ -11,12 +11,12 @@ if [ ! -d $ZEPHR_DIR ]; then
echo "Zephyr project directory does not exist: $ZEPHYR_DIR"
exit 1
fi
ZEPHYR_CRYPTO_DIR=$ZEPHYR_DIR/zephyr/samples/crypto
if [ ! -d $ZEPHYR_CRYPTO_DIR ]; then
echo "Zephyr crypto directory does not exist: $ZEPHYR_CRYPTO_DIR"
ZEPHYR_SAMPLES_DIR=$ZEPHYR_DIR/zephyr/samples/modules
if [ ! -d $ZEPHYR_SAMPLES_DIR ]; then
echo "Zephyr samples/module directory does not exist: $ZEPHYR_SAMPLES_DIR"
exit 1
fi
ZEPHYR_WOLFSSL_DIR=$ZEPHYR_CRYPTO_DIR/wolfssl_tls_sock
ZEPHYR_WOLFSSL_DIR=$ZEPHYR_SAMPLES_DIR/wolfssl_tls_sock
echo "wolfSSL directory:"
echo " $ZEPHYR_WOLFSSL_DIR"

View File

@ -1,7 +1,6 @@
# Kernel options
CONFIG_MAIN_STACK_SIZE=12288
CONFIG_MAIN_STACK_SIZE=16384
CONFIG_ENTROPY_GENERATOR=y
CONFIG_POSIX_API=y
CONFIG_INIT_STACKS=y
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=8192
@ -40,7 +39,7 @@ CONFIG_NET_PKT_TX_COUNT=10
# Logging
CONFIG_PRINTK=y
CONFIG_WOLFSSL_DEBUG=y
#CONFIG_WOLFSSL_DEBUG=y
# TLS configuration
CONFIG_WOLFSSL=y

View File

@ -98,9 +98,6 @@ static int wolfssl_client_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
}
if (ret == 0) {
/* make wolfSSL object nonblocking */
wolfSSL_set_using_nonblock(client_ssl, 1);
/* Return newly created wolfSSL context and object */
*ctx = client_ctx;
*ssl = client_ssl;
@ -174,9 +171,6 @@ static int wolfssl_server_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
}
if (ret == 0) {
/* make wolfSSL object nonblocking */
wolfSSL_set_using_nonblock(server_ssl, 1);
/* Return newly created wolfSSL context and object */
*ctx = server_ctx;
*ssl = server_ssl;
@ -358,7 +352,7 @@ void server_thread(void* arg1, void* arg2, void* arg3)
ret = wolfssl_server_accept_tcp(server_ssl, &sockfd, &clientfd);
while (ret == 0) {
k_sleep(100);
k_sleep(Z_TIMEOUT_TICKS(100));
ret = wolfssl_server_accept(server_ssl);
if (ret == 0 && wolfSSL_is_init_finished(server_ssl))
break;
@ -451,7 +445,7 @@ void client_thread()
ret = wolfssl_client_connect_tcp(client_ssl, &sockfd);
while (ret == 0) {
k_sleep(10);
k_sleep(Z_TIMEOUT_TICKS(10));
ret = wolfssl_client_connect(client_ssl);
if (ret == 0 && wolfSSL_is_init_finished(client_ssl))
break;
@ -465,7 +459,7 @@ void client_thread()
}
/* Receive HTTP response */
while (ret == 0) {
k_sleep(10);
k_sleep(Z_TIMEOUT_TICKS(10));
ret = wolfssl_recv(client_ssl);
}
if (ret == 1)
@ -484,15 +478,17 @@ void client_thread()
int main()
{
int ret = 0;
THREAD_TYPE serverThread;
wolfSSL_Init();
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
#endif
/* Start server */
start_thread(server_thread, NULL, &serverThread);
k_sleep(100);
k_sleep(Z_TIMEOUT_TICKS(100));
client_thread();
join_thread(serverThread);

View File

@ -11,12 +11,12 @@ if [ ! -d $ZEPHR_DIR ]; then
echo "Zephyr project directory does not exist: $ZEPHYR_DIR"
exit 1
fi
ZEPHYR_CRYPTO_DIR=$ZEPHYR_DIR/zephyr/samples/crypto
if [ ! -d $ZEPHYR_CRYPTO_DIR ]; then
echo "Zephyr crypto directory does not exist: $ZEPHYR_CRYPTO_DIR"
ZEPHYR_SAMPLES_DIR=$ZEPHYR_DIR/zephyr/samples/modules
if [ ! -d $ZEPHYR_SAMPLES_DIR ]; then
echo "Zephyr samples/modules directory does not exist: $ZEPHYR_SAMPLES_DIR"
exit 1
fi
ZEPHYR_WOLFSSL_DIR=$ZEPHYR_CRYPTO_DIR/wolfssl_tls_thread
ZEPHYR_WOLFSSL_DIR=$ZEPHYR_SAMPLES_DIR/wolfssl_tls_thread
echo "wolfSSL directory:"
echo " $ZEPHYR_WOLFSSL_DIR"

View File

@ -1,7 +1,6 @@
# Kernel options
CONFIG_MAIN_STACK_SIZE=12288
CONFIG_MAIN_STACK_SIZE=16384
CONFIG_ENTROPY_GENERATOR=y
CONFIG_POSIX_API=y
CONFIG_INIT_STACKS=y
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=8192
@ -16,7 +15,7 @@ CONFIG_DNS_RESOLVER=y
# Logging
CONFIG_PRINTK=y
CONFIG_WOLFSSL_DEBUG=y
#CONFIG_WOLFSSL_DEBUG=y
# TLS configuration
CONFIG_WOLFSSL=y

View File

@ -436,6 +436,9 @@ int main()
THREAD_TYPE serverThread;
wolfSSL_Init();
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
#endif
wc_InitMutex(&client_mutex);
wc_InitMutex(&server_mutex);
@ -462,7 +465,7 @@ int main()
ret = wolfssl_client_connect(client_ssl);
if (ret == 0 && wolfSSL_is_init_finished(client_ssl))
break;
k_sleep(10);
k_sleep(Z_TIMEOUT_TICKS(10));
}
if (ret == 0) {
@ -473,7 +476,7 @@ int main()
}
/* Receive HTTP response */
while (ret == 0) {
k_sleep(10);
k_sleep(Z_TIMEOUT_TICKS(10));
ret = wolfssl_recv(client_ssl);
}
if (ret == 1)

View File

@ -2530,7 +2530,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
#elif defined(WOLFSSL_ZEPHYR)
#include <entropy.h>
#include <random/rand32.h>
#ifndef _POSIX_C_SOURCE
#include <posix/time.h>
#else
@ -2539,19 +2539,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int ret = 0;
word32 rand;
while (sz > 0) {
word32 len = sizeof(rand);
if (sz < len)
len = sz;
rand = sys_rand32_get();
XMEMCPY(output, &rand, len);
output += len;
sz -= len;
}
return ret;
sys_rand_get(output, sz);
return 0;
}
#elif defined(WOLFSSL_TELIT_M2MB)

View File

@ -118,7 +118,6 @@
#include <net/socket.h>
#define SOCKET_T int
#define SOL_SOCKET 1
#define SO_REUSEADDR 201
#define WOLFSSL_USE_GETADDRINFO
static unsigned long inet_addr(const char *cp)

View File

@ -1625,12 +1625,11 @@ extern void uITRON4_free(void *p) ;
#ifdef WOLFSSL_ZEPHYR
#include <zephyr.h>
#include <misc/printk.h>
#include <misc/util.h>
#include <sys/printk.h>
#include <sys/util.h>
#include <stdlib.h>
#define WOLFSSL_DH_CONST
#define WOLFSSL_HAVE_MIN
#define WOLFSSL_HAVE_MAX
#define NO_WRITEV
@ -1642,8 +1641,10 @@ extern void uITRON4_free(void *p) ;
void *z_realloc(void *ptr, size_t size);
#define realloc z_realloc
#ifndef CONFIG_NET_SOCKETS_POSIX_NAMES
#define CONFIG_NET_SOCKETS_POSIX_NAMES
#endif
#endif
#ifdef WOLFSSL_IMX6
#ifndef SIZEOF_LONG_LONG