Rpi pico - SHA1ving the yack with micropython RP2040

So for those of you wondering how to get sha1 back in (u)hashlib on the rp2 port, it can be enabled by defining MICROPY_PY_UHASHLIB_SHA1 in 'ports/rp2/mpconfigport.h', after the #include directives (l.36)
, i.e :

[...]
#include "pico/multicore.h"
#include "mpconfigboard.h"

#define MICROPY_PY_UHASHLIB_SHA1 (1)
// alternatively, use
//  #define MICROPY_PY_NETWORK          (1)  
// for a full network stack ( adds ~145KB to firmware file size )

// Board and hardware specific configuration
[...]

then compile according to the instructions in raspberry-pi-pico-python-sdk.pdf, chapter 1.3.

The resulting filesize with only SHA1 enabled is ~10KB more.

For convenience, a pre-compiled firmware for the Rpi Pico with sha1 available in hashlib is hosted here :

MicroPython_v1.19.1-782-g699477d12-dirty_2022-12-23.uf2
sha1sum : 079d695acfbaec80261b9e2c6127f63580ebe25e
sha256sum : 9cfc1013015096f71420b56339aa3405d1f5ae6cd563149a6e9db06af4adeb10
md5sum : 85d433f5d0516b411ee28bf14d27fe11

Of course, don't use SHA1 for new stuff as it's deprecated, etc.

0 comments

Write a comment