From e3997558a9c25707d75c3c3ebea1f7893e0d4e1e Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Tue, 19 Feb 2019 09:21:10 +1000 Subject: [PATCH] Fixes from review and added REAMEs and setup.sh Add README.md and setup.sh. Add READMEs with license information. --- IDE/zephyr/README.md | 41 ++++++++++++++++++++++++++++ IDE/zephyr/lib/README | 12 ++++++++ IDE/zephyr/setup.sh | 22 +++++++++++++++ IDE/zephyr/wolfssl_test/README | 12 ++++++++ IDE/zephyr/wolfssl_tls_sock/README | 12 ++++++++ IDE/zephyr/wolfssl_tls_thread/README | 12 ++++++++ src/wolfio.c | 6 ++-- wolfcrypt/src/wc_port.c | 2 +- wolfssl/wolfio.h | 4 ++- 9 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 IDE/zephyr/README.md create mode 100755 IDE/zephyr/setup.sh create mode 100644 IDE/zephyr/wolfssl_test/README create mode 100644 IDE/zephyr/wolfssl_tls_sock/README create mode 100644 IDE/zephyr/wolfssl_tls_thread/README diff --git a/IDE/zephyr/README.md b/IDE/zephyr/README.md new file mode 100644 index 000000000..a8b47b0e2 --- /dev/null +++ b/IDE/zephyr/README.md @@ -0,0 +1,41 @@ +Zephyr Project Port +=================== + +## Overview + +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 + - wolfcrypt unit test application +- zephyr/samples/crypto/wolfssl_tls_sock + - socket based sample of TLS +- zephyr/samples/crypto/wolfssl_tls_thread + - socket based sample of TLS using threads + +## How to setup + +### delopy wolfssl source to mynewt project +Specify the path of the mynewt project and execute `wolfssl/IDE/mynewt/setup.sh`. + +```bash +./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. + +## 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 +``` + diff --git a/IDE/zephyr/lib/README b/IDE/zephyr/lib/README index e69de29bb..906a6c9ba 100644 --- a/IDE/zephyr/lib/README +++ b/IDE/zephyr/lib/README @@ -0,0 +1,12 @@ + +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. + + diff --git a/IDE/zephyr/setup.sh b/IDE/zephyr/setup.sh new file mode 100755 index 000000000..2600ca722 --- /dev/null +++ b/IDE/zephyr/setup.sh @@ -0,0 +1,22 @@ +#!/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 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) + diff --git a/IDE/zephyr/wolfssl_test/README b/IDE/zephyr/wolfssl_test/README new file mode 100644 index 000000000..906a6c9ba --- /dev/null +++ b/IDE/zephyr/wolfssl_test/README @@ -0,0 +1,12 @@ + +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. + + diff --git a/IDE/zephyr/wolfssl_tls_sock/README b/IDE/zephyr/wolfssl_tls_sock/README new file mode 100644 index 000000000..906a6c9ba --- /dev/null +++ b/IDE/zephyr/wolfssl_tls_sock/README @@ -0,0 +1,12 @@ + +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. + + diff --git a/IDE/zephyr/wolfssl_tls_thread/README b/IDE/zephyr/wolfssl_tls_thread/README new file mode 100644 index 000000000..906a6c9ba --- /dev/null +++ b/IDE/zephyr/wolfssl_tls_thread/README @@ -0,0 +1,12 @@ + +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. + + diff --git a/src/wolfio.c b/src/wolfio.c index 36d8f4695..75c30312d 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -238,9 +238,9 @@ int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx) int sd = *(int*)ctx; int sent; -#ifdef MAX_SEND_SZ - if (sz > MAX_SEND_SZ) - sz = MAX_SEND_SZ; +#ifdef WOLFSSL_MAX_SEND_SZ + if (sz > WOLFSSL_MAX_SEND_SZ) + sz = WOLFSSL_MAX_SEND_SZ; #endif sent = wolfIO_Send(sd, buf, sz, ssl->wflags); diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 6c997a5f1..6192271ad 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -489,7 +489,7 @@ XFILE z_fs_open(const char* filename, const char* perm) { XFILE file; - file = XMALLOC(sizeof(file), NULL, DYNAMIC_TYPE_FILE); + file = XMALLOC(sizeof(*file), NULL, DYNAMIC_TYPE_FILE); if (file != NULL) { if (fs_open(file, filename) != 0) { XFREE(file); diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index f9a2368d8..83b27749a 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -260,7 +260,9 @@ #define SEND_FUNCTION NU_Send #define RECV_FUNCTION NU_Recv #elif defined(WOLFSSL_ZEPHYR) - #define MAX_SEND_SZ 256 + #ifndef WOLFSSL_MAX_SEND_SZ + #define WOLFSSL_MAX_SEND_SZ 256 + #endif #define SEND_FUNCTION send #define RECV_FUNCTION recv