Class: Keyid
+Class: KeyID
@@ -28,7 +28,7 @@Keyid()
+KeyID()
Implementation of type key id
RFC4880 3.3: @@ -50,7 +50,7 @@ formed.
From 2d07c43030ad01e065a36c961912a881a123250c Mon Sep 17 00:00:00 2001
From: Daniel Huigens
streaming
Whether the top-level function will return a stream
streaming
Whether the top-level function will return a stream
streaming
Whether the top-level function will return a stream
config
Creates a new CleartextMessage object from text
-Name | - - -Type | - - - - - -Description | -
---|---|---|
text |
-
-
- - - -String - - - - | - - - - - -- |
Array of keyid objects.
+Array of keyID objects.
signingKeyIds
signingKeyIDs
Array of key IDs to use for signing. Each signingKeyIds[i] corresponds to privateKeys[i]
Array of key IDs to use for signing. Each signingKeyIDs[i] corresponds to privateKeys[i]
userIds
userIDs
Sign the cleartext message
-Name | - - -Type | - - -Attributes | - - - -Default | - - -Description | -
---|---|---|---|---|
privateKeys |
-
-
- - - -Array.<Key> - - - - | - - -- - - - - - | - - - -- - | - - -private keys with decrypted secret key data for signing |
-
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 privateKeys[i] |
-
date |
-
-
- - - -Date - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - | - - -The creation time of the signature that should be created |
-
userIds |
-
-
- - - -Array - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - | - - -User IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] |
-
config |
-
-
- - - -Object - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - | - - -Full configuration, defaults to openpgp.config |
-
New detached signature of message content.
-List of signer's keyid and validity of signature.
+List of signer's keyID and validity of signature.
Verify signatures of cleartext signed message
-Name | - - -Type | - - -Attributes | - - - - -Description | -
---|---|---|---|
keys |
-
-
- - - -Array.<Key> - - - - | - - -- - - - - - | - - - - -Array of 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 |
-
List of signer's keyid and validity of signature.
-Packet type
-Name | + + +Type | + + +Attributes | + + + +Default | + + +Description | +
---|---|---|---|---|
deep |
+
+
+ + + +Boolean + + + + | + + +
+
+ <optional> + + + + + + |
+
+
+
+ + + false + + | + + +Whether to return a deep clone |
+
Shallow clone of the key.
+Clone of the key.
Decrypts all secret key and subkey packets matching keyId
-Name | - - -Type | - - -Attributes | - - - -Default | - - -Description | -
---|---|---|---|---|
passphrases |
-
-
- - - -String -| - -Array.<String> - - - - | - - -- - - - - - | - - - -- - | - - -- |
keyId |
-
-
- - - -module:type/keyid~Keyid - - - - | - - -- - - - - - | - - - -- - null - - | - - -- |
config |
-
-
- - - -Object - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - | - - -Full configuration, defaults to openpgp.config |
-
if any matching key or subkey packets did not decrypt successfully
-Encrypts all secret key and subkey packets matching keyId
-Name | - - -Type | - - -Attributes | - - - -Default | - - -Description | -
---|---|---|---|---|
passphrases |
-
-
- - - -String -| - -Array.<String> - - - - | - - -- - - - - - | - - - -- - | - - -If multiple passphrases, then should be in same order as packets each should encrypt |
-
keyId |
-
-
- - - -module:type/keyid~Keyid - - - - | - - -- - - - - - | - - - -- - null - - | - - -- |
config |
-
-
- - - -Object - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - | - - -Full configuration, defaults to openpgp.config |
-
if encryption failed for any key or subkey
-Returns all keys that are available for decryption, matching the keyId when given +
Returns all keys that are available for decryption, matching the keyID when given This is useful to retrieve keys for session key decryption
keyId,
keyID,
userId,
userID,
Returns last created key or key by given keyId that is available for encryption or decryption
+Returns last created key or key by given keyID that is available for encryption or decryption
keyId,
keyID,
userId,
userID,
keyId,
keyID,
userId,
userID,
Returns an array containing all public or private keys matching keyId. -If keyId is not present, returns all keys starting with the primary key.
+Returns an array containing all public or private keys matching keyID. +If keyID is not present, returns all keys starting with the primary key.
keyId
keyID
userId
userID
Returns last created key or key by given keyId that is available for signing and verification
+Returns last created key or key by given keyID that is available for signing and verification
keyId,
keyID,
userId,
userID,
Returns an array containing all public or private subkeys matching keyId; -If keyId is not present, returns all subkeys.
+Returns an array containing all public or private subkeys matching keyID; +If keyID is not present, returns all subkeys.
keyId
keyID
Returns userids
+Returns userIDs
Array of userids.
+Array of userIDs.
userId
userID
list of userid, signer's keyid and validity of signature
+List of userID, signer's keyID and validity of signature
userId
userID
userId
userID
List of signer's keyid and validity of signature
+List of signer's keyID and validity of signature
Returns binary encoded key
+Binary key.
+Aead algorithm, e.g. 'eax' or 'ocb'
AEAD algorithm, e.g. 'eax' or 'ocb'
encryptionKeyIds
encryptionKeyIDs
Array of key IDs to use for encryption. Each encryptionKeyIds[i] corresponds to publicKeys[i]
Array of key IDs to use for encryption. Each encryptionKeyIDs[i] corresponds to publicKeys[i]
userIds
userIDs
Creates new message object from binary data.
-Name | - - -Type | - - -Attributes | - - - -Default | - - -Description | -
---|---|---|---|---|
bytes |
-
-
- - - -Uint8Array -| - -ReadableStream.<Uint8Array> - - - - | - - -- - - - - - | - - - -- - | - - -The message contents |
-
filename |
-
-
- - - -String - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - "" - - | - - -Name of the file (if any) |
-
date |
-
-
- - - -Date - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - current date - - | - - -Date of the message, or modification date of the file |
-
type |
-
-
- - - -'utf8' -| - -'binary' -| - -'text' -| - -'mime' - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - 'binary' - - | - - -Data packet type |
-
New message object.
-Creates new message object from text.
-Name | - - -Type | - - -Attributes | - - - -Default | - - -Description | -
---|---|---|---|---|
text |
-
-
- - - -String -| - -ReadableStream.<String> - - - - | - - -- - - - - - | - - - -- - | - - -The message contents |
-
filename |
-
-
- - - -String - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - "" - - | - - -Name of the file (if any) |
-
date |
-
-
- - - -Date - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - current date - - | - - -Date of the message, or modification date of the file |
-
type |
-
-
- - - -'utf8' -| - -'binary' -| - -'text' -| - -'mime' - - - - | - - -
-
- <optional> - - - - - - |
-
-
-
- - - 'utf8' - - | - - -Data packet type |
-
New message object.
-userIds
userIDs
algo
compression algorithm
config
streaming
Whether to process data as a stream
config
encryptionKeyIds
encryptionKeyIDs
Array of key IDs to use for encryption. Each encryptionKeyIds[i] corresponds to publicKeys[i]
Array of key IDs to use for encryption. Each encryptionKeyIDs[i] corresponds to publicKeys[i]
userIds
userIDs
streaming
Whether to process data as a stream
config
Array of keyid objects.
+Array of keyID objects.
Array of keyid objects.
+Array of keyID objects.
signingKeyIds
signingKeyIDs
Array of key IDs to use for signing. Each signingKeyIds[i] corresponds to privateKeys[i]
Array of key IDs to use for signing. Each signingKeyIDs[i] corresponds to privateKeys[i]
userIds
userIDs
streaming
Whether to process data as a stream
config
signingKeyIds
signingKeyIDs
Array of key IDs to use for signing. Each signingKeyIds[i] corresponds to privateKeys[i]
Array of key IDs to use for signing. Each signingKeyIDs[i] corresponds to privateKeys[i]
userIds
userIDs
streaming
Whether to process data as a stream
config
streaming
Whether to process data as a stream
config
List of signer's keyid and validity of signature.
+List of signer's keyID and validity of signatures.
List of signer's keyid and validity of signature.
+List of signer's keyID and validity of signature.
Packet type
-Keyid
+KeyID
Packet type
-Keyid
+KeyID
Packet type
-Keyid
+KeyID
Packet type
-Decrypts the private key params which are needed to use the key. +Successful decryption does not imply key integrity, call validate() to confirm that. SecretKeyPacket.isDecrypted should be false, as otherwise calls to this function will throw an error.
if decryption was not successful
+if the key is already decrypted, or if decryption was not successful
Keyid
+KeyID
Packet type
-Decrypts the private key params which are needed to use the key. +Successful decryption does not imply key integrity, call validate() to confirm that. SecretKeyPacket.isDecrypted should be false, as otherwise calls to this function will throw an error.
if decryption was not successful
+if the key is already decrypted, or if decryption was not successful
streaming
Whether to process data as a stream
streaming
Whether to process data as a stream
config
streaming
Whether to read this.encrypted as a stream
config
streaming
Whether to set this.encrypted to a stream
config
Packet type
-userId
userID
Object specifying userId name, email and comment
Object specifying userID name, email and comment
Creates a new CleartextMessage object from text
+Name | + + +Type | + + + + + +Description | +||||||
---|---|---|---|---|---|---|---|---|
options |
+
+
+ + + +Object + + + + | + + + + + +
+ Properties+ + +
|
+
Creates new message object from text or binary data.
+Name | + + +Type | + + + + + +Description | +||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
+
+
+ + + +Object + + + + | + + + + + +
+ Properties+ + +
|
+
New message object.
+expectSigned
If true, data decryption fails if the message is not signed with the provided publicKeys
format
streaming
Whether to return data as a stream. Defaults to the type of stream message
was created from, if any.
signature
Message to be encrypted as created by Message.fromText or Message.fromBinary
Message to be encrypted as created by createMessage
streaming
Whether to return data as a stream
signature
signingKeyIds
signingKeyIDs
Array of key IDs to use for signing. Each signingKeyIds[i]
corresponds to privateKeys[i]
Array of key IDs to use for signing. Each signingKeyIDs[i]
corresponds to privateKeys[i]
encryptionKeyIds
encryptionKeyIDs
Array of key IDs to use for encryption. Each encryptionKeyIds[i]
corresponds to publicKeys[i]
Array of key IDs to use for encryption. Each encryptionKeyIDs[i]
corresponds to publicKeys[i]
fromUserIds
fromUserIDs
toUserIds
toUserIDs
Aead algorithm, e.g. 'eax' or 'ocb'
AEAD algorithm, e.g. 'eax' or 'ocb'
encryptionKeyIds
encryptionKeyIDs
Array of key IDs to use for encryption. Each encryptionKeyIds[i] corresponds to publicKeys[i]
Array of key IDs to use for encryption. Each encryptionKeyIDs[i] corresponds to publicKeys[i]
toUserIds
toUserIDs
userIDs
User IDs as objects: { name: 'Jo Doe', email: 'info@jo.com' }
type
userIds
User IDs as objects: { name: 'Jo Doe', email: 'info@jo.com' }
passphrase
toUserIds
toUserIDs
Instantiate a new packet given its tag
+Name | + + +Type | + + + + + +Description | +
---|---|---|
tag |
+
+
+ + + +module:enums.packet + + + + | + + + + + +Property value from module:enums.packet |
+
allowedPackets |
+
+
+ + + +Object + + + + | + + + + + +mapping where keys are allowed packet tags, pointing to their Packet class |
+
New packet object with type based on tag
+userIds
userIDs
streaming
Whether to return data as a stream. Defaults to the type of stream message
was created from, if any.
detached
signingKeyIds
signingKeyIDs
Array of key IDs to use for signing. Each signingKeyIds[i] corresponds to privateKeys[i]
Array of key IDs to use for signing. Each signingKeyIDs[i] corresponds to privateKeys[i]
fromUserIds
fromUserIDs
message
(cleartext) message object with signatures
publicKeys
message
expectSigned
(cleartext) message object with signatures
If true, verification throws if the message is not signed with the provided publicKeys
streaming
Whether to return data as a stream. Defaults to the type of stream message
was created from, if any.
signature
The library implements the IETF proposal for authenticated encryption using native AES-EAX, OCB, or GCM. This makes symmetric encryption up to 30x faster on supported platforms. Since the specification has not been finalized and other OpenPGP implementations haven't adopted it yet, the feature is currently behind a flag. Note: activating this setting can break compatibility with other OpenPGP implementations, and also with future versions of OpenPGP.js. Don't use it with messages you want to store on disk or in a database. You can enable it by setting openpgp.config.aeadProtect = true
.
You can change the AEAD mode by setting one of the following options:
-openpgp.config.aeadMode = openpgp.enums.aead.eax // Default, native
-openpgp.config.aeadMode = openpgp.enums.aead.ocb // Non-native
-openpgp.config.aeadMode = openpgp.enums.aead.experimentalGcm // **Non-standard**, fastest
+openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.eax // Default, native
+openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.ocb // Non-native
+openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.experimentalGCM // **Non-standard**, fastest
To test whether the lazy loading works, try to generate a key with a non-standard curve:
import { generateKey } from 'openpgp/lightweight';
-await generateKey({ curve: 'brainpoolP512r1', userIds: [{ name: 'Test', email: 'test@test.com' }] });
+await generateKey({ curve: 'brainpoolP512r1', userIDs: [{ name: 'Test', email: 'test@test.com' }] });
For more examples of how to generate a key, see Generate new key pair. It is recommended to use curve25519
instead of brainpoolP512r1
by default.
Here are some examples of how to use OpenPGP.js v5. For more elaborate examples and working code, please check out the public API unit tests. If you're upgrading from v4 it might help to check out the changelog and documentation.
Encryption will use the algorithm specified in config.encryptionCipher (defaults to aes256), and decryption will use the algorithm used for encryption.
+Encryption will use the algorithm specified in config.preferredSymmetricAlgorithm (defaults to aes256), and decryption will use the algorithm used for encryption.
(async () => {
- const message = openpgp.Message.fromBinary(new Uint8Array([0x01, 0x01, 0x01]));
+ const message = await openpgp.createMessage({ binary: new Uint8Array([0x01, 0x01, 0x01]) });
const encrypted = await openpgp.encrypt({
message, // input as Message object
passwords: ['secret stuff'], // multiple passwords possible
@@ -296,11 +296,13 @@ import * as openpgp from './openpgp.min.mjs';
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
- const privateKey = await openpgp.readKey({ armoredKey: privateKeyArmored });
- await privateKey.decrypt(passphrase);
+ const privateKey = await openpgp.decryptKey({
+ privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
+ passphrase
+ });
const encrypted = await openpgp.encrypt({
- message: openpgp.Message.fromText('Hello, World!'), // input as Message object
+ message: await openpgp.createMessage({ text: 'Hello, World!' }), // input as Message object
publicKeys: publicKey, // for encryption
privateKeys: privateKey // for signing (optional)
});
@@ -309,15 +311,16 @@ import * as openpgp from './openpgp.min.mjs';
const message = await openpgp.readMessage({
armoredMessage: encrypted // parse armored message
});
- const { data: decrypted } = await openpgp.decrypt({
+ const { data: decrypted, signatures } = await openpgp.decrypt({
message,
publicKeys: publicKey, // for verification (optional)
privateKeys: privateKey // for decryption
});
console.log(decrypted); // 'Hello, World!'
+ console.log(signatures[0].valid) // signature validity (signed messages only)
})();
-Encrypt with multiple public keys:
+Encrypt to multiple public keys:
(async () => {
const publicKeysArmored = [
`-----BEGIN PGP PUBLIC KEY BLOCK-----
@@ -335,10 +338,12 @@ import * as openpgp from './openpgp.min.mjs';
const publicKeys = await Promise.all(publicKeysArmored.map(armoredKey => openpgp.readKey({ armoredKey })));
- const privateKey = await openpgp.readKey({ armoredKey: privateKeyArmored });
- await privateKey.decrypt(passphrase)
+ const privateKey = await openpgp.decryptKey({
+ privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
+ passphrase
+ });
- const message = openpgp.Message.fromText(message);
+ const message = await openpgp.createMessage({ text: message });
const encrypted = await openpgp.encrypt({
message:, // input as Message object
publicKeys, // for encryption
@@ -347,25 +352,61 @@ import * as openpgp from './openpgp.min.mjs';
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
})();
-By default, encrypt
will not use any compression. It's possible to override that behavior in two ways:
Either set the compression
parameter in the options object when calling encrypt
.
If you expect an encrypted message to be signed with one of the public keys you have, and do not want to trust the decrypted data otherwise, you can pass the decryption option expectSigned = true
, so that the decryption operation will fail if no valid signature is found:
(async () => {
- const message = openpgp.Message.fromBinary(new Uint8Array([0x01, 0x02, 0x03])); // or .fromText('string')
+ // put keys in backtick (``) to avoid errors caused by spaces or tabs
+ const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
+...
+-----END PGP PUBLIC KEY BLOCK-----`;
+ const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
+...
+-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
+ const passphrase = `yourPassphrase`; // what the private key is encrypted with
+
+ const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
+
+ const privateKey = await openpgp.decryptKey({
+ privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
+ passphrase
+ });
+
+ const encryptedAndSignedMessage = `-----BEGIN PGP MESSAGE-----
+...
+-----END PGP MESSAGE-----`;
+
+ const message = await openpgp.readMessage({
+ armoredMessage: encryptedAndSignedMessage // parse armored message
+ });
+ // decryption will fail if all signatures are invalid or missing
+ const { data: decrypted, signatures } = await openpgp.decrypt({
+ message,
+ privateKeys: privateKey // for decryption
+ expectSigned: true,
+ publicKeys: publicKey, // for verification (mandatory with expectSigned=true)
+ });
+ console.log(decrypted); // 'Hello, World!'
+})();
+
+By default, encrypt
will not use any compression when encrypting symmetrically only (i.e. when no publicKeys
are given).
+It's possible to change that behaviour by enabling compression through the config, either for the single encryption:
(async () => {
+ const message = await openpgp.createMessage({ binary: new Uint8Array([0x01, 0x02, 0x03]) }); // or createMessage({ text: 'string' })
const encrypted = await openpgp.encrypt({
message,
passwords: ['secret stuff'], // multiple passwords possible
- compression: openpgp.enums.compression.zip // compress the data with zip
+ config: { preferredCompressionAlgorithm: openpgp.enums.compression.zlib } // compress the data with zlib
});
})();
-Or, override the config to enable compression:
-openpgp.config.compression = openpgp.enums.compression.zlib;
+or by changing the default global configuration:
+openpgp.config.preferredCompressionAlgorithm = openpgp.enums.compression.zlib
Where the value can be any of:
openpgp.enums.compression.zip
openpgp.enums.compression.zlib
+openpgp.enums.compression.uncompressed
(default)
Streaming encrypt Uint8Array data with a password
(async () => {
@@ -376,7 +417,7 @@ import * as openpgp from './openpgp.min.mjs';
}
});
- const message = openpgp.Message.fromBinary(readableStream);
+ const message = await openpgp.createMessage({ binary: readableStream });
const encrypted = await openpgp.encrypt({
message, // input as Message object
passwords: ['secret stuff'], // multiple passwords possible
@@ -414,8 +455,10 @@ its Reader classReader class
const { privateKeyArmored, publicKeyArmored, revocationCertificate } = await openpgp.generateKey({
type: 'ecc', // Type of the key, defaults to ECC
curve: 'curve25519', // ECC curve name, defaults to curve25519
- userIds: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
+ userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
passphrase: 'super long and hard to guess secret' // protects the private key
});
@@ -467,7 +510,7 @@ and a subkey for encryption using Curve25519.
const key = await openpgp.generateKey({
type: 'rsa', // Type of the key
rsaBits: 4096, // RSA key size (defaults to 4096 bits)
- userIds: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
+ userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
passphrase: 'super long and hard to guess secret' // protects the private key
});
})();
@@ -501,10 +544,12 @@ and a subkey for encryption using Curve25519.
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
- const privateKey = await openpgp.readKey({ armoredKey: privateKeyArmored });
- await privateKey.decrypt(passphrase);
+ const privateKey = await openpgp.decryptKey({
+ privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
+ passphrase
+ });
- const unsignedMessage = openpgp.CleartextMessage.fromText('Hello, World!');
+ const unsignedMessage = await openpgp.createCleartextMessage({ text: 'Hello, World!' });
const cleartextMessage = await openpgp.sign({
message: unsignedMessage, // CleartextMessage or Message object
privateKeys: privateKey // for signing
@@ -520,7 +565,7 @@ and a subkey for encryption using Curve25519.
});
const { valid } = verified.signatures[0];
if (valid) {
- console.log('signed by key id ' + verified.signatures[0].keyid.toHex());
+ console.log('signed by key id ' + verified.signatures[0].keyID.toHex());
} else {
throw new Error('signature could not be verified');
}
@@ -538,10 +583,12 @@ and a subkey for encryption using Curve25519.
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
- const privateKey = await openpgp.readKey({ armoredKey: privateKeyArmored });
- await privateKey.decrypt(passphrase);
+ const privateKey = await openpgp.decryptKey({
+ privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
+ passphrase
+ });
- const cleartextMessage = openpgp.CleartextMessage.fromText('Hello, World!');
+ const cleartextMessage = await openpgp.createCleartextMessage({ text: 'Hello, World!' });
const detachedSignature = await openpgp.sign({
message: cleartextMessage, // CleartextMessage or Message object
privateKeys: privateKey, // for signing
@@ -559,7 +606,7 @@ and a subkey for encryption using Curve25519.
});
const { valid } = verified.signatures[0];
if (valid) {
- console.log('signed by key id ' + verified.signatures[0].keyid.toHex());
+ console.log('signed by key id ' + verified.signatures[0].keyID.toHex());
} else {
throw new Error('signature could not be verified');
}
@@ -582,10 +629,12 @@ and a subkey for encryption using Curve25519.
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
const passphrase = `yourPassphrase`; // what the private key is encrypted with
- const privateKey = await openpgp.readKey({ armoredKey: privateKeyArmored });
- await privateKey.decrypt(passphrase);
+ const privateKey = await openpgp.decryptKey({
+ privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
+ passphrase
+ });
- const message = openpgp.Message.fromBinary(readableStream); // or .fromText(readableStream: ReadableStream<String>)
+ const message = await openpgp.createMessage({ binary: readableStream }); // or createMessage({ text: ReadableStream<String> })
const signatureArmored = await openpgp.sign({
message,
privateKeys: privateKey // for signing
@@ -602,9 +651,9 @@ and a subkey for encryption using Curve25519.
// even if you don't need it, as that is what triggers the
// verification of the data.
- const { valid } = verified.signatures[0];
+ const valid = await verified.signatures[0].verified;
if (valid) {
- console.log('signed by key id ' + verified.signatures[0].keyid.toHex());
+ console.log('signed by key id ' + verified.signatures[0].keyID.toHex());
} else {
throw new Error('signature could not be verified');
}
@@ -638,7 +687,7 @@ and a subkey for encryption using Curve25519.
diff --git a/docs/module-config.html b/docs/module-config.html
index a11d39a7..8853f602 100644
--- a/docs/module-config.html
+++ b/docs/module-config.html
@@ -89,7 +89,7 @@
- Source:
@@ -247,124 +247,7 @@ Must be an integer value from 0 to 56.
- Source:
-
- config/config.js, line 69
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-(static) aeadMode
-
-
-
-
-
- Default Authenticated Encryption with Additional Data (AEAD) encryption mode
-Only has an effect when aeadProtect is set to true.
-
-
-
-
-
-
-
-
- Properties:
-
-
-
-
-
-
-
- Name
-
-
- Type
-
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- aeadMode
-
-
-
-
-
-Integer
-
-
-
-
-
-
-
-
-
- Default AEAD mode module:enums.aead
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Source:
-
@@ -482,7 +365,7 @@ Note: not all OpenPGP implementations are compatible with this option.
- Source:
@@ -607,7 +490,7 @@ where key flags were ignored when selecting a key for encryption.
- Source:
@@ -728,7 +611,7 @@ This is an insecure setting:
- Source:
@@ -845,7 +728,7 @@ This setting is insecure if the partially decrypted message is
- Source:
@@ -957,7 +840,7 @@ This setting is insecure if the partially decrypted message is
- Source:
@@ -1069,119 +952,7 @@ This setting is insecure if the partially decrypted message is
- Source:
-
- config/config.js, line 162
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-(static) compression
-
-
-
-
-
-
-
-
-
-
- Properties:
-
-
-
-
-
-
-
- Name
-
-
- Type
-
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- compression
-
-
-
-
-
-Integer
-
-
-
-
-
-
-
-
-
- Default compression algorithm module:enums.compression
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Source:
-
@@ -1293,119 +1064,7 @@ This setting is insecure if the partially decrypted message is
- Source:
-
- config/config.js, line 44
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-(static) encryptionCipher
-
-
-
-
-
-
-
-
-
-
- Properties:
-
-
-
-
-
-
-
- Name
-
-
- Type
-
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- encryptionCipher
-
-
-
-
-
-Integer
-
-
-
-
-
-
-
-
-
- Default encryption cipher module:enums.symmetric
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Source:
-
@@ -1522,7 +1181,7 @@ validation error when the notation is marked as critical.
- Source:
@@ -1540,13 +1199,13 @@ validation error when the notation is marked as critical.
-(static) maxUseridLength
+(static) maxUserIDLength
- Max userid string length (used for parsing)
+ Max userID string length (used for parsing)
@@ -1581,7 +1240,7 @@ validation error when the notation is marked as critical.
- maxUseridLength
+ maxUserIDLength
@@ -1638,7 +1297,7 @@ validation error when the notation is marked as critical.
- Source:
@@ -1750,7 +1409,7 @@ validation error when the notation is marked as critical.
- Source:
@@ -1768,7 +1427,7 @@ validation error when the notation is marked as critical.
-(static) minRsaBits
+(static) minRSABits
@@ -1805,7 +1464,7 @@ validation error when the notation is marked as critical.
- minRsaBits
+ minRSABits
@@ -1821,7 +1480,7 @@ validation error when the notation is marked as critical.
- Minimum RSA key size allowed for key generation
+ Minimum RSA key size allowed for key generation and message signing, verification and encryption
@@ -1862,7 +1521,7 @@ validation error when the notation is marked as critical.
- Source:
@@ -1979,7 +1638,7 @@ validation error when the notation is marked as critical.
- Source:
@@ -1997,7 +1656,124 @@ validation error when the notation is marked as critical.
-(static) preferHashAlgorithm
+(static) preferredAEADAlgorithm
+
+
+
+
+
+ Default Authenticated Encryption with Additional Data (AEAD) encryption mode
+Only has an effect when aeadProtect is set to true.
+
+
+
+
+
+
+
+
+ Properties:
+
+
+
+
+
+
+
+ Name
+
+
+ Type
+
+
+
+
+
+ Description
+
+
+
+
+
+
+
+
+ preferredAEADAlgorithm
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+ Default AEAD mode module:enums.aead
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+ -
+ config/config.js, line 61
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+(static) preferredCompressionAlgorithm
@@ -2034,7 +1810,119 @@ validation error when the notation is marked as critical.
- preferHashAlgorithm
+ compression
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+ Default compression algorithm module:enums.compression
+
+
+
+
Name | + + +Type | + + + + + +Description | +|||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
preferredHashAlgorithm |
@@ -2091,7 +1979,119 @@ validation error when the notation is marked as critical.
(static) preferredSymmetricAlgorithm+ + + + + + + + + + +Properties:+ + + +
+
+
@@ -2146,7 +2150,7 @@ validation error when the notation is marked as critical.
Reject insecure hash algorithms + |
+ reject_hash_algorithms rejectHashAlgorithms
@@ -2162,7 +2166,7 @@ validation error when the notation is marked as critical.
- | |
+ Reject insecure hash algorithms module:enums.hash
|
+
+
@@ -2258,7 +2266,7 @@ validation error when the notation is marked as critical.
Reject insecure message hash algorithms + |
+ reject_message_hash_algorithms rejectMessageHashAlgorithms
@@ -2274,7 +2282,7 @@ validation error when the notation is marked as critical.
- | |
+ Reject insecure message hash algorithms module:enums.hash
| (static) rejectPublicKeyAlgorithms+ + + + +
+
+
+
+
+
+
+
+
+ Reject insecure public key algorithms for message encryption, signing or verification +Properties:+ + + +
diff --git a/docs/module-crypto_random-RandomBuffer.html b/docs/module-crypto_random-RandomBuffer.html index 4eb93e4c..685f8e8f 100644 --- a/docs/module-crypto_random-RandomBuffer.html +++ b/docs/module-crypto_random-RandomBuffer.html @@ -95,7 +95,7 @@ diff --git a/docs/module-enums.html b/docs/module-enums.html index 2ea46ca7..6994587d 100644 --- a/docs/module-enums.html +++ b/docs/module-enums.html @@ -155,7 +155,7 @@ |
+ experimentalGcm experimentalGCM
@@ -212,7 +212,7 @@
|
|
+ AEADEncryptedData aeadEncryptedData
@@ -3301,7 +3301,7 @@ possession of more than one person. |
|
+ userIdInvalid userIDInvalid
@@ -3853,7 +3853,7 @@ possession of more than one person. |
|
+ primaryUserId primaryUserID
@@ -5025,7 +5025,7 @@ document) that cannot include a target subpacket. |
|
+ policyUri policyURI
@@ -5071,7 +5071,7 @@ document) that cannot include a target subpacket. |
|
+ signersUserId signersUserID
@@ -5209,7 +5209,7 @@ document) that cannot include a target subpacket. |
|
+ preferredAeadAlgorithms preferredAEADAlgorithms
@@ -5266,7 +5266,7 @@ document) that cannot include a target subpacket. |
diff --git a/docs/module-key_SubKey-SubKey.html b/docs/module-key_SubKey-SubKey.html index c93c3df2..9281f167 100644 --- a/docs/module-key_SubKey-SubKey.html +++ b/docs/module-key_SubKey-SubKey.html @@ -95,7 +95,7 @@ (async) getExpirationTime(primaryKey, date, configopt) → {Date|Infinity|null}+(async) getExpirationTime(primaryKey, date, configopt) → {Promise.<(Date|Infinity|null)>}@@ -792,7 +792,7 @@ Returns null if the subkey is invalid.getKeyId() → {module:type/keyid~Keyid}+getKeyID() → {module:type/keyid~KeyID}@@ -1120,7 +1114,7 @@ Returns null if the subkey is invalid.getKeyId() → {module:type/keyid~Keyid}+getKeyID() → {module:type/keyid~KeyID}@@ -1237,7 +1231,7 @@ Returns null if the subkey is invalid.(async) isRevoked(primaryKey, signature, key,, date, configopt) → {Boolean}+(async) isRevoked(primaryKey, signature, key,, date, configopt) → {Promise.<Boolean>}@@ -2037,7 +2031,7 @@ Returns null if the subkey is invalid.(async) revoke(primaryKey, reasonForRevocation, date, configopt) → {SubKey}+(async) revoke(primaryKey, reasonForRevocation, date, configopt) → {Promise.<SubKey>}@@ -2375,7 +2369,7 @@ Returns null if the subkey is invalid.(async) verify(primaryKey, date, configopt) → {SignaturePacket}+(async) verify(primaryKey, date, configopt) → {Promise.<SignaturePacket>}@@ -2967,7 +2961,7 @@ and valid binding signature.diff --git a/docs/module-key_User-User.html b/docs/module-key_User-User.html index b5a809c3..c1c237b9 100644 --- a/docs/module-key_User-User.html +++ b/docs/module-key_User-User.html @@ -95,7 +95,7 @@ (async) isRevoked(primaryKey, certificate, key,, date, config) → {Boolean}+(async) isRevoked(primaryKey, certificate, key,, date, config) → {Promise.<Boolean>}@@ -358,7 +358,7 @@(async) sign(primaryKey, privateKeys, config) → {Key}+(async) sign(primaryKey, privateKeys, config) → {Promise.<Key>}@@ -568,7 +568,7 @@(async) update(user, primaryKey, config) → {undefined}+(async) update(user, primaryKey, config) → {Promise.<undefined>}@@ -886,7 +886,7 @@(async) verify(primaryKey, date, config) → {true}+(async) verify(primaryKey, date, config) → {Promise.<true>}@@ -1093,7 +1093,7 @@ and validity of self signature.(async) verifyAllCertifications(primaryKey, keys, date, config) → {Promise.<Array.<{keyid: module:type/keyid~Keyid, valid: Boolean}>>}+(async) verifyAllCertifications(primaryKey, keys, date, config) → {Promise.<Array.<{keyID: module:type/keyid~KeyID, valid: Boolean}>>}@@ -1355,7 +1355,7 @@ and validity of self signature.
-
@@ -1395,7 +1395,7 @@ and validity of self signature.
List of signer's keyid and validity of signature +List of signer's keyID and validity of signature (async) verifyCertificate(primaryKey, certificate, keys, date, config) → {true|null}+(async) verifyCertificate(primaryKey, certificate, keys, date, config) → {Promise.<(true|null)>}@@ -1611,7 +1611,7 @@ and validity of self signature.diff --git a/docs/module-type_kdf_params-KDFParams.html b/docs/module-type_kdf_params-KDFParams.html index fde87145..776a22fc 100644 --- a/docs/module-type_kdf_params-KDFParams.html +++ b/docs/module-type_kdf_params-KDFParams.html @@ -163,7 +163,7 @@ diff --git a/docs/module-type_keyid-Keyid.html b/docs/module-type_keyid-KeyID.html similarity index 65% rename from docs/module-type_keyid-Keyid.html rename to docs/module-type_keyid-KeyID.html index 84d082ba..c3f8882a 100644 --- a/docs/module-type_keyid-Keyid.html +++ b/docs/module-type_keyid-KeyID.html @@ -2,7 +2,7 @@ -
-
Class: Keyid+Class: KeyID@@ -28,7 +28,7 @@Keyid()+KeyID()Implementation of type key id RFC4880 3.3: @@ -50,7 +50,7 @@ formed. new Keyid()+new KeyID()@@ -100,7 +100,7 @@ formed.equals(keyid, matchWildcard)+equals(keyID, matchWildcard)@@ -202,13 +202,13 @@ formed. |
+ keyid keyID
-Keyid
+KeyID
@@ -251,7 +251,7 @@ formed.
|
- |
+ Indicates whether to check if either keyid is a wildcard Indicates whether to check if either keyID is a wildcard diff --git a/docs/module-type_s2k-S2K.html b/docs/module-type_s2k-S2K.html index 5c004e97..686f612e 100644 --- a/docs/module-type_s2k-S2K.html +++ b/docs/module-type_s2k-S2K.html @@ -152,7 +152,7 @@ (async) produce_key(passphrase) → {Uint8Array}+(async) produceKey(passphrase) → {Promise.<Uint8Array>}@@ -600,7 +600,7 @@ hashAlgorithmdiff --git a/package-lock.json b/package-lock.json index 5af0f77c..984a37fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "openpgp", - "version": "5.0.0-1", + "version": "5.0.0-2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 47181903..d44f0051 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openpgp", "description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.", - "version": "5.0.0-1", + "version": "5.0.0-2", "license": "LGPL-3.0+", "homepage": "https://openpgpjs.org/", "engines": { |