From 4a5c380f320b27c3e57f00d6b60d9b32cc52a1d3 Mon Sep 17 00:00:00 2001 From: Hideki Miyazaki Date: Thu, 17 Jan 2019 12:25:28 +0900 Subject: [PATCH] Addressed review comments --- .../examples/wolfssl_benchmark/main/helper.c | 15 ++------------- .../examples/wolfssl_client/main/client-tls.c | 16 ++++++---------- .../examples/wolfssl_server/main/server-tls.c | 14 ++++++-------- IDE/Espressif/ESP-IDF/libs/CMakeLists.txt | 1 + IDE/Espressif/ESP-IDF/user_settings.h | 14 ++++++++++---- wolfcrypt/src/logging.c | 5 ++--- wolfssl/wolfcrypt/settings.h | 5 ----- 7 files changed, 27 insertions(+), 43 deletions(-) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/helper.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/helper.c index 69e111a73..96bc978d2 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/helper.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/helper.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "sdkconfig.h" #include "freertos/FreeRTOS.h" @@ -36,15 +37,8 @@ /* proto-type */ extern void wolf_benchmark_task(); -extern int benchmark_init(); -extern int benchmark_test(void *args); - -#ifdef WOLFSSL_ESPWROOM32SE -const static char* TAG = "wolfbenchmark"; -#else -const char* TAG = "wolfbenchmark"; -#endif +static const char* const TAG = "wolfbenchmark"; char* __argv[22]; @@ -53,17 +47,12 @@ char* __argv[22]; #include "wolfssl/wolfcrypt/port/atmel/atmel.h" -int atcatls_set_callbacks(struct WOLFSSL_CTX* ctx); - /* when you need to use a custom slot allocation, */ /* enable the definition CUSTOM_SLOT_ALLOCAION. */ - #if defined(CUSTOM_SLOT_ALLOCATION) static byte mSlotList[ATECC_MAX_SLOT]; -int atmel_set_slot_allocator(atmel_slot_alloc_cb alloc, atmel_slot_dealloc_cb dealloc); - /* initialize slot array */ void my_atmel_slotInit() { diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c index 665d0a35f..5514f8f3d 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c @@ -40,15 +40,13 @@ #include #endif -#ifdef WOLFSSL_ESPWROOM32SE -static const char* TAG = "tls_client"; -#else -const char* TAG = "tls_client"; -#endif +static const char* const TAG = "tls_client"; + +#if defined(DEBUG_WOLFSSL) static void ShowCiphers(void) { - static char ciphers[4096]; + char ciphers[4096]; int ret = wolfSSL_get_ciphers(ciphers, (int)sizeof(ciphers)); @@ -56,13 +54,13 @@ static void ShowCiphers(void) printf("%s\n", ciphers); } +#endif + #if defined(WOLFSSL_ESPWROOM32SE) && defined(HAVE_PK_CALLBACKS) \ && defined(WOLFSSL_ATECC508A) #include "wolfssl/wolfcrypt/port/atmel/atmel.h" -int atcatls_set_callbacks(struct WOLFSSL_CTX* ctx); - /* when you want to use custome slot allocation */ /* enable the definition CUSTOM_SLOT_ALLOCATION.*/ @@ -147,8 +145,6 @@ void tls_smp_client_task() WOLFSSL_MSG("Debug ON"); wolfSSL_Debugging_ON(); ShowCiphers(); -#else - (void)ShowCiphers; #endif /* Initialize wolfSSL */ wolfSSL_Init(); diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/server-tls.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/server-tls.c index 746409b97..55d39ffd7 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/server-tls.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/server-tls.c @@ -1,6 +1,6 @@ /* server-tls-callback.c * - * Copyright (C) 2006-2018 wolfSSL Inc. + * Copyright (C) 2006-2019 wolfSSL Inc. * * This file is part of wolfSSL. (formerly known as CyaSSL) * @@ -42,11 +42,9 @@ #include #endif -#if defined(WOLFSSL_ESPWROOM32SE) -static const char* TAG = "tls_server"; -#else -const char* TAG = "tls_server"; -#endif +static const char* const TAG = "tls_server"; + +#if defined(DEBUG_WOLFSSL) static void ShowCiphers(void) { @@ -58,6 +56,8 @@ static void ShowCiphers(void) printf("%s\n", ciphers); } +#endif + #if defined(WOLFSSL_ESPWROOM32SE) && defined(HAVE_PK_CALLBACKS) \ && defined(WOLFSSL_ATECC508A) @@ -146,8 +146,6 @@ void tls_smp_server_task() WOLFSSL_MSG("Debug ON"); wolfSSL_Debugging_ON(); ShowCiphers(); -#else - (void)ShowCiphers; #endif /* Initialize wolfSSL */ diff --git a/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt b/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt index d26a853f8..9009c574d 100644 --- a/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/libs/CMakeLists.txt @@ -11,6 +11,7 @@ set(INCLUDE_PATH ${WOLFSSL_ROOT}) set(COMPONENT_SRCDIRS "./src/" "./wolfcrypt/src/" "./wolfcrypt/src/port/Espressif/" + "./wolfcrypt/src/port/atmel/" ) set(COMPONENT_REQUIRES lwip) diff --git a/IDE/Espressif/ESP-IDF/user_settings.h b/IDE/Espressif/ESP-IDF/user_settings.h index 05b2deb69..c88345bb9 100644 --- a/IDE/Espressif/ESP-IDF/user_settings.h +++ b/IDE/Espressif/ESP-IDF/user_settings.h @@ -44,10 +44,16 @@ #define CURVE25519_SMALL #define HAVE_ED25519 -/* when you want to use a custom slot allocation for ATECC608A */ -/* unless your configuration is unusual, you can use default */ -/* implementation. */ -/* #define CUSTOM_SLOT_ALLOCATION */ +/* esp32-wroom-32se specific definition */ +#if defined(WOLFSSL_ESPWROOM32SE) + #define WOLFSSL_ATECC508A + #define HAVE_PK_CALLBACKS + /* when you want to use a custom slot allocation for ATECC608A */ + /* unless your configuration is unusual, you can use default */ + /* implementation. */ + /* #define CUSTOM_SLOT_ALLOCATION */ +#endif + /* debug options */ /* #define DEBUG_WOLFSSL */ diff --git a/wolfcrypt/src/logging.c b/wolfcrypt/src/logging.c index 063d8ffaf..85166466d 100644 --- a/wolfcrypt/src/logging.c +++ b/wolfcrypt/src/logging.c @@ -1,6 +1,6 @@ /* logging.c * - * Copyright (C) 2006-2017 wolfSSL Inc. + * Copyright (C) 2006-2019 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -255,8 +255,7 @@ static void wolfssl_log(const int logLevel, const char *const logMessage) #elif defined(WOLFSSL_APACHE_MYNEWT) LOG_DEBUG(&mynewt_log, LOG_MODULE_DEFAULT, "%s\n", logMessage); #elif defined(WOLFSSL_ESPIDF) - extern char* TAG; - ESP_LOGI(TAG, "%s", logMessage); + ESP_LOGI("wolfssl", "%s", logMessage); #else fprintf(stderr, "%s\n", logMessage); #endif diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 0e1c6fc0a..c4cc25e5a 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -241,11 +241,6 @@ #define WOLFSSL_ESP32WROOM32_CRYPT #endif #endif -#if defined(WOLFSSL_ESPWROOM32SE) - /* esp32-wroom-32se specific definition */ - #define WOLFSSL_ATECC508A - #define HAVE_PK_CALLBACKS -#endif #if !defined(WOLFSSL_USER_SETTINGS) #define HAVE_ECC #endif /* !WOLFSSL_USER_SETTINGS */