-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
When verify signature receive java.io.EOFException: Unexpected end of ZIP input stream #1577
Comments
Writing a PGP extension on top of Apache James server, using bouncyCastle 1.77 we encounter the very same issue. Downgrade to 1.70 solves the issue. An alternative could be |
Have done some investigation using older versions. I did not have to roll back so far, only to 1.71.1 for my code to work.
The release notes for version 1.72 indicate a change in the BZIP2 implementation. The release notes for version 1.73 indicate a change in the BCPGInputStream class. I wonder if the latter is the source of the problem I am encountering. |
Sorry to call you in. Need a bit of advice. The change of interest in the BCPGInputStream class for v1.73; in the readPacket() method, the general change was Hope you can help, Thanks. |
Hmm. Possibly, change should appear on github shortly, but try what's in https://www.bouncycastle.org/betas and let me know how it goes. |
Similar issue, works in 1.71.1 and earlier, fails afterwards... Tried the 1.78-SNAPSHOT without luck.
Caused by: java.io.EOFException: premature end of stream in PartialInputStream |
Looking at the stack traces these aren't using the BC zip library. Is it possible to provide something that reproduces the issue? I think the changes are coincidental, it's likely to be somewhere else. |
I could probably create a test case with the code that generated my stack trace. It will take a week or two, as I'll need clearance from the client to include some of their test data that helped generate the issue. I tried to grok the code base, but the commit history, and the vastness of the code base made this difficult to comprehend what is going on. |
I roughly do the same but still experience the problem. A couple of things to note from the example provided by @trondaks
Another thing of note, not yet mentioned, is that my test data was generated by Gnu PG (windows). |
In trying to get to a simple piece of code as part of a reproduction case I have solved my issue. I swapped the order things. Initially I had data integrity verification followed by signature verification. In swapping the order to signature verification followed by data integrity verification solved my issue. I thought I had tried this variation before. 😒 The stack trace I received was not helpful. Thanks for people input. |
@dghgit I would have thought that the questions: 'Has the data been tampered with? (data integrity)' and 'Has the message been sent by a know user? (signature verification)' would have been independant from each other. Conceptually I see it this way. Actual implementation may be different. I coded my solution from examples I found on the web. I adapted the code as I saw fit. It mostly worked. The example were very poorly documented, and I did not read any of the online supporting documentation from BC. The way I see it, from resolving my problem; it is the internal design of BC that has dictated the external usage of its API. That is signature verification needs to be done before data verification. If this is documented then it is so easily missed. The stack trace I encountered did not indicate the real cause of my problem. I was actually looking for the solution in an entirely different area. While the internal design of BC dictating external usage of its API may be considered poor practise; it may be because of other considerations such as algorthim, speed, memory, or other security considerations. What would have been helpful here is some sort if internal check, if possible, in the signature verification step that it's source data has not been altered, and if it is altered throw an informative excpetion early. I have suggested this tentative improvement because if internal design of BC dictates the external usage of its API then an informative exception when it is being use contray to expections would be helpful. |
I think we could better document this - the reason for it happening is because the BC PGP API is a streaming API, so order of events is tied in with the order of things as they appear in the PGP protocol. This allows the API to work with very large files, but on the other hand does introduce a level of eccentricity as order of operations really does matter. |
In verify the signer of a PGP encrypted message I receive the following stacktrace:
The message was decrypted successfully with the expected message. And it was verified correctly too.
The message had the expected
PGPOnePassSignatureList
block before thePGPLiteralData
block. It contained the ID of the expected signer.Using version 1.77 of the Bouncy Castle libraries.
Using a Java version of Temurin-11.0.22+7
The OS platform is MacOS using Sonoma 14.2.1
The text was updated successfully, but these errors were encountered: