bcgit / pc-dart

Pointy Castle - Dart Derived Bouncy Castle APIs
MIT License
237 stars 122 forks source link

OAEP bug fix for non-deterministically failing on decryption #11

Closed hoylen closed 4 years ago

hoylen commented 4 years ago

Bug fix for "RSA with OAEP fails nondeterministically" issue (reported at https://github.com/PointyCastle/pointycastle/issues/177 on the old repository before the management of Pointy Castle was moved over to under the Bouncy Castle project).

This also solves the mystery of the redundant code from Bouncy Castle. Bouncy Castle's RSA decryption method returns a new array and the code then copied it into a new block. Pointy Castle creates a block and passes it into the RSA decryption method to populate, so no copying was/is required. But the Bouncy Castle code does more than just copying the bytes: it is also taking care of the situation when the decrypted bytes is shorter than expected.

Note: the encryption code was correct. Only the decryption code had a bug.

mwcw commented 4 years ago

Thanks for the contribution.

This PR has been merged with some additional tests.

Thanks again

MW