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

Feature support old format (PGP 2.6.x) #205

Closed
wants to merge 1 commit into from

Conversation

magks
Copy link

@magks magks commented Mar 29, 2023

Legacy applications may need support for PGP 2.6.x.

BouncyCastle PgpLiteralDataGenerator supports PGP 2.6.x via a constructor taking a bool useOldFormat. Adding support in PgpCore to use that flag by adding a bool property to PGP class UseOldFormat (default false), and a bool arg useFormat to Utilties Write*LiteralData methods with a default value of false to not break any public usage of the methods.

( See https://github.com/neoeinstein/bouncycastle/blob/master/crypto/src/openpgp/PgpLiteralDataGenerator.cs )
PgpLiteralDataGenerator.cs:
///


/// Generates literal data objects in the old format.
/// This is important if you need compatibility with PGP 2.6.x.
///

/// If true, uses old format.
public PgpLiteralDataGenerator(
bool oldFormat)
{
this.oldFormat = oldFormat;
}

PgpLiteralDataGenerator has a constructor that takes a bool indicating whether to use old format.
If true, it generates literal data objects in the old format. /// This is important if you need compatibility with PGP 2.6.x.

Added bool value, useOldFormat, to all relevant utilities methods constructing PgpLiteralDataGenerator object. Some of methods that instantiate the PgpLiteralDataGenerator don't use the Open() method that can use the old format, so not adding the arg for those utility methods. Default value false to not break any current client usage of the Utilities class. useOldFormat passed to the PgpLiteralDataGenerator constructor.

Add property UseOldFormat, pass to WriteStreamToLiteralData

BouncyCastle's PgpLiteralDataGenerator has a constructor that takes a bool indicating whether or not to use "oldFormat". This can be set to true to support 2.6.x version of PGP. Including support for this in PgpCore by adding a bool property UseOldFormat  to PGP class defaulting to false. Encrypt methods passes UseOldFormat as an argument to Utilities.WriteStreamToLiteralData which wraps the call to the PgpLiteralDataGenerator constructor.
@magks magks force-pushed the feature-support-old-packets branch from 7d4b573 to 6086382 Compare March 30, 2023 05:02
@magks
Copy link
Author

magks commented Mar 31, 2023

I just made this PR to illustrate how the support might be added and start a conversation about it. I was tasked with replacing a proprietary PGP package and I was looking into this one. I believe we require the old format support and was investigating how it could be added. I saw it there was a simple way, so requesting support to be added.

I see there is a failed check in my PR. I'm not sure if its related to my changes. I will look into it and fix it if so. But any word from maintainers on whether old format support like in this PR would be added would be much appreciated.

@mattosaurus
Copy link
Owner

Hi,

Thanks for submitting this, I hadn't realised there were issues with historical formats.

I think there's an issue with the threading of the tests that causes them to fail sometimes. I'll re-run and hope it passes this time.

I'll take a look at the PR in more detail next week when I've got some more free time.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mattosaurus
Copy link
Owner

Sorry for the delay in this. I've added this as an option in v6.2.0

@mattosaurus mattosaurus closed this Dec 8, 2023
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.

2 participants