Constructor
new PrivateKey(packetlist)
Parameters:
Name | Type | Description |
---|---|---|
packetlist |
PacketList | The packets that form this key |
- Source:
Methods
(async) addSubkey() → {Promise.<PrivateKey>}
Generates a new OpenPGP subkey, and returns a clone of the Key object with the new subkey added. Supports RSA and ECC keys, as well as the newer Curve448 and Curve25519. Defaults to the algorithm and bit size/curve of the primary key. DSA primary keys default to RSA subkeys.
Parameters:
Name | Type | Description |
---|---|---|
options.type |
ecc | rsa | curve25519 | curve448 | The subkey algorithm: ECC, RSA, Curve448 or Curve25519 (new format). Note: Curve448 and Curve25519 are not widely supported yet. |
options.curve |
String | (optional) Elliptic curve for ECC keys |
options.rsaBits |
Integer | (optional) Number of bits for RSA subkeys |
options.keyExpirationTime |
Number | (optional) Number of seconds from the key creation time after which the key expires |
options.date |
Date | (optional) Override the creation date of the key and the key signatures |
options.sign |
Boolean | (optional) Indicates whether the subkey should sign rather than encrypt. Defaults to false |
options.config |
Object | (optional) custom configuration settings to overwrite those in config |
- Source:
Returns:
- Type
- Promise.<PrivateKey>
armor(configopt) → {ReadableStream.<String>}
Returns ASCII armored text of key
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
ASCII armor.
- Type
- ReadableStream.<String>
clearPrivateParams()
Clear private key parameters
- Source:
(async) getDecryptionKeys(keyID,, date,, userID,, configopt) → {Promise.<Array.<(Key|Subkey)>>}
Returns all keys that are available for decryption, matching the keyID when given This is useful to retrieve keys for session key decryption
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keyID, |
module:type/keyid~KeyID | optional |
|
date, |
Date | optional |
|
userID, |
String | optional |
|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Throws:
-
if no decryption key is found
- Type
- Error
Returns:
Array of decryption keys.
- Type
- Promise.<Array.<(Key|Subkey)>>
isDecrypted()
Returns true if the primary key or any subkey is decrypted. A dummy key is considered encrypted.
- Source:
isPrivate() → {Boolean}
Returns true if this is a private key
- Source:
Returns:
- Type
- Boolean
(async) revoke(reasonForRevocation, date, configopt) → {Promise.<PrivateKey>}
Revokes the key
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
reasonForRevocation |
Object | optional, object indicating the reason for revocation Properties
|
||||||||||
date |
Date | optional, override the creationtime of the revocation signature |
||||||||||
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New key with revocation signature.
- Type
- Promise.<PrivateKey>
toPublic() → {PublicKey}
Returns key as public key (shallow copy)
- Source:
Returns:
New public Key
- Type
- PublicKey
(async) validate(configopt)
Check whether the private and public primary key parameters correspond Together with verification of binding signatures, this guarantees key integrity In case of gnu-dummy primary key, it is enough to validate any signing subkeys otherwise all encryption subkeys are validated If only gnu-dummy keys are found, we cannot properly validate so we throw an error
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Throws:
-
if validation was not successful and the key cannot be trusted
- Type
- Error