8000 rp2/mbedtls: Enable certificate validity time validation. · micropython/micropython@b560b9f · GitHub
[go: up one dir, main page]

Skip to content

Commit b560b9f

Browse files
daviesiandpgeorge
authored andcommitted
rp2/mbedtls: Enable certificate validity time validation.
1 parent 10f85fe commit b560b9f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

ports/rp2/mbedtls/mbedtls_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE
9494
#define MBEDTLS_X509_CRT_PARSE_C
9595
#define MBEDTLS_X509_USE_C
96+
#define MBEDTLS_HAVE_TIME
97+
#define MBEDTLS_HAVE_TIME_DATE
9698

9799
// Memory allocation hooks
98100
#include <stdlib.h>
@@ -103,6 +105,10 @@ void m_tracked_free(void *ptr);
103105
#define MBEDTLS_PLATFORM_STD_FREE m_tracked_free
104106
#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
105107

108+
// Time hook
109+
time_t rp2_rtctime_seconds(time_t *timer);
110+
#define MBEDTLS_PLATFORM_TIME_MACRO rp2_rtctime_seconds
111+
106112
#include "mbedtls/check_config.h"
107113

108114
#endif /* MICROPY_INCLUDED_MBEDTLS_CONFIG_H */

ports/rp2/mbedtls/mbedtls_port.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
#include "mbedtls_config.h"
3131

32+
#include "hardware/rtc.h"
33+
#include "shared/timeutils/timeutils.h"
34+
3235
extern uint8_t rosc_random_u8(size_t cycles);
3336

3437
int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t *olen) {
@@ -39,4 +42,10 @@ int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t
3942
return 0;
4043
}
4144

45+
time_t rp2_rtctime_seconds(time_t *timer) {
46+
datetime_t t;
47+
rtc_get_datetime(&t);
48+
return timeutils_seconds_since_epoch(t.year, t.month, t.day, t.hour, t.min, t.sec);
49+
}
50+
4251
#endif

0 commit comments

Comments
 (0)
0