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

Cannot invoke "org.bouncycastle.openpgp.PGPEncryptedData$TruncatedStream.getLookAhead()" because "this.truncStream" is null #1914

Open
singpolyma opened this issue Nov 17, 2024 · 1 comment

Comments

@singpolyma
Copy link

Using https://github.com/bcgit/bc-java/blob/main/pg/src/main/java/org/bouncycastle/openpgp/examples/PBEFileProcessor.java to decrypt an SEKv6+SEIPv2 message generated by bouncycastle, it works except that I get this exception after the file is successfully written:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.bouncycastle.openpgp.PGPEncryptedData$TruncatedStream.getLookAhead()" because "this.truncStream" is null
	at org.bouncycastle.openpgp.PGPEncryptedData.verify(Unknown Source)
	at org.bouncycastle.openpgp.examples.PBEFileProcessor.decryptFile(Unknown Source)
	at org.bouncycastle.openpgp.examples.PBEFileProcessor.decryptFile(Unknown Source)
	at org.bouncycastle.openpgp.examples.PBEFileProcessor.main(Unknown Source)

As far as I can tell https://github.com/bcgit/bc-java/blob/main/pg/src/main/java/org/bouncycastle/openpgp/PGPEncryptedData.java#L227 should be true and so verify should return before getting to the getLookAhead call but it seems that is not happening for some reason.

This is with version 1.77

@vanitasvitae
Copy link
Contributor

vanitasvitae commented Nov 20, 2024

This was fixed with c6c45d3#diff-83881d5485ba95e07b97362e957d08ea04fe479d7ed772db5c8db5336d1545d8R186-R197

As a workaround, you can avoid calling PGPEncryptedData.verify() if you know you are working with a version 2 SEIPD packet.

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

No branches or pull requests

2 participants