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

OpenPGP - Partial length encoding: Enforce minimum length of the first chunk #1828

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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