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

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

Open
homps opened this issue Feb 3, 2022 · 2 comments · May be fixed by #67
Open

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

homps opened this issue Feb 3, 2022 · 2 comments · May be fixed by #67

Comments

@homps
Copy link

homps commented Feb 3, 2022

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):**

  • Version 2.3.0

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

homps added a commit to homps/bouncy-gpg that referenced this issue Feb 3, 2022
Nesting inputstreams can result in a child stream reaching its end twice.
For the MDCValidatingInputStream this results in verifying the MDC twice.
PGPEncryptedData#verify doesn't handle being called twice.

Fix with a simple boolean flag to prevent double verification.
homps added a commit to homps/bouncy-gpg that referenced this issue Feb 3, 2022
Nesting inputstreams can result in a child stream reaching its end twice.
For the MDCValidatingInputStream this results in verifying the MDC twice.
PGPEncryptedData#verify doesn't handle being called twice.

Fix with a simple boolean flag to prevent double verification.
homps added a commit to homps/bouncy-gpg that referenced this issue Feb 3, 2022
Nesting inputstreams can result in a child stream reaching its end twice.
For the MDCValidatingInputStream this results in verifying the MDC twice.
PGPEncryptedData#verify doesn't handle being called twice.

Fix with a simple boolean flag to prevent double verification.
homps added a commit to homps/bouncy-gpg that referenced this issue Feb 3, 2022
Nesting inputstreams can result in a child stream reaching its end twice.
For the MDCValidatingInputStream this results in verifying the MDC twice.
PGPEncryptedData#verify doesn't handle being called twice.

Fix with a simple boolean flag to prevent double verification.
@homps homps linked a pull request Feb 3, 2022 that will close this issue
@WayneShifu
Copy link

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

@homps
Copy link
Author

homps commented Oct 13, 2023

That would be up to @neuhalje

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 a pull request may close this issue.

2 participants