Discuss this help topic in SecureBlackbox Forum
Access and modify information about the user of the key
Each key has at least one signature, and the first one is created when the key is generated.
Various key properties, such as user name, e-mail etc. (the complete list is present in RFC 2440) are written to the signature of the key.
The properties may characterize the key itself, the user of the key or the key's signature.
However, all of them are stored as extensions to some signature(s) which bind the user ID to the key.
To access the properties of the existing key, you need to do the following:
- use UserIDs[] property of the public key to access each of the available TElPGPUserID objects;
- use Signatures[] property of TElPGPUserID object to access individual signatures (instances of TElPGPSignature class);
- for each signature of each UserID you need to read all of the available extensions.
This is done by first getting the number of extensions using GetExtensionCount() method,
then by accessing the individual extensions via Extensions[] property;
- each extension is represented by the instance of some class, descendant of TElPGPSignatureSubpacket class.
To read the actual type of the extension, use SubpacketType property of TElPGPSignatureSubpacket class.
To read the actual extension properties, cast the object to the type determined by SubpacketType property.
To add extensions when the key is generated, you need to do the following:
- create an event handler for TElPGPSecretKey.OnBeforeSign event;
- the event handler receives the signatures as a parameter.
You need to add extensions to the signature, whose IsUserCertification() method returns true;
- to add one or more extensions use AddExtension() method of TElPGPSignature class.
How To articles about OpenPGP key management
Discuss this help topic in SecureBlackbox Forum