summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extmod/moduhashlib.c8
-rw-r--r--py/mpconfig.h8
2 files changed, 16 insertions, 0 deletions
diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c
index 2eb90ed73..e47bae0a0 100644
--- a/extmod/moduhashlib.c
+++ b/extmod/moduhashlib.c
@@ -31,7 +31,9 @@
#if MICROPY_PY_UHASHLIB
+#if MICROPY_PY_UHASHLIB_SHA256
#include "crypto-algorithms/sha256.h"
+#endif
#if MICROPY_PY_UHASHLIB_SHA1
@@ -50,6 +52,7 @@ typedef struct _mp_obj_hash_t {
char state[0];
} mp_obj_hash_t;
+#if MICROPY_PY_UHASHLIB_SHA256
STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg);
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) {
@@ -94,6 +97,7 @@ STATIC const mp_obj_type_t uhashlib_sha256_type = {
.make_new = uhashlib_sha256_make_new,
.locals_dict = (void*)&uhashlib_sha256_locals_dict,
};
+#endif
#if MICROPY_PY_UHASHLIB_SHA1
STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg);
@@ -177,7 +181,9 @@ STATIC const mp_obj_type_t uhashlib_sha1_type = {
STATIC const mp_rom_map_elem_t mp_module_uhashlib_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uhashlib) },
+ #if MICROPY_PY_UHASHLIB_SHA256
{ MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&uhashlib_sha256_type) },
+ #endif
#if MICROPY_PY_UHASHLIB_SHA1
{ MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&uhashlib_sha1_type) },
#endif
@@ -190,6 +196,8 @@ 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
diff --git a/py/mpconfig.h b/py/mpconfig.h
index a85b22128..08d100549 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -1155,6 +1155,14 @@ typedef double mp_float_t;
#define MICROPY_PY_UHASHLIB (0)
#endif
+#ifndef MICROPY_PY_UHASHLIB_SHA1
+#define MICROPY_PY_UHASHLIB_SHA1 (0)
+#endif
+
+#ifndef MICROPY_PY_UHASHLIB_SHA256
+#define MICROPY_PY_UHASHLIB_SHA256 (1)
+#endif
+
#ifndef MICROPY_PY_UBINASCII
#define MICROPY_PY_UBINASCII (0)
#endif