Skip to content

Commit e7ae3ad

Browse files
committed
extmod: Update to support mbedtls 3.x.
Signed-off-by: Damien George <[email protected]>
1 parent 41c9142 commit e7ae3ad

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

extmod/modhashlib.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg);
7575

7676
#if MICROPY_SSL_MBEDTLS
7777

78-
#if MBEDTLS_VERSION_NUMBER < 0x02070000
78+
#if MBEDTLS_VERSION_NUMBER < 0x02070000 || MBEDTLS_VERSION_NUMBER >= 0x03000000
7979
#define mbedtls_sha256_starts_ret mbedtls_sha256_starts
8080
#define mbedtls_sha256_update_ret mbedtls_sha256_update
8181
#define mbedtls_sha256_finish_ret mbedtls_sha256_finish
@@ -203,7 +203,7 @@ STATIC mp_obj_t hashlib_sha1_digest(mp_obj_t self_in) {
203203

204204
#if MICROPY_SSL_MBEDTLS
205205

206-
#if MBEDTLS_VERSION_NUMBER < 0x02070000
206+
#if MBEDTLS_VERSION_NUMBER < 0x02070000 || MBEDTLS_VERSION_NUMBER >= 0x03000000
207207
#define mbedtls_sha1_starts_ret mbedtls_sha1_starts
208208
#define mbedtls_sha1_update_ret mbedtls_sha1_update
209209
#define mbedtls_sha1_finish_ret mbedtls_sha1_finish

extmod/modssl_mbedtls.c

+4
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
225225
size_t key_len;
226226
const byte *key = (const byte *)mp_obj_str_get_data(args->key.u_obj, &key_len);
227227
// len should include terminating null
228+
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
229+
ret = mbedtls_pk_parse_key(&o->pkey, key, key_len + 1, NULL, 0, mbedtls_ctr_drbg_random, &o->ctr_drbg);
230+
#else
228231
ret = mbedtls_pk_parse_key(&o->pkey, key, key_len + 1, NULL, 0);
232+
#endif
229233
if (ret != 0) {
230234
ret = MBEDTLS_ERR_PK_BAD_INPUT_DATA; // use general error for all key errors
231235
goto cleanup;

0 commit comments

Comments
 (0)