From 0722fb56d8fac87e08813cf3e4d1e2de50a36186 Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Mon, 2 Aug 2021 20:27:41 -0600 Subject: [PATCH] Adding README.md to examples dir and links to wolfssl-examples github repo in client/server.c --- README | 2 + examples/README.md | 89 ++++++++++++++++++++++++++++++++++++++++ examples/client/client.c | 15 +++++-- examples/include.am | 1 + examples/server/server.c | 14 +++++-- 5 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 examples/README.md diff --git a/README b/README index dff502f54..85bc92f23 100644 --- a/README +++ b/README @@ -318,3 +318,5 @@ More info can be found on-line at https://wolfssl.com/wolfSSL/Docs.html [wolfSSL Vulnerabilities] (https://www.wolfssl.com/docs/security-vulnerabilities/) + +Additional wolfSSL Examples](https://github.com/wolfssl/wolfssl-examples) diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 000000000..f57be3053 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,89 @@ +# wolfSSL examples directory +## client and server + + These directories contain a client (client.c) and server (server.c) that utilize a variety of the wolfSSL library's capabilities. The manner in which both programs operate can depend on the configure or can be specified at run-time depending on the end goal. Both applications contain testing as well as benchmarking code. + +Compile +``` + ./configure + make + ``` +Usage + ``` + ./examples/server/server + + ./examples/client/client + + ``` + +Run ```./examples/server/server -h``` and ```./examples/client/client -h``` for usage details. + +For simpler wolfSSL TLS server/client examples, visit https://github.com/wolfSSL/wolfssl-examples/tree/master/tls + +## echoclient and echoserver + +These directories contain a client (echoclient.c) and server (echoserver.c) that establish a connection encrypted by wolfSSL. Like the names indicate, once the connection has been established any messages entered into echoclient are sent to and displayed on the echoserver and are then echoed back to echoclient. The nature of the encryption, as well as additional behavior of the two programs, depends on how wolfSSL was configured ( DTLS enabled/disabled, Filesystem enabled/disabled, etc ... ). + +Compile +``` +./configure +make +``` + +Usage +``` +./examples/echoserver/echoserver + +./examples/echoclient/echoclient + +``` + +## benchmark + +The benchmark directory offers an application that can help you grasp just how well wolfSSL's TLS functionality is performing on your local machine. + + +Compile +``` +./configure +make +``` + +Usage +``` +./examples/benchmark/tls_bench + +``` + +The tls_bench executable can also be compiled separately with ``` gcc -lwolfssl -lpthread -o tls_bench tls_bench.c ```. + +Run ```./examples/benchmark/tls_bench -?``` for usage details. + +## sctp +This directory contains servers and clients that demonstrate wolfSSL's DTLS-SCTP support. + +Compile +``` +./configure --enable-sctp +make +``` + +Usage +``` +./examples/sctp/sctp-server + +./examples/sctp/sctp-client +``` +and + +``` +./examples/sctp/sctp-server-dtls + +./examples/sctp/sctp-client-dtls +``` + +## configs + + This directory contains example wolfSSL configuration file templates for use when autoconf is not available, such as building with a custom IDE. + + See [examples/configs/README.md](examples/configs/README.md) for more details. diff --git a/examples/client/client.c b/examples/client/client.c index dca20247e..6cdd84a03 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +/* For simpler wolfSSL TLS client examples, visit + * https://github.com/wolfSSL/wolfssl-examples/tree/master/tls + */ + #ifdef HAVE_CONFIG_H #include #endif @@ -975,7 +979,7 @@ static int ClientRead(WOLFSSL* ssl, char* reply, int replyLen, int mustRead, /* 4. add the same message into Japanese section */ /* (will be translated later) */ /* 5. add printf() into suitable position of Usage() */ -static const char* client_usage_msg[][69] = { +static const char* client_usage_msg[][70] = { /* English */ { " NOTE: All files relative to wolfSSL home dir\n", /* 0 */ @@ -1167,8 +1171,10 @@ static const char* client_usage_msg[][69] = { " SSLv3(0) - TLS1.2(3)\n", #else "-7 Set minimum downgrade protocol version [0-4] " - " SSLv3(0) - TLS1.3(4)\n", /* 69 */ + " SSLv3(0) - TLS1.3(4)\n\n", /* 69 */ #endif + "For simpler wolfSSL TLS client examples, visit\n" + "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 70 */ NULL, }, #ifndef NO_MULTIBYTE_PRINT @@ -1365,8 +1371,10 @@ static const char* client_usage_msg[][69] = { " SSLv3(0) - TLS1.2(3)\n", #else "-7 最小ダウングレード可能なプロトコルバージョンを設定します [0-4] " - " SSLv3(0) - TLS1.3(4)\n", /* 69 */ + " SSLv3(0) - TLS1.3(4)\n\n", /* 69 */ #endif + "For simpler wolfSSL TLS client examples, visit\n" + "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 70 */ NULL, }, #endif @@ -1550,6 +1558,7 @@ static void Usage(void) printf("%s", msg[++msgid]); /* --wolfsentry-config */ #endif printf("%s", msg[++msgid]); /* -7 */ + printf("%s", msg[++msgid]); /* Examples repo link */ } THREAD_RETURN WOLFSSL_THREAD client_test(void* args) diff --git a/examples/include.am b/examples/include.am index 6ebc84aa1..afde43057 100644 --- a/examples/include.am +++ b/examples/include.am @@ -8,3 +8,4 @@ include examples/echoserver/include.am include examples/server/include.am include examples/sctp/include.am include examples/configs/include.am +EXTRA_DIST += examples/README.md diff --git a/examples/server/server.c b/examples/server/server.c index bb42c3754..a242685c1 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -19,6 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +/* For simpler wolfSSL TLS server examples, visit + * https://github.com/wolfSSL/wolfssl-examples/tree/master/tls + */ #ifdef HAVE_CONFIG_H #include @@ -676,7 +679,7 @@ static void SetKeyShare(WOLFSSL* ssl, int onlyKeyShare, int useX25519, /* 4. add the same message into Japanese section */ /* (will be translated later) */ /* 5. add printf() into suitable position of Usage() */ -static const char* server_usage_msg[][59] = { +static const char* server_usage_msg[][60] = { /* English */ { " NOTE: All files relative to wolfSSL home dir\n", /* 0 */ @@ -821,8 +824,10 @@ static const char* server_usage_msg[][59] = { " SSLv3(0) - TLS1.2(3)\n", #else "-7 Set minimum downgrade protocol version [0-4] " - " SSLv3(0) - TLS1.3(4)\n", /* 59 */ + " SSLv3(0) - TLS1.3(4)\n\n", /* 59 */ #endif + "For simpler wolfSSL TLS server examples, visit\n" + "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 60 */ NULL, }, #ifndef NO_MULTIBYTE_PRINT @@ -976,8 +981,10 @@ static const char* server_usage_msg[][59] = { " SSLv3(0) - TLS1.2(3)\n", #else "-7 最小ダウングレード可能なプロトコルバージョンを設定します [0-4] " - " SSLv3(0) - TLS1.3(4)\n", /* 59 */ + " SSLv3(0) - TLS1.3(4)\n\n", /* 59 */ #endif + "For simpler wolfSSL TLS server examples, visit\n" + "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 60 */ NULL, }, #endif @@ -1119,6 +1126,7 @@ static void Usage(void) printf("%s", msg[++msgId]); /* --wolfsentry-config */ #endif printf("%s", msg[++msgId]); /* -7 */ + printf("%s", msg[++msgId]); /* Examples repo link */ } THREAD_RETURN WOLFSSL_THREAD server_test(void* args)