Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
52e3da0a
Commit
52e3da0a
authored
Sep 06, 2023
by
iabdalkader
Committed by
Damien George
Sep 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mimxrt/mbedtls: Enable certificate validity time validation.
Signed-off-by:
iabdalkader
<
i.abdalkader@gmail.com
>
parent
361ca7d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
ports/mimxrt/mbedtls/mbedtls_config.h
ports/mimxrt/mbedtls/mbedtls_config.h
+9
-0
ports/mimxrt/mbedtls/mbedtls_port.c
ports/mimxrt/mbedtls/mbedtls_port.c
+36
-0
No files found.
ports/mimxrt/mbedtls/mbedtls_config.h
View file @
52e3da0a
...
...
@@ -26,6 +26,15 @@
#ifndef MICROPY_INCLUDED_MBEDTLS_CONFIG_H
#define MICROPY_INCLUDED_MBEDTLS_CONFIG_H
// Enable mbedtls modules.
#define MBEDTLS_HAVE_TIME
#define MBEDTLS_HAVE_TIME_DATE
// Time hook.
#include <time.h>
extern
time_t
mimxrt_rtctime_seconds
(
time_t
*
timer
);
#define MBEDTLS_PLATFORM_TIME_MACRO mimxrt_rtctime_seconds
// Set MicroPython-specific options.
#define MICROPY_MBEDTLS_CONFIG_BARE_METAL (1)
...
...
ports/mimxrt/mbedtls/mbedtls_port.c
View file @
52e3da0a
...
...
@@ -24,9 +24,16 @@
* THE SOFTWARE.
*/
#include "py/runtime.h"
#ifdef MICROPY_SSL_MBEDTLS
#include "mbedtls_config.h"
#if defined(MBEDTLS_HAVE_TIME) || defined(MBEDTLS_HAVE_TIME_DATE)
#include "fsl_snvs_lp.h"
#include "shared/timeutils/timeutils.h"
#endif
void
trng_random_data
(
unsigned
char
*
output
,
size_t
len
);
int
mbedtls_hardware_poll
(
void
*
data
,
unsigned
char
*
output
,
size_t
len
,
size_t
*
olen
)
{
...
...
@@ -38,4 +45,33 @@ int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t
return
0
;
}
#if defined(MBEDTLS_HAVE_TIME)
time_t
mimxrt_rtctime_seconds
(
time_t
*
timer
)
{
// Get date and date in CPython order.
snvs_lp_srtc_datetime_t
date
;
SNVS_LP_SRTC_GetDatetime
(
SNVS
,
&
date
);
return
timeutils_seconds_since_epoch
(
date
.
year
,
date
.
month
,
date
.
day
,
date
.
hour
,
date
.
minute
,
date
.
second
);
}
#endif
#if defined(MBEDTLS_HAVE_TIME_DATE)
struct
tm
*
gmtime
(
const
time_t
*
timep
)
{
static
struct
tm
tm
;
timeutils_struct_time_t
tm_buf
=
{
0
};
timeutils_seconds_since_epoch_to_struct_time
(
*
timep
,
&
tm_buf
);
tm
.
tm_sec
=
tm_buf
.
tm_sec
;
tm
.
tm_min
=
tm_buf
.
tm_min
;
tm
.
tm_hour
=
tm_buf
.
tm_hour
;
tm
.
tm_mday
=
tm_buf
.
tm_mday
;
tm
.
tm_mon
=
tm_buf
.
tm_mon
-
1
;
tm
.
tm_year
=
tm_buf
.
tm_year
-
1900
;
tm
.
tm_wday
=
tm_buf
.
tm_wday
;
tm
.
tm_yday
=
tm_buf
.
tm_yday
;
tm
.
tm_isdst
=
-
1
;
return
&
tm
;
}
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment