Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Get rsa.decrypt working #17

Merged
merged 4 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
project.pico-go
project.pico-go
__pycache__
5 changes: 4 additions & 1 deletion lib/third_party/rsa/pkcs1.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,11 @@ def decrypt(crypto, priv_key):
decrypted = priv_key.blinded_decrypt(encrypted)
cleartext = transform.int2bytes(decrypted, blocksize)

## The test for b'\x00\x02' was always failing :(
## Seems what we actually get is b' \x02'
## A space instead of a null
# If we can't find the cleartext marker, decryption failed.
if cleartext[0:2] != b'\x00\x02':
if not ((cleartext[0:2] == b'\x00\x02') | (cleartext[0:2] == b' \x02')):
raise DecryptionError('Decryption failed')

# Find the 00 separator between the padding and the message
Expand Down