OpenPGP Code Example: Support for PGP 6.5.8

PGP 6.5.8 can be supported via the AllowOldPacketType configuration setting.

Date Entered: 08/05/2016    Last Updated: 08/05/2016

By default the component will only encrypt data using the newer and more secure integrity protected data packet type. Old implementations such as PGP 6.5.8 may require the older less secure data packet type. Support for this can be enabled in the component via the AllowOldPacketType configuration setting.

When this is set to True the component will read the features from the recipient key to determine if the older packet type is required. If the key does require the old packet type, then the older packet type will be used. If the key does not require the old packet type, then the new integrity protected packet type will still be used.

This setting is false by default meaning under no conditions is the older, less secure, packet type used. The newer integrity protected packet type is always used.

// Encrypt using the old packet format pgp.Config("AllowOldPacketType=true"); pgp.InputMessage = inputMessage; pgp.RecipientKeys.Add(new Key(publicKey, "recipient@test.com")); pgp.OutputFile = outputFile; pgp.Overwrite = true; pgp.EncryptingAlgorithm = "CAST5"; pgp.Encrypt(); // Decrypt a message encrypted using the old packet format pgp.Config("AllowOldPacketType=true"); pgp.OutputFile = decryptedFile pgp.InputFile = encryptedFile; pgp.Keys.Add(new Key(privateKey, "recipient@test.com") { Passphrase = "test" }); pgp.Decrypt();

Note that version 6.5.8 of PGP does not support AES, which is the algorithm used by the components by default. Instead, CAST5, IDEA, or 3DES must be used. These can be set via the EncryptionAlgorithm property as shown in the sample code above.


We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.