From 33f3566f61218c7b35eb089e74d646c9a8e9a402 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 26 Apr 2016 17:48:58 +0200 Subject: [PATCH] adapt to new trezor-crypto --- .../modtrezorcrypto-pbkdf2_hmac.h | 34 ++++++++----------- .../modtrezorcrypto-ripemd160.h | 19 +++++------ .../modtrezorcrypto/modtrezorcrypto-sha256.h | 19 +++++------ .../modtrezorcrypto-sha3-256.h | 18 +++++----- .../modtrezorcrypto-sha3-512.h | 18 +++++----- .../modtrezorcrypto/modtrezorcrypto-sha512.h | 19 +++++------ extmod/modtrezorcrypto/trezor-crypto | 1 + vendor/micropython | 2 +- vendor/trezor-crypto | 2 +- 9 files changed, 62 insertions(+), 70 deletions(-) create mode 120000 extmod/modtrezorcrypto/trezor-crypto diff --git a/extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2_hmac.h b/extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2_hmac.h index faa73f9c4d..193408264e 100644 --- a/extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2_hmac.h +++ b/extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2_hmac.h @@ -7,8 +7,7 @@ #include "py/objstr.h" -#include "mbedtls/pkcs5.h" -#include "mbedtls/md_internal.h" +#include "trezor-crypto/pbkdf2.h" // def pbkdf2_hmac(hash_name: str, password: bytes, salt: bytes, iterations: int, dklen:int=None) -> bytes STATIC mp_obj_t mod_TrezorCrypto_pbkdf2_hmac(size_t n_args, const mp_obj_t *args) { @@ -21,32 +20,27 @@ STATIC mp_obj_t mod_TrezorCrypto_pbkdf2_hmac(size_t n_args, const mp_obj_t *args mp_int_t iterations = mp_obj_get_int(args[3]); mp_int_t dklen = (n_args > 4) ? mp_obj_get_int(args[4]) : 0; - const mbedtls_md_info_t *info = 0; + int digestsize = 0; if (hash_name.len == 6 && memcmp(hash_name.buf, "sha256", hash_name.len) == 0) { - info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); + digestsize = 32; } else if (hash_name.len == 6 && memcmp(hash_name.buf, "sha512", hash_name.len) == 0) { - info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA512); + digestsize = 64; } - if (info == 0) { + if (digestsize == 0) { nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Invalid hash_name")); } - if (dklen == 0) { - dklen = info->size; + dklen = digestsize; } - mbedtls_md_context_t ctx; - mbedtls_md_init(&ctx); - if (mbedtls_md_setup(&ctx, info, 1) == 0) { - vstr_t vstr; - vstr_init_len(&vstr, dklen); - mbedtls_pkcs5_pbkdf2_hmac(&ctx, password.buf, password.len, salt.buf, salt.len, iterations, dklen, (uint8_t *)vstr.buf); - mbedtls_md_free(&ctx); - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); - } else { - mbedtls_md_free(&ctx); - nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "mbedtls_md_setup failed")); + vstr_t vstr; + vstr_init_len(&vstr, dklen); + if (digestsize == 32) { + pbkdf2_hmac_sha256(password.buf, password.len, salt.buf, salt.len, iterations, (uint8_t *)vstr.buf, dklen, NULL); } - return mp_const_none; + if (digestsize == 64) { + pbkdf2_hmac_sha512(password.buf, password.len, salt.buf, salt.len, iterations, (uint8_t *)vstr.buf, dklen, NULL); + } + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_pbkdf2_hmac_obj, 4, 5, mod_TrezorCrypto_pbkdf2_hmac); diff --git a/extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h b/extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h index 88182a78fb..8db83c66ff 100644 --- a/extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h +++ b/extmod/modtrezorcrypto/modtrezorcrypto-ripemd160.h @@ -7,7 +7,7 @@ #include "py/objstr.h" -#include "mbedtls/ripemd160.h" +#include "trezor-crypto/ripemd160.h" #define HASH_RIPEMD160_BLOCK_SIZE 64 #define HASH_RIPEMD160_DIGEST_SIZE 20 @@ -15,7 +15,7 @@ // class Ripemd160(object): typedef struct _mp_obj_Ripemd160_t { mp_obj_base_t base; - mbedtls_ripemd160_context ctx; + RIPEMD160_CTX ctx; } mp_obj_Ripemd160_t; STATIC mp_obj_t mod_TrezorCrypto_Ripemd160_update(mp_obj_t self, mp_obj_t data); @@ -25,8 +25,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Ripemd160_make_new(const mp_obj_type_t *type, s mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_Ripemd160_t *o = m_new_obj(mp_obj_Ripemd160_t); o->base.type = type; - mbedtls_ripemd160_init(&(o->ctx)); - mbedtls_ripemd160_starts(&(o->ctx)); + ripemd160_Init(&(o->ctx)); // constructor called with bytes/str as first parameter if (n_args == 1) { mod_TrezorCrypto_Ripemd160_update(MP_OBJ_FROM_PTR(o), args[0]); @@ -39,7 +38,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Ripemd160_update(mp_obj_t self, mp_obj_t data) mp_obj_Ripemd160_t *o = MP_OBJ_TO_PTR(self); mp_buffer_info_t databuf; mp_get_buffer_raise(data, &databuf, MP_BUFFER_READ); - mbedtls_ripemd160_update(&(o->ctx), databuf.buf, databuf.len); + ripemd160_Update(&(o->ctx), databuf.buf, databuf.len); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Ripemd160_update_obj, mod_TrezorCrypto_Ripemd160_update); @@ -49,10 +48,10 @@ STATIC mp_obj_t mod_TrezorCrypto_Ripemd160_digest(mp_obj_t self) { mp_obj_Ripemd160_t *o = MP_OBJ_TO_PTR(self); vstr_t vstr; vstr_init_len(&vstr, HASH_RIPEMD160_DIGEST_SIZE); - mbedtls_ripemd160_context ctx; - mbedtls_ripemd160_clone(&ctx, &(o->ctx)); - mbedtls_ripemd160_finish(&ctx, (uint8_t *)vstr.buf); - mbedtls_ripemd160_free(&ctx); + RIPEMD160_CTX ctx; + memcpy(&ctx, &(o->ctx), sizeof(RIPEMD160_CTX)); + ripemd160_Final(&ctx, (uint8_t *)vstr.buf); + memset(&ctx, 0, sizeof(RIPEMD160_CTX)); return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Ripemd160_digest_obj, mod_TrezorCrypto_Ripemd160_digest); @@ -60,7 +59,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Ripemd160_digest_obj, mod_Trez // def Ripemd160.__del__(self) -> None STATIC mp_obj_t mod_TrezorCrypto_Ripemd160___del__(mp_obj_t self) { mp_obj_Ripemd160_t *o = MP_OBJ_TO_PTR(self); - mbedtls_ripemd160_free(&(o->ctx)); + memset(&(o->ctx), 0, sizeof(RIPEMD160_CTX)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Ripemd160___del___obj, mod_TrezorCrypto_Ripemd160___del__); diff --git a/extmod/modtrezorcrypto/modtrezorcrypto-sha256.h b/extmod/modtrezorcrypto/modtrezorcrypto-sha256.h index d1ae7f475b..30cb78e048 100644 --- a/extmod/modtrezorcrypto/modtrezorcrypto-sha256.h +++ b/extmod/modtrezorcrypto/modtrezorcrypto-sha256.h @@ -7,7 +7,7 @@ #include "py/objstr.h" -#include "mbedtls/sha256.h" +#include "trezor-crypto/sha2.h" #define HASH_SHA256_BLOCK_SIZE 64 #define HASH_SHA256_DIGEST_SIZE 32 @@ -15,7 +15,7 @@ // class Sha256(object): typedef struct _mp_obj_Sha256_t { mp_obj_base_t base; - mbedtls_sha256_context ctx; + SHA256_CTX ctx; } mp_obj_Sha256_t; STATIC mp_obj_t mod_TrezorCrypto_Sha256_update(mp_obj_t self, mp_obj_t data); @@ -25,8 +25,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha256_make_new(const mp_obj_type_t *type, size mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_Sha256_t *o = m_new_obj(mp_obj_Sha256_t); o->base.type = type; - mbedtls_sha256_init(&(o->ctx)); - mbedtls_sha256_starts(&(o->ctx), 0); + sha256_Init(&(o->ctx)); // constructor called with bytes/str as first parameter if (n_args == 1) { mod_TrezorCrypto_Sha256_update(MP_OBJ_FROM_PTR(o), args[0]); @@ -39,7 +38,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha256_update(mp_obj_t self, mp_obj_t data) { mp_obj_Sha256_t *o = MP_OBJ_TO_PTR(self); mp_buffer_info_t databuf; mp_get_buffer_raise(data, &databuf, MP_BUFFER_READ); - mbedtls_sha256_update(&(o->ctx), databuf.buf, databuf.len); + sha256_Update(&(o->ctx), databuf.buf, databuf.len); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha256_update_obj, mod_TrezorCrypto_Sha256_update); @@ -49,10 +48,10 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha256_digest(mp_obj_t self) { mp_obj_Sha256_t *o = MP_OBJ_TO_PTR(self); vstr_t vstr; vstr_init_len(&vstr, HASH_SHA256_DIGEST_SIZE); - mbedtls_sha256_context ctx; - mbedtls_sha256_clone(&ctx, &(o->ctx)); - mbedtls_sha256_finish(&ctx, (uint8_t *)vstr.buf); - mbedtls_sha256_free(&ctx); + SHA256_CTX ctx; + memcpy(&ctx, &(o->ctx), sizeof(SHA256_CTX)); + sha256_Final(&ctx, (uint8_t *)vstr.buf); + memset(&ctx, 0, sizeof(SHA256_CTX)); return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha256_digest_obj, mod_TrezorCrypto_Sha256_digest); @@ -60,7 +59,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha256_digest_obj, mod_TrezorC // def Sha256.__del__(self) -> None STATIC mp_obj_t mod_TrezorCrypto_Sha256___del__(mp_obj_t self) { mp_obj_Sha256_t *o = MP_OBJ_TO_PTR(self); - mbedtls_sha256_free(&(o->ctx)); + memset(&(o->ctx), 0, sizeof(SHA256_CTX)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha256___del___obj, mod_TrezorCrypto_Sha256___del__); diff --git a/extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h b/extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h index 0c06f67b32..6bf28cee54 100644 --- a/extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h +++ b/extmod/modtrezorcrypto/modtrezorcrypto-sha3-256.h @@ -7,7 +7,7 @@ #include "py/objstr.h" -#include "sha3.h" +#include "trezor-crypto/sha3.h" #define HASH_SHA3_256_BLOCK_SIZE 64 #define HASH_SHA3_256_DIGEST_SIZE 32 @@ -15,7 +15,7 @@ // class Sha3_256(object): typedef struct _mp_obj_Sha3_256_t { mp_obj_base_t base; - sha3_ctx ctx; + SHA3_CTX ctx; } mp_obj_Sha3_256_t; STATIC mp_obj_t mod_TrezorCrypto_Sha3_256_update(mp_obj_t self, mp_obj_t data); @@ -25,7 +25,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_256_make_new(const mp_obj_type_t *type, si mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_Sha3_256_t *o = m_new_obj(mp_obj_Sha3_256_t); o->base.type = type; - rhash_sha3_256_init(&(o->ctx)); + sha3_256_Init(&(o->ctx)); // constructor called with bytes/str as first parameter if (n_args == 1) { mod_TrezorCrypto_Sha3_256_update(MP_OBJ_FROM_PTR(o), args[0]); @@ -38,7 +38,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_256_update(mp_obj_t self, mp_obj_t data) { mp_obj_Sha3_256_t *o = MP_OBJ_TO_PTR(self); mp_buffer_info_t databuf; mp_get_buffer_raise(data, &databuf, MP_BUFFER_READ); - rhash_sha3_update(&(o->ctx), databuf.buf, databuf.len); + sha3_Update(&(o->ctx), databuf.buf, databuf.len); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha3_256_update_obj, mod_TrezorCrypto_Sha3_256_update); @@ -48,10 +48,10 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_256_digest(mp_obj_t self) { mp_obj_Sha3_256_t *o = MP_OBJ_TO_PTR(self); vstr_t vstr; vstr_init_len(&vstr, HASH_SHA3_256_DIGEST_SIZE); - sha3_ctx ctx; - memcpy(&ctx, &(o->ctx), sizeof(sha3_ctx)); - rhash_sha3_final(&ctx, (uint8_t *)vstr.buf); - memset(&ctx, 0, sizeof(sha3_ctx)); + SHA3_CTX ctx; + memcpy(&ctx, &(o->ctx), sizeof(SHA3_CTX)); + sha3_Final(&ctx, (uint8_t *)vstr.buf); + memset(&ctx, 0, sizeof(SHA3_CTX)); return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha3_256_digest_obj, mod_TrezorCrypto_Sha3_256_digest); @@ -59,7 +59,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha3_256_digest_obj, mod_Trezo // def Sha3_256.__del__(self) -> None STATIC mp_obj_t mod_TrezorCrypto_Sha3_256___del__(mp_obj_t self) { mp_obj_Sha3_256_t *o = MP_OBJ_TO_PTR(self); - memset(&(o->ctx), 0, sizeof(sha3_ctx)); + memset(&(o->ctx), 0, sizeof(SHA3_CTX)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha3_256___del___obj, mod_TrezorCrypto_Sha3_256___del__); diff --git a/extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h b/extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h index ed5261ce7f..08e06dd79e 100644 --- a/extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h +++ b/extmod/modtrezorcrypto/modtrezorcrypto-sha3-512.h @@ -7,7 +7,7 @@ #include "py/objstr.h" -#include "sha3.h" +#include "trezor-crypto/sha3.h" #define HASH_SHA3_512_BLOCK_SIZE 128 #define HASH_SHA3_512_DIGEST_SIZE 64 @@ -15,7 +15,7 @@ // class Sha3_512(object): typedef struct _mp_obj_Sha3_512_t { mp_obj_base_t base; - sha3_ctx ctx; + SHA3_CTX ctx; } mp_obj_Sha3_512_t; STATIC mp_obj_t mod_TrezorCrypto_Sha3_512_update(mp_obj_t self, mp_obj_t data); @@ -25,7 +25,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_512_make_new(const mp_obj_type_t *type, si mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_Sha3_512_t *o = m_new_obj(mp_obj_Sha3_512_t); o->base.type = type; - rhash_sha3_512_init(&(o->ctx)); + sha3_512_Init(&(o->ctx)); // constructor called with bytes/str as first parameter if (n_args == 1) { mod_TrezorCrypto_Sha3_512_update(MP_OBJ_FROM_PTR(o), args[0]); @@ -38,7 +38,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_512_update(mp_obj_t self, mp_obj_t data) { mp_obj_Sha3_512_t *o = MP_OBJ_TO_PTR(self); mp_buffer_info_t databuf; mp_get_buffer_raise(data, &databuf, MP_BUFFER_READ); - rhash_sha3_update(&(o->ctx), databuf.buf, databuf.len); + sha3_Update(&(o->ctx), databuf.buf, databuf.len); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha3_512_update_obj, mod_TrezorCrypto_Sha3_512_update); @@ -48,10 +48,10 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_512_digest(mp_obj_t self) { mp_obj_Sha3_512_t *o = MP_OBJ_TO_PTR(self); vstr_t vstr; vstr_init_len(&vstr, HASH_SHA3_512_DIGEST_SIZE); - sha3_ctx ctx; - memcpy(&ctx, &(o->ctx), sizeof(sha3_ctx)); - rhash_sha3_final(&ctx, (uint8_t *)vstr.buf); - memset(&ctx, 0, sizeof(sha3_ctx)); + SHA3_CTX ctx; + memcpy(&ctx, &(o->ctx), sizeof(SHA3_CTX)); + sha3_Final(&ctx, (uint8_t *)vstr.buf); + memset(&ctx, 0, sizeof(SHA3_CTX)); return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha3_512_digest_obj, mod_TrezorCrypto_Sha3_512_digest); @@ -59,7 +59,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha3_512_digest_obj, mod_Trezo // def Sha3_512.__del__(self) -> None STATIC mp_obj_t mod_TrezorCrypto_Sha3_512___del__(mp_obj_t self) { mp_obj_Sha3_512_t *o = MP_OBJ_TO_PTR(self); - memset(&(o->ctx), 0, sizeof(sha3_ctx)); + memset(&(o->ctx), 0, sizeof(SHA3_CTX)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha3_512___del___obj, mod_TrezorCrypto_Sha3_512___del__); diff --git a/extmod/modtrezorcrypto/modtrezorcrypto-sha512.h b/extmod/modtrezorcrypto/modtrezorcrypto-sha512.h index 6aff396be0..30dd5c313a 100644 --- a/extmod/modtrezorcrypto/modtrezorcrypto-sha512.h +++ b/extmod/modtrezorcrypto/modtrezorcrypto-sha512.h @@ -7,7 +7,7 @@ #include "py/objstr.h" -#include "mbedtls/sha512.h" +#include "trezor-crypto/sha2.h" #define HASH_SHA512_BLOCK_SIZE 128 #define HASH_SHA512_DIGEST_SIZE 64 @@ -15,7 +15,7 @@ // class Sha512(object): typedef struct _mp_obj_Sha512_t { mp_obj_base_t base; - mbedtls_sha512_context ctx; + SHA512_CTX ctx; } mp_obj_Sha512_t; STATIC mp_obj_t mod_TrezorCrypto_Sha512_update(mp_obj_t self, mp_obj_t data); @@ -25,8 +25,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha512_make_new(const mp_obj_type_t *type, size mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_Sha512_t *o = m_new_obj(mp_obj_Sha512_t); o->base.type = type; - mbedtls_sha512_init(&(o->ctx)); - mbedtls_sha512_starts(&(o->ctx), 0); + sha512_Init(&(o->ctx)); if (n_args == 1) { mod_TrezorCrypto_Sha512_update(MP_OBJ_FROM_PTR(o), args[0]); } @@ -38,7 +37,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha512_update(mp_obj_t self, mp_obj_t data) { mp_obj_Sha512_t *o = MP_OBJ_TO_PTR(self); mp_buffer_info_t databuf; mp_get_buffer_raise(data, &databuf, MP_BUFFER_READ); - mbedtls_sha512_update(&(o->ctx), databuf.buf, databuf.len); + sha512_Update(&(o->ctx), databuf.buf, databuf.len); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha512_update_obj, mod_TrezorCrypto_Sha512_update); @@ -48,10 +47,10 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha512_digest(mp_obj_t self) { mp_obj_Sha512_t *o = MP_OBJ_TO_PTR(self); vstr_t vstr; vstr_init_len(&vstr, HASH_SHA512_DIGEST_SIZE); - mbedtls_sha512_context ctx; - mbedtls_sha512_clone(&ctx, &(o->ctx)); - mbedtls_sha512_finish(&ctx, (uint8_t *)vstr.buf); - mbedtls_sha512_free(&ctx); + SHA512_CTX ctx; + memcpy(&ctx, &(o->ctx), sizeof(SHA512_CTX)); + sha512_Final(&ctx, (uint8_t *)vstr.buf); + memset(&ctx, 0, sizeof(SHA512_CTX)); return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha512_digest_obj, mod_TrezorCrypto_Sha512_digest); @@ -59,7 +58,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha512_digest_obj, mod_TrezorC // def Sha512.__del__(self) -> None STATIC mp_obj_t mod_TrezorCrypto_Sha512___del__(mp_obj_t self) { mp_obj_Sha512_t *o = MP_OBJ_TO_PTR(self); - mbedtls_sha512_free(&(o->ctx)); + memset(&(o->ctx), 0, sizeof(SHA512_CTX)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha512___del___obj, mod_TrezorCrypto_Sha512___del__); diff --git a/extmod/modtrezorcrypto/trezor-crypto b/extmod/modtrezorcrypto/trezor-crypto new file mode 120000 index 0000000000..e533d16294 --- /dev/null +++ b/extmod/modtrezorcrypto/trezor-crypto @@ -0,0 +1 @@ +../../vendor/trezor-crypto \ No newline at end of file diff --git a/vendor/micropython b/vendor/micropython index f0ffa8c044..7a0980d511 160000 --- a/vendor/micropython +++ b/vendor/micropython @@ -1 +1 @@ -Subproject commit f0ffa8c044759ba10bd092b3ad0e1434fa1b6654 +Subproject commit 7a0980d51160a757bc509f7294460179e399a45a diff --git a/vendor/trezor-crypto b/vendor/trezor-crypto index c01be339f5..08219ea77a 160000 --- a/vendor/trezor-crypto +++ b/vendor/trezor-crypto @@ -1 +1 @@ -Subproject commit c01be339f5c43d244aa545c444cd060f334f7fe2 +Subproject commit 08219ea77ad5651c7bd2641ca13956a90ba96ae6