Discuss this help topic in SecureBlackbox Forum

Sign the data (common)

To sign the data using PGP algorithms, you need to use TElPGPWriter class.

First you need to specify the keys, which will be used for signing. This is done by setting the SigningKeys property of TElPGPWriter class to reference the instance of TElPGPKeyring class, which contains the keys. Note, that all keys will be used for signing, so if your keyring contains more keys, than you plan to use, then you need to copy the keys to other keyring. Remember, that when the data is signed, the private (secret, in PGP terms) keys are used, so you need to load the secret keyring to TElPGPKeyring.

When the keys are used the password for the key might be needed. TElPGPWriter asks the application for a password using OnKeyPassphrase event. You need to provide a handler for this event in order to supply TElPGPWriter with a password. Alternatively put the password to Passphrase property of the TElPGPSecretKey class.

To compress the data before signing, set Compress property of TElPGPWriter class to true. Compression doesn't work when you use clear-text signing.

If you want to "armor" the data (encode it to text using base64 format), set Armor property to true. Read more about armoring in the corresponding how-to article.

To specify the hashing algorithm use HashAlgorithm property of TElPGPWriter class. By default SHA1 hashing is used. Note, that older software doesn't support other algorithms.

Finally, call Sign() or ClearTextSign() method of TElPGPWriter class to process the data. ClearTextSign() creates a text signature over clear text data, without armoring or compressing the data before signing.

Detached parameter of Sign() method is used to create detached signatures. The detached signature doesn't contain the data being signed.

To sign and encrypt the data in one operation, use EncryptAndSign() method of TElPGPWriter class. Before calling this method, read the corresponding how-to article.

If you want the saved data to be readable using old PGP software (PGP 2.6, old versions of GnuPG etc.) you need to save the data in old format. To do this, set UseOldPackets property of TElPGPWriter class to true and UseNewFeatures property of TElPGPWriter to false. Set these properties before calling Sign() or ClearTextSign() method.

How To articles about file encryption and signing with OpenPGP

Discuss this help topic in SecureBlackbox Forum