SCENARIO:
We are using micropython ESP32 with this micropython release: esp32spiram-idf3-20200902-v1.13.bin
PROBLEM:
We are looking a way to encrypt and decrypt a string using public/privet keys, and we found your example on github.
Unfortunately, it seems that doesn't work, and we cannot understand why. Can you help us?
>>> res = rsa.decrypt(crypto, priv_key)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "third_party/rsa/pkcs1.py", line 239, in decrypt
DecryptionError: Decryption failed
TEST 3:
Now trying in binary. Fails again.
>>> crypto = rsa.encrypt(b'\x00\x00\x00\x00\x01', pub_key)
>>> rsa.decrypt(crypto, priv_key)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "third_party/rsa/pkcs1.py", line 239, in decrypt
DecryptionError: Decryption failed
>>> len(crypto) == rsa.common.byte_size(pub_key.n)
True
>>>
Looking at your code, it seems that the cause is because the 'decrypted clear text' doesn't start with: x00 x02, but we don't know why..
# If we can't find the cleartext marker, decryption failed.
if cleartext[0:2] != b'\x00\x02':
raise DecryptionError('Decryption failed')
I have the same issue described above. Nothing decrypts properly after I encrypt it. I used the examples in the code itself and decryption still failed.
Hello Team,
SCENARIO: We are using micropython ESP32 with this micropython release: esp32spiram-idf3-20200902-v1.13.bin
PROBLEM: We are looking a way to encrypt and decrypt a string using public/privet keys, and we found your example on github. Unfortunately, it seems that doesn't work, and we cannot understand why. Can you help us?
TEST 1: Encrypt. It's seems that it works..
TEST 2: Decrypt the 'hello' encrypted.
TEST 3: Now trying in binary. Fails again.
Looking at your code, it seems that the cause is because the 'decrypted clear text' doesn't start with: x00 x02, but we don't know why..