From f024b2610f68109a3a5d8ec2680ca3bafc179344 Mon Sep 17 00:00:00 2001 From: Yonatan Goldschmidt Date: Wed, 6 Feb 2019 00:08:25 +0200 Subject: [PATCH] extmod/moduhashlib: Include implementation of sha256 only when required. Previously crypto-algorithms impl was included even if MICROPY_SSL_MBEDTLS was in effect, thus we relied on the compiler/linker to cut out the unused functions. --- extmod/moduhashlib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index 50df7ca88..603cdb44a 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -104,6 +104,8 @@ STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) { #else +#include "crypto-algorithms/sha256.c" + STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX)); @@ -344,8 +346,4 @@ const mp_obj_module_t mp_module_uhashlib = { .globals = (mp_obj_dict_t*)&mp_module_uhashlib_globals, }; -#if MICROPY_PY_UHASHLIB_SHA256 -#include "crypto-algorithms/sha256.c" -#endif - #endif //MICROPY_PY_UHASHLIB