PGPKey Type
This container represents a PGP key.
Remarks
OpenPGP standard supports several types of keys. In our days, a typical OpenPGP keypair actually consists of two cryptographic keys: a primary key and a subkey. The primary key is normally used for signing, while the subkey is used for encryption.
While it is typical for PGP environments to use a primary key/subkey bundle, this is not a must. Sometimes you may come across standalone keys (mainly when dealing with older implementations), as well as whole key trees, each of those carrying a bunch of differently-purposed subkeys bound to the same primary key.
Algorithm-wise, OpenPGP keys also differ. Generally speaking, OpenPGP supports the following public key algorithms: RSA, Elgamal (often incorrectly referred to as DH), DSA, ECDH and ECDSA. When it comes to primary key/subkey bundles, DSA/Elgamal, RSA/RSA and ECDSA/ECDH pairs are typically used. Although there's no restriction on algorithm bundles, and, e.g. a ECDSA/Elgamal key bundle is perfectly possible, such combination is rarely used in practice.
A typical OpenPGP key is associated with some kind of user ID (Username). It is normally represented with a user's e-mail address, while in theory can be any piece of text. The secret part of the OpenPGP keypair is protected with a password (Passphrase).
Fields
BitsInKey int |
Indicates the key length in bits. | |||||||||||||||||||||
CanEncrypt boolean |
Returns True if this key can be used for encryption. | |||||||||||||||||||||
CanSign boolean |
Returns True if this key can be used for signing. | |||||||||||||||||||||
Curve String |
Indicates the elliptic curve associated with a EC key. Supported values:
| |||||||||||||||||||||
Enabled boolean |
Enables or disables this key for use in encryption or signing operation. | |||||||||||||||||||||
EncryptionAlgorithm String |
Indicates the symmetric algorithm used to encrypt the secret key. | |||||||||||||||||||||
Expires int |
Indicates key expiration time in whole days from its generation moment. The value of 0 indicates that the key does not expire. | |||||||||||||||||||||
HashAlgorithm String |
Specifies the hash algorithm associated with the key. | |||||||||||||||||||||
IsPublic boolean |
Returns True if this key is a public key, and False otherwise. | |||||||||||||||||||||
IsSecret boolean |
Returns True if this key is a secret key, and False otherwise. | |||||||||||||||||||||
IsSubkey boolean |
Returns True if this key is a subkey of another key, and False otherwise. | |||||||||||||||||||||
KeyFP String |
The 20-byte fingerprint (hash value) of this key. KeyFP could be used to distinguish two keys with the same KeyID. | |||||||||||||||||||||
KeyHashAlgorithm String |
Specifies the hash algorithm used with DSA keys to calculate signatures. | |||||||||||||||||||||
KeyID String |
Contains a 8-byte key identifier. It is quite rare that IDs of two keys collide. If that happens, their fingerprints (KeyFP) can be used for distinguish between the keys. Please note that many PGP implementations show only 4 lowest bytes of the KeyID to the user. | |||||||||||||||||||||
OldPacketFormat boolean |
Indicates whether legacy (PGP 2.6.x) packet format should be used. | |||||||||||||||||||||
Passphrase String |
The key protection password. | |||||||||||||||||||||
PassphraseValid boolean |
Use this property to check whether the specified Passphrase is valid and can be used to unlock the secret key. | |||||||||||||||||||||
PrimaryKeyID String |
If this key is a subkey (IsSubkey returns True), this field contains the identifier of the subkey's primary key. | |||||||||||||||||||||
Protection int |
Specifies the level of protection applied to the secret key. Allowed values:
| |||||||||||||||||||||
PublicKeyAlgorithm String |
Specifies the asymmetric algorithm of the key. | |||||||||||||||||||||
QBits int |
The length of the DSA Q (legitimate range: 160-512). This parameter corresponds to the hash algorithm used with the key. For example, if the value of Q is 256, SHA-256 will be used. | |||||||||||||||||||||
Revoked boolean |
Returns True if the key has been revoked, and False otherwise. | |||||||||||||||||||||
SubkeyFP String |
The 20-byte fingerprint (hash value) of this key's subkey. KeyFP could be used to distinguish two subkeys with the same SubkeyID. | |||||||||||||||||||||
SubkeyID String |
Contains a 8-byte subkey identifier. It is quite rare that IDs of two keys collide. If that happens, their fingerprints (SubkeyFP) can be used to distinguish between the keys. Please note that many PGP implementations show only 4 lowest bytes of the KeyID to the user. | |||||||||||||||||||||
Timestamp String |
Use this property to check the time the key was generated. The date and time are stored and retrieved in Universal Coordinate Time (UTC). | |||||||||||||||||||||
Username String |
Specifies the name of the user bound to this key. The PGP username is typically represented with a full name and an email address, but generally can be any non-empty string. | |||||||||||||||||||||
Valid int |
Indicates the validity status of the key.
| |||||||||||||||||||||
Version int |
Indicates the key version. The key version refers to the version of the public-key packet format as defined in RFC 4880. Only two versions are currently allowed here: 3 and 4. It is recommended that all new keys are created with version of 4. |
Constructors
public PGPKey();
Creates an empty PGP key object.
public PGPKey(String filename);
Create a PGP key object from a key file.