Skip to content

Conversation

vanitasvitae
Copy link
Contributor

The OpenPGP specification mandates that if partial body encoding is used, the first chunk must be at least 512 bytes long.
Currently, BC does not enforce this requirement (see https://tests.sequoia-pgp.org/#Tests_support_for_partial_body_encoding )

This PR adds a check for this requirement, which will throw an IOException for malformed packets.

@vanitasvitae
Copy link
Contributor Author

vanitasvitae commented Sep 10, 2024

This patch currently breaks with a (broken) test vector from BcPGPPBETest.
I'm thinking of ways to make the chunk length check configurable to allow parsing of such broken messages.

Edit: Apparently there are more broken test vectors, and it appears to be easily possible to generate broken messages via too short partial encoding.
Therefore, preventing generation of broken messages should probably have a higher priority than rejecting broken messages during consumption.
I'll think of a way to fix this without breaking backwards-compatibility.

@vanitasvitae vanitasvitae marked this pull request as draft September 10, 2024 14:12
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 this pull request may close these issues.

1 participant