Constructor
new SecretSubkeyPacket(dateopt, configopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
date |
Date |
<optional> |
Creation date |
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Extends
Members
aead :String
AEAD algorithm
Type:
- String
- Overrides:
- Source:
algorithm :String
Public key algorithm.
Type:
- String
- Overrides:
- Source:
created :Date
Key creation date.
Type:
- Date
- Overrides:
- Source:
expirationTimeV3 :Integer
Time until expiration in days (V3 only)
Type:
- Integer
- Overrides:
- Source:
fingerprint :String
Fingerprint in lowercase hex
Type:
- String
- Overrides:
- Source:
isEncrypted
Indicates whether secret-key data is encrypted. this.isEncrypted === false
means data is available in decrypted form.
- Overrides:
- Source:
keyid :module:type/keyid~Keyid
Keyid
Type:
- Overrides:
- Source:
keyMaterial
Secret-key data
- Overrides:
- Source:
privateParams :Object
Decrypted private parameters, referenced by name
Type:
- Object
- Overrides:
- Source:
publicParams :Object
Algorithm specific public params
Type:
- Object
- Overrides:
- Source:
readPublicKey
Alias of read()
- Overrides:
- Source:
- See:
s2k :type/s2k
S2K object
Type:
- type/s2k
- Overrides:
- Source:
s2k_usage :Integer
S2K usage
Type:
- Integer
- Overrides:
- Source:
symmetric :String
Symmetric algorithm
Type:
- String
- Overrides:
- Source:
tag :module:enums.packet
Packet type
Type:
- Overrides:
- Source:
version :Integer
Packet version
Type:
- Integer
- Overrides:
- Source:
writePublicKey
Alias of write()
- Overrides:
- Source:
- See:
Methods
clearPrivateParams()
Clear private key parameters
- Overrides:
- Source:
(async) decrypt(passphrase)
Decrypts the private key params which are needed to use the key. SecretKeyPacket.isDecrypted should be false, as otherwise calls to this function will throw an error.
Parameters:
Name | Type | Description |
---|---|---|
passphrase |
String | The passphrase for this private key as string |
- Overrides:
- Source:
Throws:
-
if decryption was not successful
- Type
- Error
(async) encrypt(passphrase, configopt)
Encrypt the payload. By default, we use aes256 and iterated, salted string to key specifier. If the key is in a decrypted state (isEncrypted === false) and the passphrase is empty or undefined, the key will be set as not encrypted. This can be used to remove passphrase protection after calling decrypt().
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
passphrase |
String | ||
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Overrides:
- Source:
Throws:
-
if encryption was not successful
- Type
- Error
getAlgorithmInfo() → {Object}
Returns algorithm information
- Overrides:
- Source:
Returns:
An object of the form {algorithm: String, bits:int, curve:String}.
- Type
- Object
getCreationTime() → {Date}
Returns the creation time of the key
- Overrides:
- Source:
Returns:
- Type
- Date
getFingerprint() → {String}
Calculates the fingerprint of the key
- Overrides:
- Source:
Returns:
A string containing the fingerprint in lowercase hex.
- Type
- String
getFingerprintBytes() → {Uint8Array}
Calculates the fingerprint of the key
- Overrides:
- Source:
Returns:
A Uint8Array containing the fingerprint.
- Type
- Uint8Array
getKeyId() → {module:type/keyid~Keyid}
Calculates the key id of the key
- Overrides:
- Source:
Returns:
A 8 byte key id.
hasSameFingerprintAs() → {Boolean}
Calculates whether two keys have the same fingerprint without actually calculating the fingerprint
- Overrides:
- Source:
Returns:
Whether the two keys have the same version and public key data.
- Type
- Boolean
isDecrypted() → {Boolean|null}
Check whether secret-key data is available in decrypted form. Returns false for gnu-dummy keys and null for public keys.
- Overrides:
- Source:
Returns:
- Type
- Boolean | null
isDummy() → {Boolean}
Check whether this is a gnu-dummy key
- Overrides:
- Source:
Returns:
- Type
- Boolean
makeDummy(configopt)
Remove private key material, converting the key to a dummy one. The resulting key cannot be used for signing/decrypting but can still verify signatures.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Overrides:
- Source:
read(bytes)
Internal parser for private keys as specified in RFC4880bis-04 section 5.5.3
Parameters:
Name | Type | Description |
---|---|---|
bytes |
String | Input string to read the packet from |
- Overrides:
- Source:
(async) validate()
Checks that the key parameters are consistent
- Overrides:
- Source:
Throws:
-
if validation was not successful
- Type
- Error
write() → {Uint8Array}
Creates an OpenPGP key packet for the given key.
- Overrides:
- Source:
Returns:
A string of bytes containing the secret key OpenPGP packet.
- Type
- Uint8Array
writeForHash()
Write packet in order to be hashed; either for a signature or a fingerprint.
- Overrides:
- Source: