Discuss this help topic in SecureBlackbox Forum
Unprotect an OpenPGP file
As you rarely know what kind of data (encrypted, signed, compressed, or armored) your encoded stream contains,
TElPGPReader class attempts to perform all operations within one method call.
When processing the data, TElPGPReader extracts certain information from the encoded data.
It notifies the application about this information via its events such as
OnArmored,
OnCompressed,
OnEncrypted, and
OnSigned.
These events are informational and used for notification only.
To decrypt and verify the data perform the following operations:
-
Create an instance of TElPGPKeyring class.
This class will hold the keys used to decrypt or verify the data.
Remember, that if you expect the data to be both signed and encrypted, you need to create 2 different keyrings (see below).
-
Load the keys into the keyring using Load() method of TElPGPKeyring class.
If you use the keys for decryption, you need to load only private keyring.
If you use the keys for signature verification, you only need public keys.
-
Set DecryptingKeys property of TElPGPReader class if you expect to perform decryption.
In most cases, you only need private keys to perform decryption, however, in certain situations the public keyring is also needed to show the signer details, as UserID packets might be missing in the secret keyring.
-
If you know, that the encoded data is encrypted with the key(s) and you know the password for the secret key(s) used,
you can set KeyPassphrase property of TElPGPReader class.
The alternative way is to create an event handler for OnKeyPassphrase event
of TElPGPReader class and ask the user for the secret key passphrase in the event handler.
-
If you know, that the encoded data was encrypted using the password(s), set
Passphrase property
of TElPGPReader class to the passphrase, suitable for data decryption.
The alternative way is to create an event handler for
OnPassphrase event of
TElPGPReader class and ask the user for the passphrase in the event handler.
-
Set VerifyingKeys property of TElPGPReader,
if you expect to perform signature verification.
-
(Optionally) create an event handler for OnSignatures event of TElPGPReader class.
This event is used by the component to inform the application about signature verification result.
-
Create a stream for the decoded data and set OutputStream property of TElPGPReader.
If you expect multiple data blocks (files) to be present, create an event handler for OnCreateOutputStream
event of TElPGPReader class and create the stream in the event handler.
-
Call DecryptAndVerify() method of TElPGPReader class.
Decryption and verification errors
-
No appropriate OpenPGP secret key for decryption found.
A correct private key is missing or the provided private key passphrase is invalid/not provided.
How To articles about file encryption and signing with OpenPGP
Discuss this help topic in SecureBlackbox Forum