pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
196 stars 167 forks source link

ucrypto.generate_rsa_signature() gives ValueError: Invalid Private Key, error code: -4480 #545

Open BetterAutomations opened 3 years ago

BetterAutomations commented 3 years ago

Please include the following information when submitting a bug report:

I then did some testing on various firmware. The ucrypto.generate_rsa_signature() function is failing on firmware greater than 1.20.0.rc13.

When I tried on that firmware, I see the correct output:

>>> pk = open('cert/WiPy2-pk8.key').read()
>>> import ucrypto
>>> ucrypto.generate_rsa_signature("Hello world", pk)
b'\x04\xac\xa6\xedo\xca\xc6\x88\xc9\x14h\xbd}\x10\x8dD%\x96E\xf6A.Y> \xf3\x18\x83\x99\x1c\xa4(..)\x05\x80\x04\x04|'
>>>

I did a diff and found that esp32/mods/moducrypto.c had indeed been changed in newer versions, specifically having to do with mod_pycom_generate_rsa_signature. But I don't know enough C to tell you why what had changed is having this effect.

Here is some forum discussion I've had on it: https://forum.pycom.io/topic/7022/mqtt-with-ssl-gives-error-oserror-4480?_=1620323774849

Thank you!