Constructor
new Message(packetlist)
Parameters:
Name | Type | Description |
---|---|---|
packetlist |
PacketList | The packets that form this message |
- Source:
Classes
Methods
(async, static) encryptSessionKey(sessionKey, algorithmName, aeadAlgorithmNameopt, encryptionKeysopt, passwordsopt, wildcardopt, encryptionKeyIDsopt, dateopt, userIDsopt, configopt) → {Promise.<Message>}
Encrypt a session key either with public keys, passwords, or both at once.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
sessionKey |
Uint8Array | session key for encryption |
||
algorithmName |
String | session key algorithm |
||
aeadAlgorithmName |
String |
<optional> |
AEAD algorithm, e.g. 'eax' or 'ocb' |
|
encryptionKeys |
Array.<PublicKey> |
<optional> |
Public key(s) for message encryption |
|
passwords |
Array.<String> |
<optional> |
For message encryption |
|
wildcard |
Boolean |
<optional> |
false | Use a key ID of 0 instead of the public key IDs |
encryptionKeyIDs |
Array.<module:type/keyid~KeyID> |
<optional> |
Array of key IDs to use for encryption. Each encryptionKeyIDs[i] corresponds to encryptionKeys[i] |
|
date |
Date |
<optional> |
Override the date |
|
userIDs |
Array |
<optional> |
User IDs to encrypt for, e.g. [{ name:'Robert Receiver', email:'robert@openpgp.org' }] |
|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with encrypted content.
- Type
- Promise.<Message>
(async, static) generateSessionKey(encryptionKeysopt, dateopt, userIDsopt, configopt) → {Promise.<{data: Uint8Array, algorithm: String, aeadAlgorithm: (undefined|String)}>}
Generate a new session key object, taking the algorithm preferences of the passed encryption keys into account, if any.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
encryptionKeys |
Array.<PublicKey> |
<optional> |
Public key(s) to select algorithm preferences for |
date |
Date |
<optional> |
Date to select algorithm preferences at |
userIDs |
Array.<Object> |
<optional> |
User IDs to select algorithm preferences for |
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
Object with session key data and algorithms.
- Type
- Promise.<{data: Uint8Array, algorithm: String, aeadAlgorithm: (undefined|String)}>
(async) appendSignature(detachedSignature, configopt)
Append signature to unencrypted message object
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
detachedSignature |
String | Uint8Array | The detached ASCII-armored or Uint8Array PGP signature |
|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
armor(configopt) → {ReadableStream.<String>}
Returns ASCII armored text of message
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
ASCII armor.
- Type
- ReadableStream.<String>
compress(algo, configopt) → {Message}
Compresses the message (the literal and -if signed- signature data packets of the message)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
algo |
module:enums.compression | compression algorithm |
|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with compressed content.
- Type
- Message
(async) decrypt(decryptionKeysopt, passwordsopt, sessionKeysopt, dateopt, configopt) → {Promise.<Message>}
Decrypt the message. Either a private key, a session key, or a password must be specified.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
decryptionKeys |
Array.<PrivateKey> |
<optional> |
Private keys with decrypted secret data |
passwords |
Array.<String> |
<optional> |
Passwords used to decrypt |
sessionKeys |
Array.<Object> |
<optional> |
Session keys in the form: { data:Uint8Array, algorithm:String, [aeadAlgorithm:String] } |
date |
Date |
<optional> |
Use the given date for key verification instead of the current time |
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with decrypted content.
- Type
- Promise.<Message>
(async) decryptSessionKeys(decryptionKeysopt, passwordsopt, expectedSymmetricAlgorithmopt, dateopt, configopt) → {Promise.<Array.<{data: Uint8Array, algorithm: String}>>}
Decrypt encrypted session keys either with private keys or passwords.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
decryptionKeys |
Array.<PrivateKey> |
<optional> |
Private keys with decrypted secret data |
passwords |
Array.<String> |
<optional> |
Passwords used to decrypt |
expectedSymmetricAlgorithm |
enums.symmetric |
<optional> |
The symmetric algorithm the SEIPDv2 / AEAD packet is encrypted with (if applicable) |
date |
Date |
<optional> |
Use the given date for key verification, instead of current time |
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
array of object with potential sessionKey, algorithm pairs
- Type
- Promise.<Array.<{data: Uint8Array, algorithm: String}>>
(async) encrypt(encryptionKeysopt, passwordsopt, sessionKeyopt, wildcardopt, encryptionKeyIDsopt, dateopt, userIDsopt, configopt) → {Promise.<Message>}
Encrypt the message either with public keys, passwords, or both at once.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
encryptionKeys |
Array.<PublicKey> |
<optional> |
Public key(s) for message encryption |
|
passwords |
Array.<String> |
<optional> |
Password(s) for message encryption |
|
sessionKey |
Object |
<optional> |
Session key in the form: { data:Uint8Array, algorithm:String, [aeadAlgorithm:String] } |
|
wildcard |
Boolean |
<optional> |
false | Use a key ID of 0 instead of the public key IDs |
encryptionKeyIDs |
Array.<module:type/keyid~KeyID> |
<optional> |
Array of key IDs to use for encryption. Each encryptionKeyIDs[i] corresponds to keys[i] |
|
date |
Date |
<optional> |
Override the creation date of the literal package |
|
userIDs |
Array.<Object> |
<optional> |
User IDs to encrypt for, e.g. [{ name:'Robert Receiver', email:'robert@openpgp.org' }] |
|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with encrypted content.
- Type
- Promise.<Message>
getEncryptionKeyIDs() → {Array.<module:type/keyid~KeyID>}
Returns the key IDs of the keys to which the session key is encrypted
- Source:
Returns:
Array of keyID objects.
- Type
- Array.<module:type/keyid~KeyID>
getFilename() → {String|null}
Get filename from literal data packet
- Source:
Returns:
Filename of literal data packet as string.
- Type
- String | null
getLiteralData() → {Uint8Array|null}
Get literal data that is the body of the message
- Source:
Returns:
Literal body of the message as Uint8Array.
- Type
- Uint8Array | null
getSigningKeyIDs() → {Array.<module:type/keyid~KeyID>}
Returns the key IDs of the keys that signed the message
- Source:
Returns:
Array of keyID objects.
- Type
- Array.<module:type/keyid~KeyID>
getText() → {String|null}
Get literal data as text
- Source:
Returns:
Literal body of the message interpreted as text.
- Type
- String | null
(async) sign(signingKeys, recipientKeys, signatureopt, signingKeyIDsopt, dateopt, signingUserIDsopt, recipientUserIDsopt, notationsopt, configopt) → {Promise.<Message>}
Sign the message (the literal data packet of the message)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
signingKeys |
Array.<PrivateKey> | private keys with decrypted secret key data for signing |
||
recipientKeys |
Array.<Key> | recipient keys to get the signing preferences from |
||
signature |
Signature |
<optional> |
null | Any existing detached signature to add to the message |
signingKeyIDs |
Array.<module:type/keyid~KeyID> |
<optional> |
Array of key IDs to use for signing. Each signingKeyIDs[i] corresponds to signingKeys[i] |
|
date |
Date |
<optional> |
Override the creation time of the signature |
|
signingUserIDs |
Array.<UserID> |
<optional> |
User IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] |
|
recipientUserIDs |
Array.<UserID> |
<optional> |
User IDs associated with |
|
notations |
Array |
<optional> |
Notation Data to add to the signatures, e.g. [{ name: 'test@example.org', value: new TextEncoder().encode('test'), humanReadable: true, critical: false }] |
|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with signed content.
- Type
- Promise.<Message>
(async) signDetached(signingKeys, recipientKeys, signatureopt, signingKeyIDsopt, dateopt, signingUserIDsopt, recipientUserIDsopt, notationsopt, configopt) → {Promise.<Signature>}
Create a detached signature for the message (the literal data packet of the message)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
signingKeys |
Array.<PrivateKey> | private keys with decrypted secret key data for signing |
||
recipientKeys |
Array.<Key> | recipient keys to get the signing preferences from |
||
signature |
Signature |
<optional> |
null | Any existing detached signature |
signingKeyIDs |
Array.<module:type/keyid~KeyID> |
<optional> |
Array of key IDs to use for signing. Each signingKeyIDs[i] corresponds to signingKeys[i] |
|
date |
Date |
<optional> |
Override the creation time of the signature |
|
signingUserIDs |
Array.<UserID> |
<optional> |
User IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] |
|
recipientUserIDs |
Array.<UserID> |
<optional> |
User IDs associated with |
|
notations |
Array |
<optional> |
Notation Data to add to the signatures, e.g. [{ name: 'test@example.org', value: new TextEncoder().encode('test'), humanReadable: true, critical: false }] |
|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New detached signature of message content.
- Type
- Promise.<Signature>
unwrapCompressed() → {Message}
Unwrap compressed message
- Source:
Returns:
Message Content of compressed message.
- Type
- Message
(async) verify(verificationKeys, dateopt, configopt) → {Promise.<Array.<{keyID: module:type/keyid~KeyID, signature: Promise.<Signature>, verified: Promise.<true>}>>}
Verify message signatures
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
verificationKeys |
Array.<PublicKey> | Array of public keys to verify signatures |
|
date |
Date |
<optional> |
Verify the signature against the given date, i.e. check signature creation time < date < expiration time |
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
List of signer's keyID and validity of signatures.
- Type
- Promise.<Array.<{keyID: module:type/keyid~KeyID, signature: Promise.<Signature>, verified: Promise.<true>}>>
(async) verifyDetached(verificationKeys, signature, date, configopt) → {Promise.<Array.<{keyID: module:type/keyid~KeyID, signature: Promise.<Signature>, verified: Promise.<true>}>>}
Verify detached message signature
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
verificationKeys |
Array.<PublicKey> | Array of public keys to verify signatures |
|
signature |
Signature | ||
date |
Date | Verify the signature against the given date, i.e. check signature creation time < date < expiration time |
|
config |
Object |
<optional> |
Full configuration, defaults to openpgp.config |
- Source:
Returns:
List of signer's keyID and validity of signature.
- Type
- Promise.<Array.<{keyID: module:type/keyid~KeyID, signature: Promise.<Signature>, verified: Promise.<true>}>>
write() → {ReadableStream.<Uint8Array>}
Returns binary encoded message
- Source:
Returns:
Binary message.
- Type
- ReadableStream.<Uint8Array>