From 8a562c817ce0003dd39b34d9123d138ac28cc019 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 13 Mar 2017 12:22:44 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20build=20issues=20with=20DEBUG=5FWOLFSSL?= =?UTF-8?q?=20defined.=20Fix=20typo=20in=20user=5Fsettings.h=20for=20DEBUG?= =?UTF-8?q?=5FWOLFSSL.=20Fix=20issue=20with=20example=20client=20waiting?= =?UTF-8?q?=20on=20local=20server=20(shouldn=E2=80=99t=20be).=20Updated=20?= =?UTF-8?q?README.md=20with=20example=20output.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IDE/INTIME-RTOS/README.md | 105 ++++++++++++++++++++++ IDE/INTIME-RTOS/user_settings.h | 15 +++- IDE/INTIME-RTOS/wolfExamples.c | 10 +-- IDE/INTIME-RTOS/wolfExamples.sln | 12 --- IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h | 11 ++- wolfssl/wolfcrypt/logging.h | 8 +- 6 files changed, 134 insertions(+), 27 deletions(-) mode change 100644 => 100755 wolfssl/wolfcrypt/logging.h diff --git a/IDE/INTIME-RTOS/README.md b/IDE/INTIME-RTOS/README.md index 21e137adf..e747efdde 100755 --- a/IDE/INTIME-RTOS/README.md +++ b/IDE/INTIME-RTOS/README.md @@ -32,10 +32,104 @@ Please select one of the above options: Performs testing of all crypto algorithms. +``` +Crypt Test +error test passed! +base64 test passed! +base64 test passed! +MD5 test passed! +SHA test passed! +SHA-256 test passed! +SHA-384 test passed! +SHA-512 test passed! +Hash test passed! +HMAC-MD5 test passed! +HMAC-SHA test passed! +HMAC-SHA256 test passed! +HMAC-SHA384 test passed! +HMAC-SHA512 test passed! +HMAC-KDF test passed! +X963-KDF test passed! +GMAC test passed! +Chacha test passed! +POLY1305 test passed! +ChaCha20-Poly1305 AEAD test passed! +DES test passed! +DES3 test passed! +AES test passed! +AES-GCM test passed! +AES-CCM test passed! +AES Key Wrap test passed! +RANDOM test passed! +RSA test passed! +DH test passed! +DSA test passed! +SRP test passed! +PWDBASED test passed! +openSSL extra test +OPENSSL test passed! +ECC test passed! +ECC Enc test passed! +ECC buffer test passed! +CURVE25519 test passed! +ED25519 test passed! +CMAC test passed! +PKCS7enveloped test passed! +PKCS7signed test passed! +PKCS7encrypted test passed! +mutex test passed! +memcb test passed! +Crypt Test: Return code 0 +``` + ### `b` wolfCrypt Benchmark Performs benchmark of crypto algorithms. +``` +Benchmark Test +RNG 25 kB took 0.002 seconds, 11.017 MB/s +AES enc 25 kB took 0.002 seconds, 15.090 MB/s +AES dec 25 kB took 0.002 seconds, 15.119 MB/s +AES-GCM 25 kB took 0.003 seconds, 9.433 MB/s +AES-CTR 25 kB took 0.001 seconds, 22.378 MB/s +AES-CCM 25 kB took 0.002 seconds, 15.306 MB/s +CHACHA 25 kB took 0.002 seconds, 16.063 MB/s +CHA-POLY 25 kB took 0.001 seconds, 20.447 MB/s +3DES 25 kB took 0.002 seconds, 10.717 MB/s + +MD5 25 kB took 0.00 seconds, 31.576 MB/s +POLY1305 25 kB took 0.000 seconds, 201.575 MB/s +SHA 25 kB took 0.00 seconds, 43.761 MB/s +SHA-256 25 kB took 0.001 seconds, 19.299 MB/s +SHA-384 25 kB took 0.002 seconds, 14.577 MB/s +SHA-512 25 kB took 0.001 seconds, 21.718 MB/s +AES-CMAC 25 kB took 0.00 seconds, 34.925 MB/s + +RSA 2048 public 2.445 milliseconds, avg over 1 iterations +RSA 2048 private 64.711 milliseconds, avg over 1 iterations + +RSA 1024 key generation 318.755 milliseconds, avg over 5 iterations +RSA 2048 key generation 22648.396 milliseconds, avg over 5 iterations +DH 2048 key generation 23.119 milliseconds, avg over 1 iterations +DH 2048 key agreement 26.756 milliseconds, avg over 1 iterations + +ECC 256 key generation 2.984 milliseconds, avg over 5 iterations +EC-DHE key agreement 2.967 milliseconds, avg over 5 iterations +EC-DSA sign time 1.448 milliseconds, avg over 5 iterations +EC-DSA verify time 3.304 milliseconds, avg over 5 iterations +ECC encrypt 5.860 milliseconds, avg over 1 iterations +ECC decrypt 6.360 milliseconds, avg over 1 iterations + +CURVE25519 256 key generation 1.416 milliseconds, avg over 5 iterations +CURVE25519 key agreement 1.332 milliseconds, avg over 5 iterations + +ED25519 key generation 0.320 milliseconds, avg over 5 iterations +ED25519 sign time 0.595 milliseconds, avg over 5 iterations +ED25519 verify time 1.310 milliseconds, avg over 5 iterations +Benchmark Test: Return code 0 +``` + ### `c` wolfSSL Client To configure the host address and port modify the `TLS_HOST_REMOTE` and `TLS_PORT` macros at top of `wolfExamples.c`. This example uses TLS 1.2 to connect to a remote host. @@ -48,6 +142,17 @@ To configure the port to listen on modify `TLS_PORT` at top of `wolfExamples.c`. Starts a TLS server thread listening on localhost. Starts the TLS client and performs connect, exchanges some data and disconnects. +``` +Waiting for a connection... +Client connected successfully +Using Non-Blocking I/O: 0 +Message for server: Client: + +Recieved: I hear ya fa shizzle! + +The client has closed the connection. +``` + ## References For more information please contact info@wolfssl.com. diff --git a/IDE/INTIME-RTOS/user_settings.h b/IDE/INTIME-RTOS/user_settings.h index 14e78cc89..dfff66834 100755 --- a/IDE/INTIME-RTOS/user_settings.h +++ b/IDE/INTIME-RTOS/user_settings.h @@ -17,7 +17,7 @@ extern "C" { #define INTIME_RTOS_MUTEX_MAX 10 #undef WOLF_EXAMPLES_STACK -#define WOLF_EXAMPLES_STACK 131072 +#define WOLF_EXAMPLES_STACK 65536 #undef WOLFSSL_GENERAL_ALIGNMENT #define WOLFSSL_GENERAL_ALIGNMENT 4 @@ -32,9 +32,11 @@ extern "C" { #undef NO_WOLFSSL_DIR #define NO_WOLFSSL_DIR +/* disable writev */ #undef NO_WRITEV #define NO_WRITEV +/* we provide main entry point */ #undef NO_MAIN_DRIVER #define NO_MAIN_DRIVER @@ -83,8 +85,13 @@ extern "C" { #undef HAVE_ALL_CURVES //#define HAVE_ALL_CURVES #ifndef HAVE_ALL_CURVES + /* allows enabling custom curve sizes */ #undef ECC_USER_CURVES #define ECC_USER_CURVES + + //#define HAVE_ECC112 + //#define HAVE_ECC128 + //#define HAVE_ECC160 #define HAVE_ECC192 #define HAVE_ECC224 //#define NO_ECC256 @@ -478,9 +485,9 @@ extern "C" { /* ------------------------------------------------------------------------- */ /* Debugging */ /* ------------------------------------------------------------------------- */ -#undef WOLFSSL_DEBUG -#define WOLFSSL_DEBUG -#ifdef WOLFSSL_DEBUG +#undef DEBUG_WOLFSSL +//#define DEBUG_WOLFSSL +#ifdef DEBUG_WOLFSSL /* Use this to measure / print heap usage */ #if 0 #undef USE_WOLFSSL_MEMORY diff --git a/IDE/INTIME-RTOS/wolfExamples.c b/IDE/INTIME-RTOS/wolfExamples.c index fdea5eb68..d7b801ee7 100755 --- a/IDE/INTIME-RTOS/wolfExamples.c +++ b/IDE/INTIME-RTOS/wolfExamples.c @@ -59,11 +59,6 @@ int wolfExample_TLSClient(const char* ip, int port) struct sockaddr_in servAddr; /* struct for server address */ char sendBuff[TLS_MAXDATASIZE], rcvBuff[TLS_MAXDATASIZE]; - /* wait for server to be ready */ - while (gServerReady != 1) { - RtSleep(0); - } - sockFd = socket(AF_INET, SOCK_STREAM, 0); if (sockFd < 0) { printf("Failed to create socket. Error: %d\n", errno); @@ -299,6 +294,11 @@ int wolfExample_TLSLocal(int port) return -1; } + /* wait for server to be ready */ + while (gServerReady != 1) { + RtSleep(0); + } + /* run client */ ret = wolfExample_TLSClient(TLS_HOST_LOCAL, port); diff --git a/IDE/INTIME-RTOS/wolfExamples.sln b/IDE/INTIME-RTOS/wolfExamples.sln index 81666bf8e..ab478bf6d 100755 --- a/IDE/INTIME-RTOS/wolfExamples.sln +++ b/IDE/INTIME-RTOS/wolfExamples.sln @@ -24,18 +24,6 @@ Global {1731767D-573F-45C9-A466-191DA0D180CF}.Debug|INtime.Build.0 = Debug|INtime {1731767D-573F-45C9-A466-191DA0D180CF}.Release|INtime.ActiveCfg = Release|INtime {1731767D-573F-45C9-A466-191DA0D180CF}.Release|INtime.Build.0 = Release|INtime - {AA35919C-9D2D-4753-8FD1-E5D1644ABE65}.Debug|INtime.ActiveCfg = Debug|INtime - {AA35919C-9D2D-4753-8FD1-E5D1644ABE65}.Debug|INtime.Build.0 = Debug|INtime - {AA35919C-9D2D-4753-8FD1-E5D1644ABE65}.Release|INtime.ActiveCfg = Release|INtime - {AA35919C-9D2D-4753-8FD1-E5D1644ABE65}.Release|INtime.Build.0 = Release|INtime - {A7A65D11-2A66-4936-9476-16646CF896CA}.Debug|INtime.ActiveCfg = Debug|INtime - {A7A65D11-2A66-4936-9476-16646CF896CA}.Debug|INtime.Build.0 = Debug|INtime - {A7A65D11-2A66-4936-9476-16646CF896CA}.Release|INtime.ActiveCfg = Release|INtime - {A7A65D11-2A66-4936-9476-16646CF896CA}.Release|INtime.Build.0 = Release|INtime - {2359342B-C023-4443-8170-3471928C9334}.Debug|INtime.ActiveCfg = Debug|INtime - {2359342B-C023-4443-8170-3471928C9334}.Debug|INtime.Build.0 = Debug|INtime - {2359342B-C023-4443-8170-3471928C9334}.Release|INtime.ActiveCfg = Release|INtime - {2359342B-C023-4443-8170-3471928C9334}.Release|INtime.Build.0 = Release|INtime EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h b/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h index ae3e57858..5641973c9 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h +++ b/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h @@ -232,14 +232,17 @@ extern "C" { #undef USE_CERT_BUFFERS_2048 #define USE_CERT_BUFFERS_2048 +#undef USE_CERT_BUFFERS_256 +#define USE_CERT_BUFFERS_256 + /* ------------------------------------------------------------------------- */ /* Debugging */ /* ------------------------------------------------------------------------- */ -#undef WOLFSSL_DEBUG -//#define WOLFSSL_DEBUG +#undef DEBUG_WOLFSSL +//#define DEBUG_WOLFSSL -#ifdef WOLFSSL_DEBUG +#ifdef DEBUG_WOLFSSL #define fprintf(file, format, ...) printf(format, ##__VA_ARGS__) /* Use this to measure / print heap usage */ @@ -255,7 +258,7 @@ extern "C" { #define NO_WOLFSSL_MEMORY #undef NO_ERROR_STRINGS - #define NO_ERROR_STRINGS + //#define NO_ERROR_STRINGS #endif diff --git a/wolfssl/wolfcrypt/logging.h b/wolfssl/wolfcrypt/logging.h old mode 100644 new mode 100755 index 66e90127b..43df62ff6 --- a/wolfssl/wolfcrypt/logging.h +++ b/wolfssl/wolfcrypt/logging.h @@ -62,8 +62,12 @@ WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function); #endif /* defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) */ #ifdef DEBUG_WOLFSSL - #if defined ( WIN32 ) - #define __func__ __FUNCTION__ + #if defined(_WIN32) + #if defined(INTIME_RTOS) + #define __func__ NULL + #else + #define __func__ __FUNCTION__ + #endif #endif /* a is prepended to m and b is appended, creating a log msg a + m + b */