From c1802eaa98478afd58cf037ab229342261179358 Mon Sep 17 00:00:00 2001 From: Liu Han Date: Thu, 1 Dec 2016 16:25:44 +0800 Subject: [PATCH] components/mbedtls: add time and time data configuration at menuconfig --- components/mbedtls/Kconfig | 20 +++++++++++++++++++ .../mbedtls/port/include/mbedtls/esp_config.h | 8 ++++++-- components/mbedtls/port/net.c | 10 ++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/components/mbedtls/Kconfig b/components/mbedtls/Kconfig index 1e347582f0..5a719ff33a 100644 --- a/components/mbedtls/Kconfig +++ b/components/mbedtls/Kconfig @@ -81,4 +81,24 @@ config MBEDTLS_HARDWARE_SHA be calculated fully in hardware and the rest will be calculated (at least partially calculated) in software. +config MBEDTLS_HAVE_TIME + bool "Enable mbedtls time" + depends on !ESP32_TIME_SYSCALL_USE_NONE + default y + help + System has time.h and time(). + The time does not need to be correct, only time differences are used, + +config MBEDTLS_HAVE_TIME_DATE + bool "Enable mbedtls time data" + depends on MBEDTLS_HAVE_TIME + default n + help + System has time.h and time(), gmtime() and the clock is correct. + The time needs to be correct (not necesarily very accurate, but at least + the date should be correct). This is used to verify the validity period of + X.509 certificates. + + It is suggested that you should get the real time by "SNTP". + endmenu diff --git a/components/mbedtls/port/include/mbedtls/esp_config.h b/components/mbedtls/port/include/mbedtls/esp_config.h index cd9f87e698..fd6c023fa3 100644 --- a/components/mbedtls/port/include/mbedtls/esp_config.h +++ b/components/mbedtls/port/include/mbedtls/esp_config.h @@ -74,7 +74,9 @@ * * Comment if your system does not support time functions */ -//#define MBEDTLS_HAVE_TIME +#ifdef CONFIG_MBEDTLS_HAVE_TIME +#define MBEDTLS_HAVE_TIME +#endif /** * \def MBEDTLS_HAVE_TIME_DATE @@ -86,7 +88,9 @@ * * Comment if your system does not have a correct clock. */ -//#define MBEDTLS_HAVE_TIME_DATE +#ifdef CONFIG_MBEDTLS_HAVE_TIME_DATE +#define MBEDTLS_HAVE_TIME_DATE +#endif /** * \def MBEDTLS_PLATFORM_MEMORY diff --git a/components/mbedtls/port/net.c b/components/mbedtls/port/net.c index 45aa4b2deb..bb0884ac87 100644 --- a/components/mbedtls/port/net.c +++ b/components/mbedtls/port/net.c @@ -29,6 +29,16 @@ #if !defined(MBEDTLS_NET_C) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#define mbedtls_time time +#define mbedtls_time_t time_t +#endif + #include "mbedtls/net.h" #include -- 2.40.0