Customizing PGP Version Header in OpenPGP Messages
When generating OpenPGP messages, a Version header is automatically included to indicate the originating software. By default, this value is set by the component and appears in the output message.
-----BEGIN PGP MESSAGE-----
Version: IPWorks OpenPGP 2020
yMC1ATXKTUhaAQAA4OdPhppMG2SluWgSdTAlC9NGEFGGYjELKn8mPFSsnhluTKGD
lDsElhQ2pxQkQTkmG1kHCwKHFSZqYIqBEVQgRRmRBZHzrejQ+ft2CCgAifAxLW/8
YpcHESaBgDhno2lUEKSrNOj0kDLwV4YGEEgAU4B8EQCHJb72j6ZCuJQKm4fQKuXe
vf3gsr6B+3/wrA08T/dcdrocsfFkmX9+LHi9lISrIu3MPQ6XmLKzWjq62JyB+In6
V+vy3ETUeGHtM/5Ufvl+LjOpqQq/c/o0W00kHQ78/sSuY1B0K6mNEsPC6DxLsBXi
f3ZvUDZvmnxk8q0Iq/GohAHryKo+T5HTF2El5mi/keAUhgBvwpmpBeNhhgisUUD4
oD2znja/c0w+LX8zo3BX2h+8u2iUnv/Hp3mb3TxcBFXxVbrY+7ZoJjt5XD4seSi2
kSS73e+1/QlpdXoNkl0zi7C+wB+BxaYwgjE5/lG7ndsVdcxOfTh4Bg==
=9b/T
-----END PGP MESSAGE-----
The VersionHeader configuration setting allows this value to be overridden with a user-defined string, enabling the message to identify your application instead of the default component value. For example:
//C#
Key key = new Key("C:\\MyKeyring", "myuser@mail.com");
key.Passphrase = "password";
pgp.Keys.Add(key);
pgp.InputMessage = "hello world";
pgp.Config("VersionHeader=My Application");
pgp.ASCIIArmor = true;
pgp.Sign();
String encryptedMsg = pgp.OutputMessage;
After setting this option, the generated message will include the custom Version header:
-----BEGIN PGP MESSAGE-----
Version: My Application
yMCyATXKQUhaAQAA0P9/1nLwLaEOIR+UrIh0QgexrxSjg3QwNjtkaJ80C7HfxCQ6
FSFFzCGVHqICcQxFMQix1LTWMHWrJIsioZWbGoGgQmJRUjk67PxeEC4DINDD+lK1
KzQ7wEOyDBAWjQXFEI6rqBOqMVwe+CEhACAEVJRDrwK8JVb/79ajNyXFmeZ9iNU/
yxWM/vmlTeW8W/5QmZqKxsgMhLi/xvcundDyQubftCJQFFlQJxPhtsGS7J4rO11K
opGPL3QTTXqvbDSxufVwC8YY0aXjOt5Ow20LRrwLXiXqeE9zfZCFDRO0pJkk+Ey5
WRnK8/Lou5+nx8qo7/JTFz65aGtOdthr7hd2ozHNwTf/V2Ste2AqLmIO/x5vM1vF
KWzDLsh9UBaQTnlgfn1Qv+yu8zVpMu7eCweL8nm1nSN1GOkP5zqnT2TgaGtJLm46
0urh94gphrA6Uwhj7O8Cvf42FKnctCHebRKEumQGNPGIXWv+AQ==
=yHVX
-----END PGP MESSAGE-----
This allows full control over how the originating application is represented in the PGP message header.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.