← index #4119Issue #7881
Off-topic · high · value 0.098
QUERY · ISSUE

ESP32 SHA1 on uhashlib is not correct at 2nd or more times.

openby CUEICHIopened 2018-09-11updated 2021-05-25
extmod

I tried this, and result is not same at 1st time and 2nd or more.
is it a bug?

os.uname()
(sysname='esp32', nodename='esp32', release='1.9.4', version='v1.9.4-498-g5cd2c7f2e on 2018-09-09', machine='ESP32 module with ESP32')
import binascii, hashlib
hash = hashlib.sha1(b'mango')
binascii.hexlify(hash.digest())
b'934aae49f648ed870c9c421829f4cece6643cf86'
binascii.hexlify(hash.digest())
b'0ffd8d43b4e33c7c53461bd10f27a5461050d90d'
binascii.hexlify(hash.digest())
b'0ffd8d43b4e33c7c53461bd10f27a5461050d90d'

os.uname()
posix.uname_result(sysname='Darwin', nodename='rydeen.local', release='17.7.0', version='Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64', machine='x86_64')
import binascii, hashlib
hash = hashlib.sha1(b'mango')
binascii.hexlify(hash.digest())
b'934aae49f648ed870c9c421829f4cece6643cf86'
binascii.hexlify(hash.digest())
b'934aae49f648ed870c9c421829f4cece6643cf86'
binascii.hexlify(hash.digest())
b'934aae49f648ed870c9c421829f4cece6643cf86'

CANDIDATE · ISSUE

uhashlib module object has no attribute sha1

closedby ernesto75opened 2021-10-05updated 2023-02-17
port-rp2

When using the micropython port for rp2 board, and trying to use uhashlib.sha1(), it gives error: module object has no attribute sha1. Only sha256 is implemented. Please add sha1 in uhashlib as well. I also tried to compile micropython from source, editing the file /micropython/ports/rp2/mpconfigport.h By default only #define MICROPY_PY_UHASHLIB (1) is present; i tried to add #define MICROPY_PY_UHASHLIB_SHA1 (1) but the compiling process results in this error:
[ 4%] Building C object CMakeFiles/firmware.dir/pico/micropython/extmod/moduhashlib.c.obj
In file included from /pico/micropython/py/mpstate.h:35:0,
from /pico/micropython/py/runtime.h:29,
from /pico/micropython/extmod/moduhashlib.c:30:
/pico/micropython/extmod/moduhashlib.c:249:60: error: 'uhashlib_sha1_digest' undeclared here (not in a function); did you mean 'uhashlib_sha256_digest'?
STATIC MP_DEFINE_CONST_FUN_OBJ_1(uhashlib_sha1_digest_obj, uhashlib_sha1_digest);
^
/pico/micropython/py/obj.h:337:42: note: in definition of macro 'MP_DEFINE_CONST_FUN_OBJ_1'
{{&mp_type_fun_builtin_1}, .fun._1 = fun_name}
^~~~~~~~
/pico/micropython/extmod/moduhashlib.c:260:17: error: 'uhashlib_sha1_make_new' undeclared here (not in a function); did you mean 'uhashlib_sha256_make_new'?
.make_new = uhashlib_sha1_make_new,
^~~~~~~~~~~~~~~~~~~~~~
uhashlib_sha256_make_new
/pico/micropython/extmod/moduhashlib.c:171:17: error: 'uhashlib_sha1_update' used but never defined [-Werror]
STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg);
^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/firmware.dir/build.make:2219: CMakeFiles/firmware.dir/pico/micropython/extmod/moduhashlib.c.obj] Error 1

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied