summaryrefslogtreecommitdiff
path: root/extmod/moduhashlib.c
diff options
context:
space:
mode:
authorYonatan Goldschmidt <yon.goldschmidt@gmail.com>2019-02-06 00:08:25 +0200
committerDamien George <damien.p.george@gmail.com>2019-02-07 23:27:58 +1100
commitf024b2610f68109a3a5d8ec2680ca3bafc179344 (patch)
treede891ad2ed2ea96468415295323b357198d5c6c3 /extmod/moduhashlib.c
parentc33f53806630fcfa471dfc2c8338f79b5d820708 (diff)
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.
Diffstat (limited to 'extmod/moduhashlib.c')
-rw-r--r--extmod/moduhashlib.c6
1 files 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