neuhalje / bouncy-gpg

Make using Bouncy Castle with OpenPGP fun again!
https://neuhalje.github.io/bouncy-gpg/
Other
205 stars 58 forks source link

File with valid MDC can fail MDC verification when stream is wrapped #66

Open homps opened 2 years ago

homps commented 2 years ago

Describe the bug Exception thrown ('Error while validating MDC') if MDC validation occurs twice, caused by nested InputStreams.

To Reproduce Wrap the decryptAndVerifyStream in an additional InputStream, reading to the end of that stream can cause MDCValidatingInputStream#read to be called twice. PGPEncryptedData#verify doesn't like being called twice, possibly due to the reuse of the integrityCalculator OutputStream (a guess).

Expected behavior Exception should not be thrown if MDC is valid, even if nested streams cause the validator to trigger twice.

System (please complete the following information):

Additional context I've got an example trivial fix, will raise a PR for consideration shortly. Thanks!

WayneShifu commented 11 months ago

Any way to merge this PR. I am facing the same issue here.

homps commented 11 months ago

That would be up to @neuhalje