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

pkcs1 fix #159

Merged
merged 3 commits into from
Sep 19, 2019
Merged

pkcs1 fix #159

merged 3 commits into from
Sep 19, 2019

Conversation

honzikpoul
Copy link

fix: pkcs1 returned Buffer object when data were invalid.

I found it when I tried to decrypt data with different padding type than i used during encryption. It was bug in my code. But the library returns invalid data instead of throw an error.

Your code contains some checks for this case, but there is AND instead of OR operator. My data had first byte 0 and second byte random value. In this case the condition failed.

I supose that the library have to throws an error, when first byte is not 0 and second is not 2 during decryption with padding pkcs1.

honzap added 3 commits September 10, 2019 13:47
… data has been encrypted with different padding type than was encrypted. The library correctly returned data instead of throw error)
…und when data has been encrypted with different padding type than was encrypted. The library correctly returned data instead of throw error)"

This reverts commit fb8f507.
… data has been encrypted with different padding type than was encrypted. The library correctly returned data instead of throw error)
@rzcoder
Copy link
Owner

rzcoder commented Sep 10, 2019

Hi! Thanks for PR! Could you please provide some tests for this case?

@honzikpoul
Copy link
Author

Hello, your current tests are working. I can try write some. But this is crazy case. And the problem was in usage of the library (encrypt with padding A, decrypt with padding B.).

I can try it :).

@rzcoder rzcoder merged commit ae3fe05 into rzcoder:master Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants