Fixes dead links in the documentation
This commit is contained in:
parent
4ded3f9d58
commit
96c9cd0d73
|
@ -35,8 +35,8 @@ import { createVerificationObjects, createSignaturePackets } from './message';
|
||||||
* @class
|
* @class
|
||||||
* @classdesc Class that represents an OpenPGP cleartext signed message.
|
* @classdesc Class that represents an OpenPGP cleartext signed message.
|
||||||
* See {@link https://tools.ietf.org/html/rfc4880#section-7}
|
* See {@link https://tools.ietf.org/html/rfc4880#section-7}
|
||||||
* @param {String} text The cleartext of the signed message
|
* @param {String} text The cleartext of the signed message
|
||||||
* @param {module:signature} signature The detached signature or an empty signature if message not yet signed
|
* @param {module:signature.Signature} signature The detached signature or an empty signature for unsigned messages
|
||||||
*/
|
*/
|
||||||
export function CleartextMessage(text, signature) {
|
export function CleartextMessage(text, signature) {
|
||||||
if (!(this instanceof CleartextMessage)) {
|
if (!(this instanceof CleartextMessage)) {
|
||||||
|
@ -65,10 +65,10 @@ CleartextMessage.prototype.getSigningKeyIds = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign the cleartext message
|
* Sign the cleartext message
|
||||||
* @param {Array<module:key~Key>} privateKeys private keys with decrypted secret key data for signing
|
* @param {Array<module:key.Key>} privateKeys private keys with decrypted secret key data for signing
|
||||||
* @param {Signature} signature (optional) any existing detached signature
|
* @param {Signature} signature (optional) any existing detached signature
|
||||||
* @param {Date} date (optional) The creation time of the signature that should be created
|
* @param {Date} date (optional) The creation time of the signature that should be created
|
||||||
* @returns {Promise<module:message~CleartextMessage>} new cleartext message with signed content
|
* @returns {Promise<module:cleartext.CleartextMessage>} new cleartext message with signed content
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
CleartextMessage.prototype.sign = async function(privateKeys, signature=null, date=new Date()) {
|
CleartextMessage.prototype.sign = async function(privateKeys, signature=null, date=new Date()) {
|
||||||
|
@ -77,10 +77,10 @@ CleartextMessage.prototype.sign = async function(privateKeys, signature=null, da
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign the cleartext message
|
* Sign the cleartext message
|
||||||
* @param {Array<module:key~Key>} privateKeys private keys with decrypted secret key data for signing
|
* @param {Array<module:key.Key>} privateKeys private keys with decrypted secret key data for signing
|
||||||
* @param {Signature} signature (optional) any existing detached signature
|
* @param {Signature} signature (optional) any existing detached signature
|
||||||
* @param {Date} date (optional) The creation time of the signature that should be created
|
* @param {Date} date (optional) The creation time of the signature that should be created
|
||||||
* @returns {Promise<module:signature~Signature>} new detached signature of message content
|
* @returns {Promise<module:signature.Signature>} new detached signature of message content
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
CleartextMessage.prototype.signDetached = async function(privateKeys, signature=null, date=new Date()) {
|
CleartextMessage.prototype.signDetached = async function(privateKeys, signature=null, date=new Date()) {
|
||||||
|
@ -92,7 +92,7 @@ CleartextMessage.prototype.signDetached = async function(privateKeys, signature=
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify signatures of cleartext signed message
|
* Verify signatures of cleartext signed message
|
||||||
* @param {Array<module:key~Key>} keys array of keys to verify signatures
|
* @param {Array<module:key.Key>} keys array of keys to verify signatures
|
||||||
* @param {Date} date (optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time
|
* @param {Date} date (optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time
|
||||||
* @returns {Promise<Array<{keyid: module:type/keyid, valid: Boolean}>>} list of signer's keyid and validity of signature
|
* @returns {Promise<Array<{keyid: module:type/keyid, valid: Boolean}>>} list of signer's keyid and validity of signature
|
||||||
* @async
|
* @async
|
||||||
|
@ -103,7 +103,7 @@ CleartextMessage.prototype.verify = function(keys, date=new Date()) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify signatures of cleartext signed message
|
* Verify signatures of cleartext signed message
|
||||||
* @param {Array<module:key~Key>} keys array of keys to verify signatures
|
* @param {Array<module:key.Key>} keys array of keys to verify signatures
|
||||||
* @param {Date} date (optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time
|
* @param {Date} date (optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time
|
||||||
* @returns {Promise<Array<{keyid: module:type/keyid, valid: Boolean}>>} list of signer's keyid and validity of signature
|
* @returns {Promise<Array<{keyid: module:type/keyid, valid: Boolean}>>} list of signer's keyid and validity of signature
|
||||||
* @async
|
* @async
|
||||||
|
@ -146,7 +146,7 @@ CleartextMessage.prototype.armor = function() {
|
||||||
/**
|
/**
|
||||||
* reads an OpenPGP cleartext signed message and returns a CleartextMessage object
|
* reads an OpenPGP cleartext signed message and returns a CleartextMessage object
|
||||||
* @param {String} armoredText text to be parsed
|
* @param {String} armoredText text to be parsed
|
||||||
* @returns {module:cleartext~CleartextMessage} new cleartext message object
|
* @returns {module:cleartext.CleartextMessage} new cleartext message object
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
export function readArmored(armoredText) {
|
export function readArmored(armoredText) {
|
||||||
|
@ -163,9 +163,9 @@ export function readArmored(armoredText) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare hash algorithm specified in the armor header with signatures
|
* Compare hash algorithm specified in the armor header with signatures
|
||||||
* @private
|
|
||||||
* @param {Array<String>} headers Armor headers
|
* @param {Array<String>} headers Armor headers
|
||||||
* @param {module:packet/packetlist} packetlist The packetlist with signature packets
|
* @param {module:packet.List} packetlist The packetlist with signature packets
|
||||||
|
* @private
|
||||||
*/
|
*/
|
||||||
function verifyHeaders(headers, packetlist) {
|
function verifyHeaders(headers, packetlist) {
|
||||||
const checkHashAlgos = function(hashAlgos) {
|
const checkHashAlgos = function(hashAlgos) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* @fileoverview Provides EME-PKCS1-v1_5 encoding and decoding and EMSA-PKCS1-v1_5 encoding function
|
* @fileoverview Provides EME-PKCS1-v1_5 encoding and decoding and EMSA-PKCS1-v1_5 encoding function
|
||||||
* @see module:crypto/public_key/rsa
|
* @see module:crypto/public_key/rsa
|
||||||
* @see module:crypto/public_key/elliptic/ecdh
|
* @see module:crypto/public_key/elliptic/ecdh
|
||||||
* @see module:packet/public_key_encrypted_session_key
|
* @see module:packet.PublicKeyEncryptedSessionKey
|
||||||
* @requires crypto/random
|
* @requires crypto/random
|
||||||
* @requires crypto/hash
|
* @requires crypto/hash
|
||||||
* @requires util
|
* @requires util
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fileoverview Functions to add and remove PKCS5 padding
|
* @fileoverview Functions to add and remove PKCS5 padding
|
||||||
* @see module:packet/public_key_encrypted_session_key
|
* @see module:packet.PublicKeyEncryptedSessionKey
|
||||||
* @module crypto/pkcs5
|
* @module crypto/pkcs5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fileoverview Key encryption and decryption for RFC 6637 ECDH
|
* @fileoverview Key encryption and decryption for RFC 6637 ECDH
|
||||||
* @requires crypto/public_key/elliptic/curves
|
* @requires crypto/public_key/elliptic/curve
|
||||||
* @requires crypto/aes_kw
|
* @requires crypto/aes_kw
|
||||||
* @requires crypto/cipher
|
* @requires crypto/cipher
|
||||||
* @requires crypto/hash
|
* @requires crypto/hash
|
||||||
|
@ -63,13 +63,13 @@ function kdf(hash_algo, X, length, param) {
|
||||||
/**
|
/**
|
||||||
* Encrypt and wrap a session key
|
* Encrypt and wrap a session key
|
||||||
*
|
*
|
||||||
* @param {module:type/oid} oid Elliptic curve object identifier
|
* @param {module:type/oid} oid Elliptic curve object identifier
|
||||||
* @param {Enums} cipher_algo Symmetric cipher to use
|
* @param {module:enums.symmetric} cipher_algo Symmetric cipher to use
|
||||||
* @param {Enums} hash_algo Hash algorithm to use
|
* @param {module:enums.hash} hash_algo Hash algorithm to use
|
||||||
* @param {module:type/mpi} m Value derived from session key (RFC 6637)
|
* @param {module:type/mpi} m Value derived from session key (RFC 6637)
|
||||||
* @param {Uint8Array} Q Recipient public key
|
* @param {Uint8Array} Q Recipient public key
|
||||||
* @param {String} fingerprint Recipient fingerprint
|
* @param {String} fingerprint Recipient fingerprint
|
||||||
* @returns {{V: BN, C: BN}} Returns ephemeral key and encoded session key
|
* @returns {{V: BN, C: BN}} Returns ephemeral key and encoded session key
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
async function encrypt(oid, cipher_algo, hash_algo, m, Q, fingerprint) {
|
async function encrypt(oid, cipher_algo, hash_algo, m, Q, fingerprint) {
|
||||||
|
@ -91,14 +91,14 @@ async function encrypt(oid, cipher_algo, hash_algo, m, Q, fingerprint) {
|
||||||
/**
|
/**
|
||||||
* Decrypt and unwrap the value derived from session key
|
* Decrypt and unwrap the value derived from session key
|
||||||
*
|
*
|
||||||
* @param {module:type/oid} oid Elliptic curve object identifier
|
* @param {module:type/oid} oid Elliptic curve object identifier
|
||||||
* @param {Enums} cipher_algo Symmetric cipher to use
|
* @param {module:enums.symmetric} cipher_algo Symmetric cipher to use
|
||||||
* @param {Enums} hash_algo Hash algorithm to use
|
* @param {module:enums.hash} hash_algo Hash algorithm to use
|
||||||
* @param {BN} V Public part of ephemeral key
|
* @param {BN} V Public part of ephemeral key
|
||||||
* @param {Uint8Array} C Encrypted and wrapped value derived from session key
|
* @param {Uint8Array} C Encrypted and wrapped value derived from session key
|
||||||
* @param {Uint8Array} d Recipient private key
|
* @param {Uint8Array} d Recipient private key
|
||||||
* @param {String} fingerprint Recipient fingerprint
|
* @param {String} fingerprint Recipient fingerprint
|
||||||
* @returns {Uint8Array} Value derived from session
|
* @returns {Uint8Array} Value derived from session
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
async function decrypt(oid, cipher_algo, hash_algo, V, C, d, fingerprint) {
|
async function decrypt(oid, cipher_algo, hash_algo, V, C, d, fingerprint) {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
/**
|
/**
|
||||||
* @fileoverview Implementation of ECDSA following RFC6637 for Openpgpjs
|
* @fileoverview Implementation of ECDSA following RFC6637 for Openpgpjs
|
||||||
* @requires crypto/hash
|
* @requires crypto/hash
|
||||||
* @requires crypto/public_key/elliptic/curves
|
* @requires crypto/public_key/elliptic/curve
|
||||||
* @module crypto/public_key/elliptic/ecdsa
|
* @module crypto/public_key/elliptic/ecdsa
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ import Curve from './curves';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign a message using the provided key
|
* Sign a message using the provided key
|
||||||
* @param {module:type/oid} oid Elliptic curve object identifier
|
* @param {module:type/oid} oid Elliptic curve object identifier
|
||||||
* @param {enums.hash} hash_algo Hash algorithm used to sign
|
* @param {module:enums.hash} hash_algo Hash algorithm used to sign
|
||||||
* @param {Uint8Array} m Message to sign
|
* @param {Uint8Array} m Message to sign
|
||||||
* @param {Uint8Array} d Private key used to sign the message
|
* @param {Uint8Array} d Private key used to sign the message
|
||||||
* @returns {{r: Uint8Array,
|
* @returns {{r: Uint8Array,
|
||||||
* s: Uint8Array}} Signature of the message
|
* s: Uint8Array}} Signature of the message
|
||||||
* @async
|
* @async
|
||||||
|
@ -45,12 +45,12 @@ async function sign(oid, hash_algo, m, d) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies if a signature is valid for a message
|
* Verifies if a signature is valid for a message
|
||||||
* @param {module:type/oid} oid Elliptic curve object identifier
|
* @param {module:type/oid} oid Elliptic curve object identifier
|
||||||
* @param {enums.hash} hash_algo Hash algorithm used in the signature
|
* @param {module:enums.hash} hash_algo Hash algorithm used in the signature
|
||||||
* @param {{r: Uint8Array,
|
* @param {{r: Uint8Array,
|
||||||
s: Uint8Array}} signature Signature to verify
|
s: Uint8Array}} signature Signature to verify
|
||||||
* @param {Uint8Array} m Message to verify
|
* @param {Uint8Array} m Message to verify
|
||||||
* @param {Uint8Array} Q Public key used to verify the message
|
* @param {Uint8Array} Q Public key used to verify the message
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* @fileoverview Implementation of EdDSA following RFC4880bis-03 for OpenPGP
|
* @fileoverview Implementation of EdDSA following RFC4880bis-03 for OpenPGP
|
||||||
* @requires bn.js
|
* @requires bn.js
|
||||||
* @requires crypto/hash
|
* @requires crypto/hash
|
||||||
* @requires crypto/public_key/elliptic/curves
|
* @requires crypto/public_key/elliptic/curve
|
||||||
* @module crypto/public_key/elliptic/eddsa
|
* @module crypto/public_key/elliptic/eddsa
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -29,10 +29,10 @@ import Curve from './curves';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign a message using the provided key
|
* Sign a message using the provided key
|
||||||
* @param {module:type/oid} oid Elliptic curve object identifier
|
* @param {module:type/oid} oid Elliptic curve object identifier
|
||||||
* @param {enums.hash} hash_algo Hash algorithm used to sign
|
* @param {module:enums.hash} hash_algo Hash algorithm used to sign
|
||||||
* @param {Uint8Array} m Message to sign
|
* @param {Uint8Array} m Message to sign
|
||||||
* @param {Uint8Array} d Private key used to sign
|
* @param {Uint8Array} d Private key used to sign
|
||||||
* @returns {{R: Uint8Array,
|
* @returns {{R: Uint8Array,
|
||||||
* S: Uint8Array}} Signature of the message
|
* S: Uint8Array}} Signature of the message
|
||||||
* @async
|
* @async
|
||||||
|
@ -48,12 +48,12 @@ async function sign(oid, hash_algo, m, d) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies if a signature is valid for a message
|
* Verifies if a signature is valid for a message
|
||||||
* @param {module:type/oid} oid Elliptic curve object identifier
|
* @param {module:type/oid} oid Elliptic curve object identifier
|
||||||
* @param {enums.hash} hash_algo Hash algorithm used in the signature
|
* @param {module:enums.hash} hash_algo Hash algorithm used in the signature
|
||||||
* @param {{R: Uint8Array,
|
* @param {{R: Uint8Array,
|
||||||
S: Uint8Array}} signature Signature to verify the message
|
S: Uint8Array}} signature Signature to verify the message
|
||||||
* @param {Uint8Array} m Message to verify
|
* @param {Uint8Array} m Message to verify
|
||||||
* @param {Uint8Array} Q Public key used to verify the message
|
* @param {Uint8Array} Q Public key used to verify the message
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
/**
|
/**
|
||||||
* @fileoverview Wrapper for a KeyPair of an Elliptic Curve
|
* @fileoverview Wrapper for a KeyPair of an Elliptic Curve
|
||||||
* @requires bn.js
|
* @requires bn.js
|
||||||
* @requires crypto/public_key/elliptic/curves
|
* @requires crypto/public_key/elliptic/curve
|
||||||
* @requires crypto/hash
|
* @requires crypto/hash
|
||||||
* @requires util
|
* @requires util
|
||||||
* @requires enums
|
* @requires enums
|
||||||
|
|
178
src/key.js
178
src/key.js
|
@ -36,9 +36,8 @@ import util from './util';
|
||||||
* @class
|
* @class
|
||||||
* @classdesc Class that represents an OpenPGP key. Must contain a primary key.
|
* @classdesc Class that represents an OpenPGP key. Must contain a primary key.
|
||||||
* Can contain additional subkeys, signatures, user ids, user attributes.
|
* Can contain additional subkeys, signatures, user ids, user attributes.
|
||||||
* @param {module:packet/packetlist} packetlist The packets that form this key
|
* @param {module:packet.List} packetlist The packets that form this key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function Key(packetlist) {
|
export function Key(packetlist) {
|
||||||
if (!(this instanceof Key)) {
|
if (!(this instanceof Key)) {
|
||||||
return new Key(packetlist);
|
return new Key(packetlist);
|
||||||
|
@ -57,7 +56,7 @@ export function Key(packetlist) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms packetlist to structured key data
|
* Transforms packetlist to structured key data
|
||||||
* @param {module:packet/packetlist} packetlist The packets that form a key
|
* @param {module:packet.List} packetlist The packets that form a key
|
||||||
*/
|
*/
|
||||||
Key.prototype.packetlist2structure = function(packetlist) {
|
Key.prototype.packetlist2structure = function(packetlist) {
|
||||||
let user;
|
let user;
|
||||||
|
@ -132,7 +131,7 @@ Key.prototype.packetlist2structure = function(packetlist) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms structured key data to packetlist
|
* Transforms structured key data to packetlist
|
||||||
* @returns {module:packet/packetlist} The packets that form a key
|
* @returns {module:packet.List} The packets that form a key
|
||||||
*/
|
*/
|
||||||
Key.prototype.toPacketlist = function() {
|
Key.prototype.toPacketlist = function() {
|
||||||
const packetlist = new packet.List();
|
const packetlist = new packet.List();
|
||||||
|
@ -148,7 +147,7 @@ Key.prototype.toPacketlist = function() {
|
||||||
* Returns packetlist containing all public or private subkey packets matching keyId;
|
* Returns packetlist containing all public or private subkey packets matching keyId;
|
||||||
* If keyId is not present, returns all subkey packets.
|
* If keyId is not present, returns all subkey packets.
|
||||||
* @param {type/keyid} keyId
|
* @param {type/keyid} keyId
|
||||||
* @returns {module:packet/packetlist}
|
* @returns {module:packet.List}
|
||||||
*/
|
*/
|
||||||
Key.prototype.getSubkeyPackets = function(keyId=null) {
|
Key.prototype.getSubkeyPackets = function(keyId=null) {
|
||||||
const packets = new packet.List();
|
const packets = new packet.List();
|
||||||
|
@ -164,7 +163,7 @@ Key.prototype.getSubkeyPackets = function(keyId=null) {
|
||||||
* Returns a packetlist containing all public or private key packets matching keyId.
|
* Returns a packetlist containing all public or private key packets matching keyId.
|
||||||
* If keyId is not present, returns all key packets starting with the primary key.
|
* If keyId is not present, returns all key packets starting with the primary key.
|
||||||
* @param {type/keyid} keyId
|
* @param {type/keyid} keyId
|
||||||
* @returns {module:packet/packetlist}
|
* @returns {module:packet.List}
|
||||||
*/
|
*/
|
||||||
Key.prototype.getKeyPackets = function(keyId=null) {
|
Key.prototype.getKeyPackets = function(keyId=null) {
|
||||||
const packets = new packet.List();
|
const packets = new packet.List();
|
||||||
|
@ -211,7 +210,7 @@ Key.prototype.isPrivate = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns key as public key (shallow copy)
|
* Returns key as public key (shallow copy)
|
||||||
* @returns {module:key~Key} new public Key
|
* @returns {module:key.Key} new public Key
|
||||||
*/
|
*/
|
||||||
Key.prototype.toPublic = function() {
|
Key.prototype.toPublic = function() {
|
||||||
const packetlist = new packet.List();
|
const packetlist = new packet.List();
|
||||||
|
@ -263,8 +262,8 @@ function isValidSigningKeyPacket(keyPacket, signature, date=new Date()) {
|
||||||
* Returns first key packet or key packet by given keyId that is available for signing and verification
|
* Returns first key packet or key packet by given keyId that is available for signing and verification
|
||||||
* @param {module:type/keyid} keyId, optional
|
* @param {module:type/keyid} keyId, optional
|
||||||
* @param {Date} date use the given date for verification instead of the current time
|
* @param {Date} date use the given date for verification instead of the current time
|
||||||
* @returns {Promise<module:packet/secret_subkey|
|
* @returns {Promise<module:packet.SecretSubkey|
|
||||||
module:packet/secret_key|null>} key packet or null if no signing key has been found
|
* module:packet.SecretKey|null>} key packet or null if no signing key has been found
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
Key.prototype.getSigningKeyPacket = async function (keyId=null, date=new Date()) {
|
Key.prototype.getSigningKeyPacket = async function (keyId=null, date=new Date()) {
|
||||||
|
@ -306,10 +305,10 @@ function isValidEncryptionKeyPacket(keyPacket, signature, date=new Date()) {
|
||||||
* Returns first key packet or key packet by given keyId that is available for encryption or decryption
|
* Returns first key packet or key packet by given keyId that is available for encryption or decryption
|
||||||
* @param {module:type/keyid} keyId, optional
|
* @param {module:type/keyid} keyId, optional
|
||||||
* @param {Date} date, optional
|
* @param {Date} date, optional
|
||||||
* @returns {Promise<module:packet/public_subkey|
|
* @returns {Promise<module:packet.PublicSubkey|
|
||||||
* module:packet/secret_subkey|
|
* module:packet.SecretSubkey|
|
||||||
* module:packet/secret_key|
|
* module:packet.SecretKey|
|
||||||
* module:packet/public_key|null>} key packet or null if no encryption key has been found
|
* module:packet.PublicKey|null>} key packet or null if no encryption key has been found
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
Key.prototype.getEncryptionKeyPacket = async function(keyId, date=new Date()) {
|
Key.prototype.getEncryptionKeyPacket = async function(keyId, date=new Date()) {
|
||||||
|
@ -341,7 +340,7 @@ Key.prototype.getEncryptionKeyPacket = async function(keyId, date=new Date()) {
|
||||||
* Encrypts all secret key and subkey packets matching keyId
|
* Encrypts all secret key and subkey packets matching keyId
|
||||||
* @param {module:type/keyid} keyId
|
* @param {module:type/keyid} keyId
|
||||||
* @param {String} passphrase
|
* @param {String} passphrase
|
||||||
* @returns {Promise<Array<module:packet/secret_key|module:packet/secret_subkey>>}
|
* @returns {Promise<Array<module:packet.SecretKey|module:packet.SecretSubkey>>}
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
Key.prototype.encrypt = async function(passphrase, keyId=null) {
|
Key.prototype.encrypt = async function(passphrase, keyId=null) {
|
||||||
|
@ -376,12 +375,12 @@ Key.prototype.decrypt = async function(passphrase, keyId=null) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a signature on a key is revoked
|
* Checks if a signature on a key is revoked
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
* @param {module:packet/signature} signature The signature to verify
|
* @param {module:packet.Signature} signature The signature to verify
|
||||||
* @param {module:packet/public_subkey|
|
* @param {module:packet.PublicSubkey|
|
||||||
* module:packet/secret_subkey|
|
* module:packet.SecretSubkey|
|
||||||
* module:packet/public_key|
|
* module:packet.PublicKey|
|
||||||
* module:packet/secret_key} key, optional The key to verify the signature
|
* module:packet.SecretKey} key, optional The key to verify the signature
|
||||||
* @param {Date} date Use the given date instead of the current time
|
* @param {Date} date Use the given date instead of the current time
|
||||||
* @returns {Promise<Boolean>} True if the certificate is revoked
|
* @returns {Promise<Boolean>} True if the certificate is revoked
|
||||||
* @async
|
* @async
|
||||||
|
@ -474,8 +473,8 @@ Key.prototype.getExpirationTime = async function() {
|
||||||
* - if multiple primary users exist, returns the one with the latest self signature
|
* - if multiple primary users exist, returns the one with the latest self signature
|
||||||
* - otherwise, returns the user with the latest self signature
|
* - otherwise, returns the user with the latest self signature
|
||||||
* @param {Date} date use the given date for verification instead of the current time
|
* @param {Date} date use the given date for verification instead of the current time
|
||||||
* @returns {Promise<{user: Array<module:packet/User>,
|
* @returns {Promise<{user: Array<module:key.User>,
|
||||||
* selfCertification: Array<module:packet/signature>}|undefined>} The primary user and the self signature
|
* selfCertification: Array<module:packet.Signature>}>} The primary user and the self signature
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
Key.prototype.getPrimaryUser = async function(date=new Date()) {
|
Key.prototype.getPrimaryUser = async function(date=new Date()) {
|
||||||
|
@ -530,7 +529,7 @@ Key.prototype.getPrimaryUser = async function(date=new Date()) {
|
||||||
*
|
*
|
||||||
* If the specified key is a private key and the destination key is public,
|
* If the specified key is a private key and the destination key is public,
|
||||||
* the destination key is transformed to a private key.
|
* the destination key is transformed to a private key.
|
||||||
* @param {module:key~Key} key Source key to merge
|
* @param {module:key.Key} key Source key to merge
|
||||||
*/
|
*/
|
||||||
Key.prototype.update = async function(key) {
|
Key.prototype.update = async function(key) {
|
||||||
const that = this;
|
const that = this;
|
||||||
|
@ -623,8 +622,8 @@ Key.prototype.revoke = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signs primary user of key
|
* Signs primary user of key
|
||||||
* @param {Array<module:key~Key>} privateKey decrypted private keys for signing
|
* @param {Array<module:key.Key>} privateKey decrypted private keys for signing
|
||||||
* @returns {Promise<module:key~Key>} new public key with new certificate signature
|
* @returns {Promise<module:key.Key>} new public key with new certificate signature
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
Key.prototype.signPrimaryUser = async function(privateKeys) {
|
Key.prototype.signPrimaryUser = async function(privateKeys) {
|
||||||
|
@ -640,8 +639,8 @@ Key.prototype.signPrimaryUser = async function(privateKeys) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signs all users of key
|
* Signs all users of key
|
||||||
* @param {Array<module:key~Key>} privateKeys decrypted private keys for signing
|
* @param {Array<module:key.Key>} privateKeys decrypted private keys for signing
|
||||||
* @returns {Promise<module:key~Key>} new public key with new certificate signature
|
* @returns {Promise<module:key.Key>} new public key with new certificate signature
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
Key.prototype.signAllUsers = async function(privateKeys) {
|
Key.prototype.signAllUsers = async function(privateKeys) {
|
||||||
|
@ -657,7 +656,7 @@ Key.prototype.signAllUsers = async function(privateKeys) {
|
||||||
* Verifies primary user of key
|
* Verifies primary user of key
|
||||||
* - if no arguments are given, verifies the self certificates;
|
* - if no arguments are given, verifies the self certificates;
|
||||||
* - otherwise, verifies all certificates signed with given keys.
|
* - otherwise, verifies all certificates signed with given keys.
|
||||||
* @param {Array<module:key~Key>} keys array of keys to verify certificate signatures
|
* @param {Array<module:key.Key>} keys array of keys to verify certificate signatures
|
||||||
* @returns {Promise<Array<{keyid: module:type/keyid,
|
* @returns {Promise<Array<{keyid: module:type/keyid,
|
||||||
* valid: Boolean}>>} List of signer's keyid and validity of signature
|
* valid: Boolean}>>} List of signer's keyid and validity of signature
|
||||||
* @async
|
* @async
|
||||||
|
@ -677,7 +676,7 @@ Key.prototype.verifyPrimaryUser = async function(keys) {
|
||||||
* Verifies all users of key
|
* Verifies all users of key
|
||||||
* - if no arguments are given, verifies the self certificates;
|
* - if no arguments are given, verifies the self certificates;
|
||||||
* - otherwise, verifies all certificates signed with given keys.
|
* - otherwise, verifies all certificates signed with given keys.
|
||||||
* @param {Array<module:key~Key>} keys array of keys to verify certificate signatures
|
* @param {Array<module:key.Key>} keys array of keys to verify certificate signatures
|
||||||
* @returns {Promise<Array<{userid: String,
|
* @returns {Promise<Array<{userid: String,
|
||||||
* keyid: module:type/keyid,
|
* keyid: module:type/keyid,
|
||||||
* valid: Boolean}>>} list of userid, signer's keyid and validity of signature
|
* valid: Boolean}>>} list of userid, signer's keyid and validity of signature
|
||||||
|
@ -717,7 +716,7 @@ function User(userPacket) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms structured user data to packetlist
|
* Transforms structured user data to packetlist
|
||||||
* @returns {module:packet/packetlist}
|
* @returns {module:packet.List}
|
||||||
*/
|
*/
|
||||||
User.prototype.toPacketlist = function() {
|
User.prototype.toPacketlist = function() {
|
||||||
const packetlist = new packet.List();
|
const packetlist = new packet.List();
|
||||||
|
@ -730,10 +729,10 @@ User.prototype.toPacketlist = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signs user
|
* Signs user
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
* module:packet/public_key} primaryKey The primary key packet
|
* module:packet.PublicKey} primaryKey The primary key packet
|
||||||
* @param {Array<module:key~Key>} privateKeys Decrypted private keys for signing
|
* @param {Array<module:key.Key>} privateKeys Decrypted private keys for signing
|
||||||
* @returns {Promise<module:key~Key>} New user with new certificate signatures
|
* @returns {Promise<module:key.Key>} New user with new certificate signatures
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
User.prototype.sign = async function(primaryKey, privateKeys) {
|
User.prototype.sign = async function(primaryKey, privateKeys) {
|
||||||
|
@ -770,13 +769,13 @@ User.prototype.sign = async function(primaryKey, privateKeys) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a given certificate of the user is revoked
|
* Checks if a given certificate of the user is revoked
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
* module:packet/public_key} primaryKey The primary key packet
|
* module:packet.PublicKey} primaryKey The primary key packet
|
||||||
* @param {module:packet/signature} certificate The certificate to verify
|
* @param {module:packet.Signature} certificate The certificate to verify
|
||||||
* @param {module:packet/public_subkey|
|
* @param {module:packet.PublicSubkey|
|
||||||
* module:packet/secret_subkey|
|
* module:packet.SecretSubkey|
|
||||||
* module:packet/public_key|
|
* module:packet.PublicKey|
|
||||||
* module:packet/secret_key} key, optional The key to verify the signature
|
* module:packet.SecretKey} key, optional The key to verify the signature
|
||||||
* @param {Date} date Use the given date instead of the current time
|
* @param {Date} date Use the given date instead of the current time
|
||||||
* @returns {Promise<Boolean>} True if the certificate is revoked
|
* @returns {Promise<Boolean>} True if the certificate is revoked
|
||||||
* @async
|
* @async
|
||||||
|
@ -792,10 +791,10 @@ User.prototype.isRevoked = async function(primaryKey, certificate, key, date=new
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies the user certificate
|
* Verifies the user certificate
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
module:packet/public_key} primaryKey The primary key packet
|
* module:packet.PublicKey} primaryKey The primary key packet
|
||||||
* @param {module:packet/signature} certificate A certificate of this user
|
* @param {module:packet.Signature} certificate A certificate of this user
|
||||||
* @param {Array<module:key~Key>} keys Array of keys to verify certificate signatures
|
* @param {Array<module:key.Key>} keys Array of keys to verify certificate signatures
|
||||||
* @param {Date} date Use the given date instead of the current time
|
* @param {Date} date Use the given date instead of the current time
|
||||||
* @returns {Promise<module:enums.keyStatus>} status of the certificate
|
* @returns {Promise<module:enums.keyStatus>} status of the certificate
|
||||||
* @async
|
* @async
|
||||||
|
@ -823,9 +822,9 @@ User.prototype.verifyCertificate = async function(primaryKey, certificate, keys,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies all user certificates
|
* Verifies all user certificates
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
* module:packet/public_key} primaryKey The primary key packet
|
* module:packet.PublicKey} primaryKey The primary key packet
|
||||||
* @param {Array<module:key~Key>} keys Array of keys to verify certificate signatures
|
* @param {Array<module:key.Key>} keys Array of keys to verify certificate signatures
|
||||||
* @returns {Promise<Array<{keyid: module:type/keyid,
|
* @returns {Promise<Array<{keyid: module:type/keyid,
|
||||||
* valid: Boolean}>>} List of signer's keyid and validity of signature
|
* valid: Boolean}>>} List of signer's keyid and validity of signature
|
||||||
* @async
|
* @async
|
||||||
|
@ -845,8 +844,8 @@ User.prototype.verifyAllCertifications = async function(primaryKey, keys) {
|
||||||
/**
|
/**
|
||||||
* Verify User. Checks for existence of self signatures, revocation signatures
|
* Verify User. Checks for existence of self signatures, revocation signatures
|
||||||
* and validity of self signature
|
* and validity of self signature
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
* module:packet/public_key} primaryKey The primary key packet
|
* module:packet.PublicKey} primaryKey The primary key packet
|
||||||
* @returns {Promise<module:enums.keyStatus>} Status of user
|
* @returns {Promise<module:enums.keyStatus>} Status of user
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
|
@ -876,9 +875,9 @@ User.prototype.verify = async function(primaryKey) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update user with new components from specified user
|
* Update user with new components from specified user
|
||||||
* @param {module:key~User} user Source user to merge
|
* @param {module:key.User} user Source user to merge
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
module:packet/secret_subkey} primaryKey primary key used for validation
|
* module:packet.SecretSubkey} primaryKey primary key used for validation
|
||||||
*/
|
*/
|
||||||
User.prototype.update = async function(user, primaryKey) {
|
User.prototype.update = async function(user, primaryKey) {
|
||||||
const dataToVerify = { userid: this.userId || this.userAttribute, key: primaryKey };
|
const dataToVerify = { userid: this.userId || this.userAttribute, key: primaryKey };
|
||||||
|
@ -909,7 +908,7 @@ function SubKey(subKeyPacket) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms structured subkey data to packetlist
|
* Transforms structured subkey data to packetlist
|
||||||
* @returns {module:packet/packetlist}
|
* @returns {module:packet.List}
|
||||||
*/
|
*/
|
||||||
SubKey.prototype.toPacketlist = function() {
|
SubKey.prototype.toPacketlist = function() {
|
||||||
const packetlist = new packet.List();
|
const packetlist = new packet.List();
|
||||||
|
@ -921,13 +920,13 @@ SubKey.prototype.toPacketlist = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a binding signature of a subkey is revoked
|
* Checks if a binding signature of a subkey is revoked
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
* module:packet/public_key} primaryKey The primary key packet
|
* module:packet.PublicKey} primaryKey The primary key packet
|
||||||
* @param {module:packet/signature} signature The binding signature to verify
|
* @param {module:packet.Signature} signature The binding signature to verify
|
||||||
* @param {module:packet/public_subkey|
|
* @param {module:packet.PublicSubkey|
|
||||||
* module:packet/secret_subkey|
|
* module:packet.SecretSubkey|
|
||||||
* module:packet/public_key|
|
* module:packet.PublicKey|
|
||||||
* module:packet/secret_key} key, optional The key to verify the signature
|
* module:packet.SecretKey} key, optional The key to verify the signature
|
||||||
* @param {Date} date Use the given date instead of the current time
|
* @param {Date} date Use the given date instead of the current time
|
||||||
* @returns {Promise<Boolean>} True if the binding signature is revoked
|
* @returns {Promise<Boolean>} True if the binding signature is revoked
|
||||||
* @async
|
* @async
|
||||||
|
@ -944,8 +943,8 @@ SubKey.prototype.isRevoked = async function(primaryKey, signature, key, date=new
|
||||||
/**
|
/**
|
||||||
* Verify subkey. Checks for revocation signatures, expiration time
|
* Verify subkey. Checks for revocation signatures, expiration time
|
||||||
* and valid binding signature
|
* and valid binding signature
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
* module:packet/public_key} primaryKey The primary key packet
|
* module:packet.PublicKey} primaryKey The primary key packet
|
||||||
* @param {Date} date Use the given date instead of the current time
|
* @param {Date} date Use the given date instead of the current time
|
||||||
* @returns {Promise<module:enums.keyStatus>} The status of the subkey
|
* @returns {Promise<module:enums.keyStatus>} The status of the subkey
|
||||||
* @async
|
* @async
|
||||||
|
@ -1000,9 +999,9 @@ SubKey.prototype.getExpirationTime = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update subkey with new components from specified subkey
|
* Update subkey with new components from specified subkey
|
||||||
* @param {module:key~SubKey} subKey Source subkey to merge
|
* @param {module:key.SubKey} subKey Source subkey to merge
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
module:packet/secret_subkey} primaryKey primary key used for validation
|
module:packet.SecretSubkey} primaryKey primary key used for validation
|
||||||
*/
|
*/
|
||||||
SubKey.prototype.update = async function(subKey, primaryKey) {
|
SubKey.prototype.update = async function(subKey, primaryKey) {
|
||||||
if (await subKey.verify(primaryKey) === enums.keyStatus.invalid) {
|
if (await subKey.verify(primaryKey) === enums.keyStatus.invalid) {
|
||||||
|
@ -1042,7 +1041,7 @@ SubKey.prototype.update = async function(subKey, primaryKey) {
|
||||||
/**
|
/**
|
||||||
* Reads an unarmored OpenPGP key list and returns one or multiple key objects
|
* Reads an unarmored OpenPGP key list and returns one or multiple key objects
|
||||||
* @param {Uint8Array} data to be parsed
|
* @param {Uint8Array} data to be parsed
|
||||||
* @returns {{keys: Array<module:key~Key>,
|
* @returns {{keys: Array<module:key.Key>,
|
||||||
* err: (Array<Error>|null)}} result object with key and error arrays
|
* err: (Array<Error>|null)}} result object with key and error arrays
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
|
@ -1076,7 +1075,7 @@ export function read(data) {
|
||||||
/**
|
/**
|
||||||
* Reads an OpenPGP armored text and returns one or multiple key objects
|
* Reads an OpenPGP armored text and returns one or multiple key objects
|
||||||
* @param {String} armoredText text to be parsed
|
* @param {String} armoredText text to be parsed
|
||||||
* @returns {{keys: Array<module:key~Key>,
|
* @returns {{keys: Array<module:key.Key>,
|
||||||
* err: (Array<Error>|null)}} result object with key and error arrays
|
* err: (Array<Error>|null)}} result object with key and error arrays
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
|
@ -1097,15 +1096,18 @@ export function readArmored(armoredText) {
|
||||||
/**
|
/**
|
||||||
* Generates a new OpenPGP key. Supports RSA and ECC keys.
|
* Generates a new OpenPGP key. Supports RSA and ECC keys.
|
||||||
* Primary and subkey will be of same type.
|
* Primary and subkey will be of same type.
|
||||||
* @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsa_encrypt_sign] to indicate what type of key to make.
|
* @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsa_encrypt_sign]
|
||||||
|
* To indicate what type of key to make.
|
||||||
* RSA is 1. See {@link https://tools.ietf.org/html/rfc4880#section-9.1}
|
* RSA is 1. See {@link https://tools.ietf.org/html/rfc4880#section-9.1}
|
||||||
* @param {Integer} options.numBits number of bits for the key creation.
|
* @param {Integer} options.numBits number of bits for the key creation.
|
||||||
* @param {String|Array<String>} options.userIds assumes already in form of "User Name <username@email.com>"
|
* @param {String|Array<String>} options.userIds
|
||||||
If array is used, the first userId is set as primary user Id
|
* Assumes already in form of "User Name <username@email.com>"
|
||||||
|
* If array is used, the first userId is set as primary user Id
|
||||||
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
||||||
* @param {Boolean} [options.unlocked=false] The secret part of the generated key is unlocked
|
* @param {Boolean} [options.unlocked=false] The secret part of the generated key is unlocked
|
||||||
* @param {Number} [options.keyExpirationTime=0] The number of seconds after the key creation time that the key expires
|
* @param {Number} [options.keyExpirationTime=0]
|
||||||
* @returns {Promise<module:key~Key>}
|
* The number of seconds after the key creation time that the key expires
|
||||||
|
* @returns {Promise<module:key.Key>}
|
||||||
* @async
|
* @async
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
|
@ -1174,14 +1176,16 @@ export function generate(options) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reformats and signs an OpenPGP with a given User ID. Currently only supports RSA keys.
|
* Reformats and signs an OpenPGP with a given User ID. Currently only supports RSA keys.
|
||||||
* @param {module:key~Key} options.privateKey The private key to reformat
|
* @param {module:key.Key} options.privateKey The private key to reformat
|
||||||
* @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsa_encrypt_sign]
|
* @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsa_encrypt_sign]
|
||||||
* @param {String|Array<String>} options.userIds assumes already in form of "User Name <username@email.com>"
|
* @param {String|Array<String>} options.userIds
|
||||||
If array is used, the first userId is set as primary user Id
|
* Assumes already in form of "User Name <username@email.com>"
|
||||||
|
* If array is used, the first userId is set as primary user Id
|
||||||
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
||||||
* @param {Boolean} [options.unlocked=false] The secret part of the generated key is unlocked
|
* @param {Boolean} [options.unlocked=false] The secret part of the generated key is unlocked
|
||||||
* @param {Number} [options.keyExpirationTime=0] The number of seconds after the key creation time that the key expires
|
* @param {Number} [options.keyExpirationTime=0]
|
||||||
* @returns {Promise<module:key~Key>}
|
* The number of seconds after the key creation time that the key expires
|
||||||
|
* @returns {Promise<module:key.Key>}
|
||||||
* @async
|
* @async
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
|
@ -1317,15 +1321,15 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPacket, options) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a given certificate or binding signature is revoked
|
* Checks if a given certificate or binding signature is revoked
|
||||||
* @param {module:packet/secret_key|
|
* @param {module:packet.SecretKey|
|
||||||
* module:packet/public_key} primaryKey The primary key packet
|
* module:packet.PublicKey} primaryKey The primary key packet
|
||||||
* @param {Object} dataToVerify The data to check
|
* @param {Object} dataToVerify The data to check
|
||||||
* @param {Array<module:packet/signature>} revocations The revocation signatures to check
|
* @param {Array<module:packet.Signature>} revocations The revocation signatures to check
|
||||||
* @param {module:packet/signature} signature The certificate or signature to check
|
* @param {module:packet.Signature} signature The certificate or signature to check
|
||||||
* @param {module:packet/public_subkey|
|
* @param {module:packet.PublicSubkey|
|
||||||
* module:packet/secret_subkey|
|
* module:packet.SecretSubkey|
|
||||||
* module:packet/public_key|
|
* module:packet.PublicKey|
|
||||||
* module:packet/secret_key} key, optional The key packet to check the signature
|
* module:packet.SecretKey} key, optional The key packet to check the signature
|
||||||
* @param {Date} date Use the given date instead of the current time
|
* @param {Date} date Use the given date instead of the current time
|
||||||
* @returns {Promise<Boolean>} True if the signature revokes the data
|
* @returns {Promise<Boolean>} True if the signature revokes the data
|
||||||
* @async
|
* @async
|
||||||
|
@ -1412,7 +1416,7 @@ export async function getPreferredHashAlgo(key) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the preferred symmetric algorithm for a set of keys
|
* Returns the preferred symmetric algorithm for a set of keys
|
||||||
* @param {Array<module:key~Key>} keys Set of keys
|
* @param {Array<module:key.Key>} keys Set of keys
|
||||||
* @returns {Promise<module:enums.symmetric>} Preferred symmetric algorithm
|
* @returns {Promise<module:enums.symmetric>} Preferred symmetric algorithm
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -58,7 +58,7 @@ Keyring.prototype.clear = function() {
|
||||||
* @param {String} keyId provided as string of lowercase hex number
|
* @param {String} keyId provided as string of lowercase hex number
|
||||||
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
||||||
* @param {Boolean} deep if true search also in subkeys
|
* @param {Boolean} deep if true search also in subkeys
|
||||||
* @returns {Array<module:key~Key>|null} keys found or null
|
* @returns {Array<module:key.Key>|null} keys found or null
|
||||||
*/
|
*/
|
||||||
Keyring.prototype.getKeysForId = function (keyId, deep) {
|
Keyring.prototype.getKeysForId = function (keyId, deep) {
|
||||||
let result = [];
|
let result = [];
|
||||||
|
@ -71,7 +71,7 @@ Keyring.prototype.getKeysForId = function (keyId, deep) {
|
||||||
* Removes keys having the specified key id from the keyring
|
* Removes keys having the specified key id from the keyring
|
||||||
* @param {String} keyId provided as string of lowercase hex number
|
* @param {String} keyId provided as string of lowercase hex number
|
||||||
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
||||||
* @returns {Array<module:key~Key>|null} keys found or null
|
* @returns {Array<module:key.Key>|null} keys found or null
|
||||||
*/
|
*/
|
||||||
Keyring.prototype.removeKeysForId = function (keyId) {
|
Keyring.prototype.removeKeysForId = function (keyId) {
|
||||||
let result = [];
|
let result = [];
|
||||||
|
@ -82,7 +82,7 @@ Keyring.prototype.removeKeysForId = function (keyId) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all public and private keys
|
* Get all public and private keys
|
||||||
* @returns {Array<module:key~Key>} all keys
|
* @returns {Array<module:key.Key>} all keys
|
||||||
*/
|
*/
|
||||||
Keyring.prototype.getAllKeys = function () {
|
Keyring.prototype.getAllKeys = function () {
|
||||||
return this.publicKeys.keys.concat(this.privateKeys.keys);
|
return this.publicKeys.keys.concat(this.privateKeys.keys);
|
||||||
|
@ -90,7 +90,7 @@ Keyring.prototype.getAllKeys = function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of keys
|
* Array of keys
|
||||||
* @param {Array<module:key~Key>} keys The keys to store in this array
|
* @param {Array<module:key.Key>} keys The keys to store in this array
|
||||||
*/
|
*/
|
||||||
function KeyArray(keys) {
|
function KeyArray(keys) {
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
|
@ -99,7 +99,7 @@ function KeyArray(keys) {
|
||||||
/**
|
/**
|
||||||
* Searches all keys in the KeyArray matching the address or address part of the user ids
|
* Searches all keys in the KeyArray matching the address or address part of the user ids
|
||||||
* @param {String} email email address to search for
|
* @param {String} email email address to search for
|
||||||
* @returns {Array<module:key~Key>} The public keys associated with provided email address.
|
* @returns {Array<module:key.Key>} The public keys associated with provided email address.
|
||||||
*/
|
*/
|
||||||
KeyArray.prototype.getForAddress = function(email) {
|
KeyArray.prototype.getForAddress = function(email) {
|
||||||
const results = [];
|
const results = [];
|
||||||
|
@ -115,7 +115,7 @@ KeyArray.prototype.getForAddress = function(email) {
|
||||||
* Checks a key to see if it matches the specified email address
|
* Checks a key to see if it matches the specified email address
|
||||||
* @private
|
* @private
|
||||||
* @param {String} email email address to search for
|
* @param {String} email email address to search for
|
||||||
* @param {module:key~Key} key The key to be checked.
|
* @param {module:key.Key} key The key to be checked.
|
||||||
* @returns {Boolean} True if the email address is defined in the specified key
|
* @returns {Boolean} True if the email address is defined in the specified key
|
||||||
*/
|
*/
|
||||||
function emailCheck(email, key) {
|
function emailCheck(email, key) {
|
||||||
|
@ -138,7 +138,7 @@ function emailCheck(email, key) {
|
||||||
* @private
|
* @private
|
||||||
* @param {String} keyId provided as string of lowercase hex number
|
* @param {String} keyId provided as string of lowercase hex number
|
||||||
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
||||||
* @param {module:packet/secret_key|public_key|public_subkey|secret_subkey} keypacket The keypacket to be checked
|
* @param {module:packet.SecretKey|public_key|public_subkey|secret_subkey} keypacket The keypacket to be checked
|
||||||
* @returns {Boolean} True if keypacket has the specified keyid
|
* @returns {Boolean} True if keypacket has the specified keyid
|
||||||
*/
|
*/
|
||||||
function keyIdCheck(keyId, keypacket) {
|
function keyIdCheck(keyId, keypacket) {
|
||||||
|
@ -153,7 +153,7 @@ function keyIdCheck(keyId, keypacket) {
|
||||||
* @param {String} keyId provided as string of lowercase hex number
|
* @param {String} keyId provided as string of lowercase hex number
|
||||||
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
||||||
* @param {Boolean} deep if true search also in subkeys
|
* @param {Boolean} deep if true search also in subkeys
|
||||||
* @returns {module:key~Key|null} key found or null
|
* @returns {module:key.Key|null} key found or null
|
||||||
*/
|
*/
|
||||||
KeyArray.prototype.getForId = function (keyId, deep) {
|
KeyArray.prototype.getForId = function (keyId, deep) {
|
||||||
for (let i = 0; i < this.keys.length; i++) {
|
for (let i = 0; i < this.keys.length; i++) {
|
||||||
|
@ -197,7 +197,7 @@ KeyArray.prototype.importKey = async function (armored) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add key to KeyArray
|
* Add key to KeyArray
|
||||||
* @param {module:key~Key} key The key that will be added to the keyring
|
* @param {module:key.Key} key The key that will be added to the keyring
|
||||||
* @returns {Number} The new length of the KeyArray
|
* @returns {Number} The new length of the KeyArray
|
||||||
*/
|
*/
|
||||||
KeyArray.prototype.push = function (key) {
|
KeyArray.prototype.push = function (key) {
|
||||||
|
@ -208,7 +208,7 @@ KeyArray.prototype.push = function (key) {
|
||||||
* Removes a key with the specified keyid from the keyring
|
* Removes a key with the specified keyid from the keyring
|
||||||
* @param {String} keyId provided as string of lowercase hex number
|
* @param {String} keyId provided as string of lowercase hex number
|
||||||
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
* withouth 0x prefix (can be 16-character key ID or fingerprint)
|
||||||
* @returns {module:key~Key|null} The key object which has been removed or null
|
* @returns {module:key.Key|null} The key object which has been removed or null
|
||||||
*/
|
*/
|
||||||
KeyArray.prototype.removeForId = function (keyId) {
|
KeyArray.prototype.removeForId = function (keyId) {
|
||||||
for (let i = 0; i < this.keys.length; i++) {
|
for (let i = 0; i < this.keys.length; i++) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ LocalStore.prototype.privateKeysItem = 'private-keys';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the public keys from HTML5 local storage.
|
* Load the public keys from HTML5 local storage.
|
||||||
* @returns {Array<module:key~Key>} array of keys retrieved from localstore
|
* @returns {Array<module:key.Key>} array of keys retrieved from localstore
|
||||||
*/
|
*/
|
||||||
LocalStore.prototype.loadPublic = function () {
|
LocalStore.prototype.loadPublic = function () {
|
||||||
return loadKeys(this.storage, this.publicKeysItem);
|
return loadKeys(this.storage, this.publicKeysItem);
|
||||||
|
@ -60,7 +60,7 @@ LocalStore.prototype.loadPublic = function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the private keys from HTML5 local storage.
|
* Load the private keys from HTML5 local storage.
|
||||||
* @returns {Array<module:key~Key>} array of keys retrieved from localstore
|
* @returns {Array<module:key.Key>} array of keys retrieved from localstore
|
||||||
*/
|
*/
|
||||||
LocalStore.prototype.loadPrivate = function () {
|
LocalStore.prototype.loadPrivate = function () {
|
||||||
return loadKeys(this.storage, this.privateKeysItem);
|
return loadKeys(this.storage, this.privateKeysItem);
|
||||||
|
@ -86,7 +86,7 @@ function loadKeys(storage, itemname) {
|
||||||
/**
|
/**
|
||||||
* Saves the current state of the public keys to HTML5 local storage.
|
* Saves the current state of the public keys to HTML5 local storage.
|
||||||
* The key array gets stringified using JSON
|
* The key array gets stringified using JSON
|
||||||
* @param {Array<module:key~Key>} keys array of keys to save in localstore
|
* @param {Array<module:key.Key>} keys array of keys to save in localstore
|
||||||
*/
|
*/
|
||||||
LocalStore.prototype.storePublic = function (keys) {
|
LocalStore.prototype.storePublic = function (keys) {
|
||||||
storeKeys(this.storage, this.publicKeysItem, keys);
|
storeKeys(this.storage, this.publicKeysItem, keys);
|
||||||
|
@ -95,7 +95,7 @@ LocalStore.prototype.storePublic = function (keys) {
|
||||||
/**
|
/**
|
||||||
* Saves the current state of the private keys to HTML5 local storage.
|
* Saves the current state of the private keys to HTML5 local storage.
|
||||||
* The key array gets stringified using JSON
|
* The key array gets stringified using JSON
|
||||||
* @param {Array<module:key~Key>} keys array of keys to save in localstore
|
* @param {Array<module:key.Key>} keys array of keys to save in localstore
|
||||||
*/
|
*/
|
||||||
LocalStore.prototype.storePrivate = function (keys) {
|
LocalStore.prototype.storePrivate = function (keys) {
|
||||||
storeKeys(this.storage, this.privateKeysItem, keys);
|
storeKeys(this.storage, this.privateKeysItem, keys);
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @requires encoding/armor
|
||||||
|
* @requires type/keyid
|
||||||
* @requires config
|
* @requires config
|
||||||
* @requires crypto
|
* @requires crypto
|
||||||
* @requires encoding/armor
|
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @requires util
|
* @requires util
|
||||||
* @requires packet
|
* @requires packet
|
||||||
|
@ -27,13 +28,13 @@
|
||||||
* @module message
|
* @module message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import armor from './encoding/armor';
|
||||||
|
import type_keyid from './type/keyid';
|
||||||
import config from './config';
|
import config from './config';
|
||||||
import crypto from './crypto';
|
import crypto from './crypto';
|
||||||
import armor from './encoding/armor';
|
|
||||||
import enums from './enums';
|
import enums from './enums';
|
||||||
import util from './util';
|
import util from './util';
|
||||||
import packet from './packet';
|
import packet from './packet';
|
||||||
import type_keyid from './type/keyid';
|
|
||||||
import { Signature } from './signature';
|
import { Signature } from './signature';
|
||||||
import { getPreferredHashAlgo, getPreferredSymAlgo } from './key';
|
import { getPreferredHashAlgo, getPreferredSymAlgo } from './key';
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ import { getPreferredHashAlgo, getPreferredSymAlgo } from './key';
|
||||||
* @class
|
* @class
|
||||||
* @classdesc Class that represents an OpenPGP message.
|
* @classdesc Class that represents an OpenPGP message.
|
||||||
* Can be an encrypted message, signed message, compressed message or literal message
|
* Can be an encrypted message, signed message, compressed message or literal message
|
||||||
* @param {module:packet/packetlist} packetlist The packets that form this message
|
* @param {module:packet.List} packetlist The packets that form this message
|
||||||
* See {@link https://tools.ietf.org/html/rfc4880#section-11.3}
|
* See {@link https://tools.ietf.org/html/rfc4880#section-11.3}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -361,7 +362,7 @@ export async function encryptSessionKey(sessionKey, symAlgo, publicKeys, passwor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign the message (the literal data packet of the message)
|
* Sign the message (the literal data packet of the message)
|
||||||
* @param {Array<module:key~Key>} privateKeys private keys with decrypted secret key data for signing
|
* @param {Array<module:key.Key>} privateKeys private keys with decrypted secret key data for signing
|
||||||
* @param {Signature} signature (optional) any existing detached signature to add to the message
|
* @param {Signature} signature (optional) any existing detached signature to add to the message
|
||||||
* @param {Date} date} (optional) override the creation time of the signature
|
* @param {Date} date} (optional) override the creation time of the signature
|
||||||
* @returns {Promise<Message>} new message with signed content
|
* @returns {Promise<Message>} new message with signed content
|
||||||
|
@ -428,7 +429,7 @@ Message.prototype.sign = async function(privateKeys=[], signature=null, date=new
|
||||||
/**
|
/**
|
||||||
* Compresses the message (the literal and -if signed- signature data packets of the message)
|
* Compresses the message (the literal and -if signed- signature data packets of the message)
|
||||||
* @param {module:enums.compression} compression compression algorithm to be used
|
* @param {module:enums.compression} compression compression algorithm to be used
|
||||||
* @returns {module:message~Message} new message with compressed content
|
* @returns {module:message.Message} new message with compressed content
|
||||||
*/
|
*/
|
||||||
Message.prototype.compress = function(compression) {
|
Message.prototype.compress = function(compression) {
|
||||||
if (compression === enums.compression.uncompressed) {
|
if (compression === enums.compression.uncompressed) {
|
||||||
|
@ -447,10 +448,10 @@ Message.prototype.compress = function(compression) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a detached signature for the message (the literal data packet of the message)
|
* Create a detached signature for the message (the literal data packet of the message)
|
||||||
* @param {Array<module:key~Key>} privateKeys private keys with decrypted secret key data for signing
|
* @param {Array<module:key.Key>} privateKeys private keys with decrypted secret key data for signing
|
||||||
* @param {Signature} signature (optional) any existing detached signature
|
* @param {Signature} signature (optional) any existing detached signature
|
||||||
* @param {Date} date (optional) override the creation time of the signature
|
* @param {Date} date (optional) override the creation time of the signature
|
||||||
* @returns {Promise<module:signature~Signature>} new detached signature of message content
|
* @returns {Promise<module:signature.Signature>} new detached signature of message content
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
Message.prototype.signDetached = async function(privateKeys=[], signature=null, date=new Date()) {
|
Message.prototype.signDetached = async function(privateKeys=[], signature=null, date=new Date()) {
|
||||||
|
@ -463,11 +464,11 @@ Message.prototype.signDetached = async function(privateKeys=[], signature=null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create signature packets for the message
|
* Create signature packets for the message
|
||||||
* @param {module:packet/literal} literalDataPacket the literal data packet to sign
|
* @param {module:packet.Literal} literalDataPacket the literal data packet to sign
|
||||||
* @param {Array<module:key~Key>} privateKeys private keys with decrypted secret key data for signing
|
* @param {Array<module:key.Key>} privateKeys private keys with decrypted secret key data for signing
|
||||||
* @param {Signature} signature (optional) any existing detached signature to append
|
* @param {Signature} signature (optional) any existing detached signature to append
|
||||||
* @param {Date} date (optional) override the creationtime of the signature
|
* @param {Date} date (optional) override the creationtime of the signature
|
||||||
* @returns {Promise<module:packet/packetlist>} list of signature packets
|
* @returns {Promise<module:packet.List>} list of signature packets
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
export async function createSignaturePackets(literalDataPacket, privateKeys, signature=null, date=new Date()) {
|
export async function createSignaturePackets(literalDataPacket, privateKeys, signature=null, date=new Date()) {
|
||||||
|
@ -508,7 +509,7 @@ export async function createSignaturePackets(literalDataPacket, privateKeys, sig
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify message signatures
|
* Verify message signatures
|
||||||
* @param {Array<module:key~Key>} keys array of keys to verify signatures
|
* @param {Array<module:key.Key>} keys array of keys to verify signatures
|
||||||
* @param {Date} date (optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time
|
* @param {Date} date (optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time
|
||||||
* @returns {Promise<Array<({keyid: module:type/keyid, valid: Boolean})>>} list of signer's keyid and validity of signature
|
* @returns {Promise<Array<({keyid: module:type/keyid, valid: Boolean})>>} list of signer's keyid and validity of signature
|
||||||
* @async
|
* @async
|
||||||
|
@ -525,7 +526,7 @@ Message.prototype.verify = function(keys, date=new Date()) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify detached message signature
|
* Verify detached message signature
|
||||||
* @param {Array<module:key~Key>} keys array of keys to verify signatures
|
* @param {Array<module:key.Key>} keys array of keys to verify signatures
|
||||||
* @param {Signature} signature
|
* @param {Signature} signature
|
||||||
* @param {Date} date Verify the signature against the given date, i.e. check signature creation time < date < expiration time
|
* @param {Date} date Verify the signature against the given date, i.e. check signature creation time < date < expiration time
|
||||||
* @returns {Promise<Array<({keyid: module:type/keyid, valid: Boolean})>>} list of signer's keyid and validity of signature
|
* @returns {Promise<Array<({keyid: module:type/keyid, valid: Boolean})>>} list of signer's keyid and validity of signature
|
||||||
|
@ -543,9 +544,9 @@ Message.prototype.verifyDetached = function(signature, keys, date=new Date()) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create list of objects containing signer's keyid and validity of signature
|
* Create list of objects containing signer's keyid and validity of signature
|
||||||
* @param {Array<module:packet/signature>} signatureList array of signature packets
|
* @param {Array<module:packet.Signature>} signatureList array of signature packets
|
||||||
* @param {Array<module:packet/literal>} literalDataList array of literal data packets
|
* @param {Array<module:packet.Literal>} literalDataList array of literal data packets
|
||||||
* @param {Array<module:key~Key>} keys array of keys to verify signatures
|
* @param {Array<module:key.Key>} keys array of keys to verify signatures
|
||||||
* @param {Date} date Verify the signature against the given date,
|
* @param {Date} date Verify the signature against the given date,
|
||||||
* i.e. check signature creation time < date < expiration time
|
* i.e. check signature creation time < date < expiration time
|
||||||
* @returns {Promise<Array<{keyid: module:type/keyid,
|
* @returns {Promise<Array<{keyid: module:type/keyid,
|
||||||
|
@ -578,7 +579,7 @@ export async function createVerificationObjects(signatureList, literalDataList,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unwrap compressed message
|
* Unwrap compressed message
|
||||||
* @returns {module:message~Message} message Content of compressed message
|
* @returns {module:message.Message} message Content of compressed message
|
||||||
*/
|
*/
|
||||||
Message.prototype.unwrapCompressed = function() {
|
Message.prototype.unwrapCompressed = function() {
|
||||||
const compressed = this.packets.filterByTag(enums.packet.compressed);
|
const compressed = this.packets.filterByTag(enums.packet.compressed);
|
||||||
|
@ -607,7 +608,7 @@ Message.prototype.armor = function() {
|
||||||
/**
|
/**
|
||||||
* reads an OpenPGP armored message and returns a message object
|
* reads an OpenPGP armored message and returns a message object
|
||||||
* @param {String} armoredText text to be parsed
|
* @param {String} armoredText text to be parsed
|
||||||
* @returns {module:message~Message} new message object
|
* @returns {module:message.Message} new message object
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
export function readArmored(armoredText) {
|
export function readArmored(armoredText) {
|
||||||
|
@ -634,7 +635,7 @@ export function read(input) {
|
||||||
* @param {String} text
|
* @param {String} text
|
||||||
* @param {String} filename (optional)
|
* @param {String} filename (optional)
|
||||||
* @param {Date} date (optional)
|
* @param {Date} date (optional)
|
||||||
* @returns {module:message~Message} new message object
|
* @returns {module:message.Message} new message object
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
export function fromText(text, filename, date=new Date()) {
|
export function fromText(text, filename, date=new Date()) {
|
||||||
|
@ -654,7 +655,7 @@ export function fromText(text, filename, date=new Date()) {
|
||||||
* @param {Uint8Array} bytes
|
* @param {Uint8Array} bytes
|
||||||
* @param {String} filename (optional)
|
* @param {String} filename (optional)
|
||||||
* @param {Date} date (optional)
|
* @param {Date} date (optional)
|
||||||
* @returns {module:message~Message} new message object
|
* @returns {module:message.Message} new message object
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
export function fromBinary(bytes, filename, date=new Date()) {
|
export function fromBinary(bytes, filename, date=new Date()) {
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @fileoverview The openpgp base module should provide all of the functionality
|
||||||
|
* to consume the openpgp.js library. All additional classes are documented
|
||||||
|
* for extending and developing on top of the base library.
|
||||||
* @requires message
|
* @requires message
|
||||||
* @requires cleartext
|
* @requires cleartext
|
||||||
* @requires key
|
* @requires key
|
||||||
|
@ -26,10 +29,12 @@
|
||||||
* @module openpgp
|
* @module openpgp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// This file intentionally has two separate file overviews so that
|
||||||
|
// a reference to this module appears at the end of doc/index.html.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fileoverview The openpgp base module should provide all of the functionality
|
* @fileoverview To view the full API documentation, start from
|
||||||
* to consume the openpgp.js library. All additional classes are documented
|
* {@link module:openpgp}
|
||||||
* for extending and developing on top of the base library.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as messageLib from './message';
|
import * as messageLib from './message';
|
||||||
|
@ -68,7 +73,7 @@ export function initWorker({ path='openpgp.worker.js', n = 1, workers = [] } = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the async proxy if the worker was initialized with openpgp.initWorker()
|
* Returns a reference to the async proxy if the worker was initialized with openpgp.initWorker()
|
||||||
* @returns {module:worker/async_proxy~AsyncProxy|null} the async proxy or null if not initialized
|
* @returns {module:worker/async_proxy.AsyncProxy|null} the async proxy or null if not initialized
|
||||||
*/
|
*/
|
||||||
export function getWorker() {
|
export function getWorker() {
|
||||||
return asyncProxy;
|
return asyncProxy;
|
||||||
|
|
|
@ -1,44 +1,80 @@
|
||||||
/**
|
/**
|
||||||
|
* @fileoverview Exports all OpenPGP packet types
|
||||||
* @requires enums
|
* @requires enums
|
||||||
|
* @module packet/all_packets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import enums from '../enums.js';
|
import enums from '../enums.js';
|
||||||
import * as packets from './all_packets.js'; // re-import module to parse packets from tag
|
import * as packets from './all_packets.js'; // re-import module to parse packets from tag
|
||||||
|
|
||||||
/** @see module:packet/compressed */
|
export {
|
||||||
export { default as Compressed } from './compressed.js';
|
/** @see module:packet.Compressed */
|
||||||
/** @see module:packet/sym_encrypted_integrity_protected */
|
default as Compressed
|
||||||
export { default as SymEncryptedIntegrityProtected } from './sym_encrypted_integrity_protected.js';
|
} from './compressed.js';
|
||||||
/** @see module:packet/sym_encrypted_aead_protected */
|
export {
|
||||||
export { default as SymEncryptedAEADProtected } from './sym_encrypted_aead_protected.js';
|
/** @see module:packet.SymEncryptedIntegrityProtected */
|
||||||
/** @see module:packet/public_key_encrypted_session_key */
|
default as SymEncryptedIntegrityProtected
|
||||||
export { default as PublicKeyEncryptedSessionKey } from './public_key_encrypted_session_key.js';
|
} from './sym_encrypted_integrity_protected.js';
|
||||||
/** @see module:packet/sym_encrypted_session_key */
|
export {
|
||||||
export { default as SymEncryptedSessionKey } from './sym_encrypted_session_key.js';
|
/** @see module:packet.SymEncryptedAEADProtected */
|
||||||
/** @see module:packet/literal */
|
default as SymEncryptedAEADProtected
|
||||||
export { default as Literal } from './literal.js';
|
} from './sym_encrypted_aead_protected.js';
|
||||||
/** @see module:packet/public_key */
|
export {
|
||||||
export { default as PublicKey } from './public_key.js';
|
/** @see module:packet.PublicKeyEncryptedSessionKey */
|
||||||
/** @see module:packet/symmetrically_encrypted */
|
default as PublicKeyEncryptedSessionKey
|
||||||
export { default as SymmetricallyEncrypted } from './symmetrically_encrypted.js';
|
} from './public_key_encrypted_session_key.js';
|
||||||
/** @see module:packet/marker */
|
export {
|
||||||
export { default as Marker } from './marker.js';
|
/** @see module:packet.SymEncryptedSessionKey */
|
||||||
/** @see module:packet/public_subkey */
|
default as SymEncryptedSessionKey
|
||||||
export { default as PublicSubkey } from './public_subkey.js';
|
} from './sym_encrypted_session_key.js';
|
||||||
/** @see module:packet/user_attribute */
|
export {
|
||||||
export { default as UserAttribute } from './user_attribute.js';
|
/** @see module:packet.Literal */
|
||||||
/** @see module:packet/one_pass_signature */
|
default as Literal
|
||||||
export { default as OnePassSignature } from './one_pass_signature.js';
|
} from './literal.js';
|
||||||
/** @see module:packet/secret_key */
|
export {
|
||||||
export { default as SecretKey } from './secret_key.js';
|
/** @see module:packet.PublicKey */
|
||||||
/** @see module:packet/userid */
|
default as PublicKey
|
||||||
export { default as Userid } from './userid.js';
|
} from './public_key.js';
|
||||||
/** @see module:packet/secret_subkey */
|
export {
|
||||||
export { default as SecretSubkey } from './secret_subkey.js';
|
/** @see module:packet.SymmetricallyEncrypted */
|
||||||
/** @see module:packet/signature */
|
default as SymmetricallyEncrypted
|
||||||
export { default as Signature } from './signature.js';
|
} from './symmetrically_encrypted.js';
|
||||||
/** @see module:packet/trust */
|
export {
|
||||||
export { default as Trust } from './trust.js';
|
/** @see module:packet.Marker */
|
||||||
|
default as Marker
|
||||||
|
} from './marker.js';
|
||||||
|
export {
|
||||||
|
/** @see module:packet.PublicSubkey */
|
||||||
|
default as PublicSubkey
|
||||||
|
} from './public_subkey.js';
|
||||||
|
export {
|
||||||
|
/** @see module:packet.UserAttribute */
|
||||||
|
default as UserAttribute
|
||||||
|
} from './user_attribute.js';
|
||||||
|
export {
|
||||||
|
/** @see module:packet.OnePassSignature */
|
||||||
|
default as OnePassSignature
|
||||||
|
} from './one_pass_signature.js';
|
||||||
|
export {
|
||||||
|
/** @see module:packet.SecretKey */
|
||||||
|
default as SecretKey
|
||||||
|
} from './secret_key.js';
|
||||||
|
export {
|
||||||
|
/** @see module:packet.Userid */
|
||||||
|
default as Userid
|
||||||
|
} from './userid.js';
|
||||||
|
export {
|
||||||
|
/** @see module:packet.SecretSubkey */
|
||||||
|
default as SecretSubkey
|
||||||
|
} from './secret_subkey.js';
|
||||||
|
export {
|
||||||
|
/** @see module:packet.Signature */
|
||||||
|
default as Signature
|
||||||
|
} from './signature.js';
|
||||||
|
export {
|
||||||
|
/** @see module:packet.Trust */
|
||||||
|
default as Trust
|
||||||
|
} from './trust.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new packet
|
* Allocate a new packet
|
||||||
|
|
|
@ -47,7 +47,7 @@ function Compressed() {
|
||||||
this.tag = enums.packet.compressed;
|
this.tag = enums.packet.compressed;
|
||||||
/**
|
/**
|
||||||
* List of packets
|
* List of packets
|
||||||
* @type {module:packet/packetlist}
|
* @type {module:packet.List}
|
||||||
*/
|
*/
|
||||||
this.packets = null;
|
this.packets = null;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* @fileoverview OpenPGP packet types
|
* @fileoverview OpenPGP packet types
|
||||||
* @see module:packet/all_packets
|
* @see module:packet/all_packets
|
||||||
* @see module:packet/packetlist
|
|
||||||
* @see module:packet/clone
|
* @see module:packet/clone
|
||||||
|
* @see module:packet.List
|
||||||
* @module packet
|
* @module packet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ Literal.prototype.getFilename = function() {
|
||||||
* Parsing function for a literal data packet (tag 11).
|
* Parsing function for a literal data packet (tag 11).
|
||||||
*
|
*
|
||||||
* @param {Uint8Array} input Payload of a tag 11 packet
|
* @param {Uint8Array} input Payload of a tag 11 packet
|
||||||
* @returns {module:packet/literal} object representation
|
* @returns {module:packet.Literal} object representation
|
||||||
*/
|
*/
|
||||||
Literal.prototype.read = function(bytes) {
|
Literal.prototype.read = function(bytes) {
|
||||||
// - A one-octet field that describes how the data is formatted.
|
// - A one-octet field that describes how the data is formatted.
|
||||||
|
|
|
@ -47,7 +47,7 @@ function Marker() {
|
||||||
* @param {Integer} len
|
* @param {Integer} len
|
||||||
* Length of the packet or the remaining length of
|
* Length of the packet or the remaining length of
|
||||||
* input at position
|
* input at position
|
||||||
* @returns {module:packet/marker} Object representation
|
* @returns {module:packet.Marker} Object representation
|
||||||
*/
|
*/
|
||||||
Marker.prototype.read = function (bytes) {
|
Marker.prototype.read = function (bytes) {
|
||||||
if (bytes[0] === 0x50 && // P
|
if (bytes[0] === 0x50 && // P
|
||||||
|
|
|
@ -74,7 +74,7 @@ function OnePassSignature() {
|
||||||
/**
|
/**
|
||||||
* parsing function for a one-pass signature packet (tag 4).
|
* parsing function for a one-pass signature packet (tag 4).
|
||||||
* @param {Uint8Array} bytes payload of a tag 4 packet
|
* @param {Uint8Array} bytes payload of a tag 4 packet
|
||||||
* @returns {module:packet/one_pass_signature} object representation
|
* @returns {module:packet.OnePassSignature} object representation
|
||||||
*/
|
*/
|
||||||
OnePassSignature.prototype.read = function (bytes) {
|
OnePassSignature.prototype.read = function (bytes) {
|
||||||
let mypos = 0;
|
let mypos = 0;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* eslint-disable callback-return */
|
/* eslint-disable callback-return */
|
||||||
/**
|
/**
|
||||||
* @fileoverview Provides a class for representing lists of OpenPGP packets.
|
|
||||||
* @requires packet/all_packets
|
* @requires packet/all_packets
|
||||||
* @requires packet/packet
|
* @requires packet/packet
|
||||||
* @requires config
|
* @requires config
|
||||||
|
|
|
@ -16,13 +16,6 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME
|
|
||||||
* Implementation of the Key Material Packet (Tag 5,6,7,14)
|
|
||||||
*
|
|
||||||
* {@link https://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}:
|
|
||||||
* A key material packet contains all the information about a public or
|
|
||||||
* private key. There are four variants of this packet type, and two
|
|
||||||
* major versions. Consequently, this section is complex.
|
|
||||||
* @requires type/keyid
|
* @requires type/keyid
|
||||||
* @requires type/mpi
|
* @requires type/mpi
|
||||||
* @requires crypto
|
* @requires crypto
|
||||||
|
@ -37,20 +30,43 @@ import enums from '../enums';
|
||||||
import util from '../util';
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Implementation of the Key Material Packet (Tag 5,6,7,14)
|
||||||
|
*
|
||||||
|
* {@link https://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}:
|
||||||
|
* A key material packet contains all the information about a public or
|
||||||
|
* private key. There are four variants of this packet type, and two
|
||||||
|
* major versions.
|
||||||
|
*
|
||||||
* A Public-Key packet starts a series of packets that forms an OpenPGP
|
* A Public-Key packet starts a series of packets that forms an OpenPGP
|
||||||
* key (sometimes called an OpenPGP certificate).
|
* key (sometimes called an OpenPGP certificate).
|
||||||
* @memberof module:packet
|
* @memberof module:packet
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function PublicKey() {
|
function PublicKey() {
|
||||||
|
/**
|
||||||
|
* Packet type
|
||||||
|
* @type {module:enums.packet}
|
||||||
|
*/
|
||||||
this.tag = enums.packet.publicKey;
|
this.tag = enums.packet.publicKey;
|
||||||
|
/**
|
||||||
|
* Packet version
|
||||||
|
* @type {Integer}
|
||||||
|
*/
|
||||||
this.version = 4;
|
this.version = 4;
|
||||||
/** Key creation date.
|
/**
|
||||||
* @type {Date} */
|
* Key creation date.
|
||||||
|
* @type {Date}
|
||||||
|
*/
|
||||||
this.created = util.normalizeDate();
|
this.created = util.normalizeDate();
|
||||||
/* Algorithm specific params */
|
/**
|
||||||
|
* Algorithm specific params
|
||||||
|
* @type {Array<Object>}
|
||||||
|
*/
|
||||||
this.params = [];
|
this.params = [];
|
||||||
// time in days (V3 only)
|
/**
|
||||||
|
* Time until expiration in days (V3 only)
|
||||||
|
* @type {Integer}
|
||||||
|
*/
|
||||||
this.expirationTimeV3 = 0;
|
this.expirationTimeV3 = 0;
|
||||||
/**
|
/**
|
||||||
* Fingerprint in lowercase hex
|
* Fingerprint in lowercase hex
|
||||||
|
@ -110,7 +126,7 @@ PublicKey.prototype.read = function (bytes) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias of read()
|
* Alias of read()
|
||||||
* @see module:packet/public_key~PublicKey#read
|
* @see module:packet.PublicKey#read
|
||||||
*/
|
*/
|
||||||
PublicKey.prototype.readPublicKey = PublicKey.prototype.read;
|
PublicKey.prototype.readPublicKey = PublicKey.prototype.read;
|
||||||
|
|
||||||
|
@ -140,7 +156,7 @@ PublicKey.prototype.write = function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias of write()
|
* Alias of write()
|
||||||
* @see module:packet/public_key~PublicKey#write
|
* @see module:packet.PublicKey#write
|
||||||
*/
|
*/
|
||||||
PublicKey.prototype.writePublicKey = PublicKey.prototype.write;
|
PublicKey.prototype.writePublicKey = PublicKey.prototype.write;
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ function PublicKeyEncryptedSessionKey() {
|
||||||
* @param {Integer} position Position to start reading from the input string
|
* @param {Integer} position Position to start reading from the input string
|
||||||
* @param {Integer} len Length of the packet or the remaining length of
|
* @param {Integer} len Length of the packet or the remaining length of
|
||||||
* input at position
|
* input at position
|
||||||
* @returns {module:packet/public_key_encrypted_session_key} Object representation
|
* @returns {module:packet.PublicKeyEncryptedSessionKey} Object representation
|
||||||
*/
|
*/
|
||||||
PublicKeyEncryptedSessionKey.prototype.read = function (bytes) {
|
PublicKeyEncryptedSessionKey.prototype.read = function (bytes) {
|
||||||
this.version = bytes[0];
|
this.version = bytes[0];
|
||||||
|
@ -102,7 +102,7 @@ PublicKeyEncryptedSessionKey.prototype.write = function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt session key packet
|
* Encrypt session key packet
|
||||||
* @param {module:packet/public_key} key Public key
|
* @param {module:packet.PublicKey} key Public key
|
||||||
* @returns {Promise<Boolean>}
|
* @returns {Promise<Boolean>}
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
|
@ -130,7 +130,7 @@ PublicKeyEncryptedSessionKey.prototype.encrypt = async function (key) {
|
||||||
* Decrypts the session key (only for public key encrypted session key
|
* Decrypts the session key (only for public key encrypted session key
|
||||||
* packets (tag 1)
|
* packets (tag 1)
|
||||||
*
|
*
|
||||||
* @param {module:packet/secret_key} key
|
* @param {module:packet.SecretKey} key
|
||||||
* Private key with secret params unlocked
|
* Private key with secret params unlocked
|
||||||
* @returns {Promise<Boolean>}
|
* @returns {Promise<Boolean>}
|
||||||
* @async
|
* @async
|
||||||
|
|
|
@ -16,13 +16,6 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME
|
|
||||||
* Implementation of the Key Material Packet (Tag 5,6,7,14)
|
|
||||||
*
|
|
||||||
* {@link https://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}:
|
|
||||||
* A key material packet contains all the information about a public or
|
|
||||||
* private key. There are four variants of this packet type, and two
|
|
||||||
* major versions. Consequently, this section is complex.
|
|
||||||
* @requires packet/public_key
|
* @requires packet/public_key
|
||||||
* @requires type/keyid
|
* @requires type/keyid
|
||||||
* @requires type/s2k
|
* @requires type/s2k
|
||||||
|
@ -48,10 +41,18 @@ import util from '../util';
|
||||||
*/
|
*/
|
||||||
function SecretKey() {
|
function SecretKey() {
|
||||||
publicKey.call(this);
|
publicKey.call(this);
|
||||||
|
/**
|
||||||
|
* Packet type
|
||||||
|
* @type {module:enums.packet}
|
||||||
|
*/
|
||||||
this.tag = enums.packet.secretKey;
|
this.tag = enums.packet.secretKey;
|
||||||
// encrypted secret-key data
|
/**
|
||||||
|
* Encrypted secret-key data
|
||||||
|
*/
|
||||||
this.encrypted = null;
|
this.encrypted = null;
|
||||||
// indicator if secret-key data is available in decrypted form
|
/**
|
||||||
|
* Indicator if secret-key data is available in decrypted form
|
||||||
|
*/
|
||||||
this.isDecrypted = false;
|
this.isDecrypted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +124,8 @@ function write_cleartext_params(hash_algorithm, algorithm, params) {
|
||||||
// 5.5.3. Secret-Key Packet Formats
|
// 5.5.3. Secret-Key Packet Formats
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal parser for private keys as specified in {@link https://tools.ietf.org/html/rfc4880#section-5.5.3|RFC 4880 section 5.5.3}
|
* Internal parser for private keys as specified in
|
||||||
|
* {@link https://tools.ietf.org/html/rfc4880#section-5.5.3|RFC 4880 section 5.5.3}
|
||||||
* @param {String} bytes Input string to read the packet from
|
* @param {String} bytes Input string to read the packet from
|
||||||
*/
|
*/
|
||||||
SecretKey.prototype.read = function (bytes) {
|
SecretKey.prototype.read = function (bytes) {
|
||||||
|
@ -154,9 +156,10 @@ SecretKey.prototype.read = function (bytes) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Creates an OpenPGP key packet for the given key.
|
/**
|
||||||
* @returns {String} A string of bytes containing the secret key OpenPGP packet
|
* Creates an OpenPGP key packet for the given key.
|
||||||
*/
|
* @returns {String} A string of bytes containing the secret key OpenPGP packet
|
||||||
|
*/
|
||||||
SecretKey.prototype.write = function () {
|
SecretKey.prototype.write = function () {
|
||||||
const arr = [this.writePublicKey()];
|
const arr = [this.writePublicKey()];
|
||||||
|
|
||||||
|
@ -171,7 +174,8 @@ SecretKey.prototype.write = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Encrypt the payload. By default, we use aes256 and iterated, salted string
|
/**
|
||||||
|
* Encrypt the payload. By default, we use aes256 and iterated, salted string
|
||||||
* to key specifier. If the key is in a decrypted state (isDecrypted === true)
|
* to key specifier. If the key is in a decrypted state (isDecrypted === true)
|
||||||
* and the passphrase is empty or undefined, the key will be set as not encrypted.
|
* 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().
|
* This can be used to remove passphrase protection after calling decrypt().
|
||||||
|
@ -213,9 +217,8 @@ function produceEncryptionKey(s2k, passphrase, algorithm) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts the private key params which are needed to use the key.
|
* Decrypts the private key params which are needed to use the key.
|
||||||
* @link module:packet/secret_key.isDecrypted should be
|
* {@link module:packet.SecretKey.isDecrypted} should be false, as
|
||||||
* false otherwise a call to this function is not needed
|
* otherwise calls to this function will throw an error.
|
||||||
*
|
|
||||||
* @param {String} passphrase The passphrase for this private key as string
|
* @param {String} passphrase The passphrase for this private key as string
|
||||||
* @returns {Promise<Boolean>}
|
* @returns {Promise<Boolean>}
|
||||||
* @async
|
* @async
|
||||||
|
|
|
@ -94,7 +94,7 @@ function Signature(date=new Date()) {
|
||||||
* @param {String} bytes payload of a tag 2 packet
|
* @param {String} bytes payload of a tag 2 packet
|
||||||
* @param {Integer} position position to start reading from the bytes string
|
* @param {Integer} position position to start reading from the bytes string
|
||||||
* @param {Integer} len length of the packet or the remaining length of bytes at position
|
* @param {Integer} len length of the packet or the remaining length of bytes at position
|
||||||
* @returns {module:packet/signature} object representation
|
* @returns {module:packet.Signature} object representation
|
||||||
*/
|
*/
|
||||||
Signature.prototype.read = function (bytes) {
|
Signature.prototype.read = function (bytes) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
@ -210,7 +210,7 @@ Signature.prototype.write = function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signs provided data. This needs to be done prior to serialization.
|
* Signs provided data. This needs to be done prior to serialization.
|
||||||
* @param {module:packet/secret_key} key private key used to sign the message.
|
* @param {module:packet.SecretKey} key private key used to sign the message.
|
||||||
* @param {Object} data Contains packets to be signed.
|
* @param {Object} data Contains packets to be signed.
|
||||||
* @returns {Promise<Boolean>}
|
* @returns {Promise<Boolean>}
|
||||||
* @async
|
* @async
|
||||||
|
@ -619,8 +619,8 @@ Signature.prototype.calculateTrailer = function () {
|
||||||
/**
|
/**
|
||||||
* verifys the signature packet. Note: not signature types are implemented
|
* verifys the signature packet. Note: not signature types are implemented
|
||||||
* @param {String|Object} data data which on the signature applies
|
* @param {String|Object} data data which on the signature applies
|
||||||
* @param {module:packet/public_subkey|module:packet/public_key|
|
* @param {module:packet.PublicSubkey|module:packet.PublicKey|
|
||||||
* module:packet/secret_subkey|module:packet/secret_key} key the public key to verify the signature
|
* module:packet.SecretSubkey|module:packet.SecretKey} key the public key to verify the signature
|
||||||
* @returns {Promise<Boolean>} True if message is verified, else false.
|
* @returns {Promise<Boolean>} True if message is verified, else false.
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -63,7 +63,7 @@ function SymEncryptedSessionKey() {
|
||||||
* @param {Integer} len
|
* @param {Integer} len
|
||||||
* Length of the packet or the remaining length of
|
* Length of the packet or the remaining length of
|
||||||
* input at position
|
* input at position
|
||||||
* @returns {module:packet/sym_encrypted_session_key} Object representation
|
* @returns {module:packet.SymEncryptedSessionKey} Object representation
|
||||||
*/
|
*/
|
||||||
SymEncryptedSessionKey.prototype.read = function(bytes) {
|
SymEncryptedSessionKey.prototype.read = function(bytes) {
|
||||||
// A one-octet version number. The only currently defined version is 4.
|
// A one-octet version number. The only currently defined version is 4.
|
||||||
|
|
|
@ -38,11 +38,24 @@ import enums from '../enums';
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function SymmetricallyEncrypted() {
|
function SymmetricallyEncrypted() {
|
||||||
|
/**
|
||||||
|
* Packet type
|
||||||
|
* @type {module:enums.packet}
|
||||||
|
*/
|
||||||
this.tag = enums.packet.symmetricallyEncrypted;
|
this.tag = enums.packet.symmetricallyEncrypted;
|
||||||
|
/**
|
||||||
|
* Encrypted secret-key data
|
||||||
|
*/
|
||||||
this.encrypted = null;
|
this.encrypted = null;
|
||||||
/** Decrypted packets contained within.
|
/**
|
||||||
* @type {module:packet/packetlist} */
|
* Decrypted packets contained within.
|
||||||
|
* @type {module:packet.List}
|
||||||
|
*/
|
||||||
this.packets = null;
|
this.packets = null;
|
||||||
|
/**
|
||||||
|
* When true, decrypt fails if message is not integrity protected
|
||||||
|
* @see module:config.ignore_mdc_error
|
||||||
|
*/
|
||||||
this.ignore_mdc_error = config.ignore_mdc_error;
|
this.ignore_mdc_error = config.ignore_mdc_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +69,8 @@ SymmetricallyEncrypted.prototype.write = function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypt the symmetrically-encrypted packet data
|
* Decrypt the symmetrically-encrypted packet data
|
||||||
* @param {module:enums.symmetric} sessionKeyAlgorithm
|
* See {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC 4880 9.2} for algorithms.
|
||||||
* Symmetric key algorithm to use // See {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880 9.2}
|
* @param {module:enums.symmetric} sessionKeyAlgorithm Symmetric key algorithm to use
|
||||||
* @param {Uint8Array} key The key of cipher blocksize length to be used
|
* @param {Uint8Array} key The key of cipher blocksize length to be used
|
||||||
* @returns {Promise<Boolean>}
|
* @returns {Promise<Boolean>}
|
||||||
* @async
|
* @async
|
||||||
|
@ -78,8 +91,8 @@ SymmetricallyEncrypted.prototype.decrypt = async function (sessionKeyAlgorithm,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt the symmetrically-encrypted packet data
|
* Encrypt the symmetrically-encrypted packet data
|
||||||
* @param {module:enums.symmetric} sessionKeyAlgorithm
|
* See {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC 4880 9.2} for algorithms.
|
||||||
* Symmetric key algorithm to use // See {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880 9.2}
|
* @param {module:enums.symmetric} sessionKeyAlgorithm Symmetric key algorithm to use
|
||||||
* @param {Uint8Array} key The key of cipher blocksize length to be used
|
* @param {Uint8Array} key The key of cipher blocksize length to be used
|
||||||
* @returns {Promise<Boolean>}
|
* @returns {Promise<Boolean>}
|
||||||
* @async
|
* @async
|
||||||
|
|
|
@ -79,7 +79,7 @@ UserAttribute.prototype.write = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare for equality
|
* Compare for equality
|
||||||
* @param {module:user_attribute~UserAttribute} usrAttr
|
* @param {module:packet.UserAttribute} usrAttr
|
||||||
* @returns {Boolean} true if equal
|
* @returns {Boolean} true if equal
|
||||||
*/
|
*/
|
||||||
UserAttribute.prototype.equals = function(usrAttr) {
|
UserAttribute.prototype.equals = function(usrAttr) {
|
||||||
|
|
|
@ -16,22 +16,21 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires enums
|
|
||||||
* @requires packet
|
|
||||||
* @requires encoding/armor
|
* @requires encoding/armor
|
||||||
|
* @requires packet
|
||||||
|
* @requires enums
|
||||||
* @module signature
|
* @module signature
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import armor from './encoding/armor';
|
||||||
import packet from './packet';
|
import packet from './packet';
|
||||||
import enums from './enums';
|
import enums from './enums';
|
||||||
import armor from './encoding/armor';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
* @classdesc Class that represents an OpenPGP signature.
|
* @classdesc Class that represents an OpenPGP signature.
|
||||||
* @param {module:packet/packetlist} packetlist The signature packets
|
* @param {module:packet.List} packetlist The signature packets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function Signature(packetlist) {
|
export function Signature(packetlist) {
|
||||||
if (!(this instanceof Signature)) {
|
if (!(this instanceof Signature)) {
|
||||||
return new Signature(packetlist);
|
return new Signature(packetlist);
|
||||||
|
|
|
@ -63,11 +63,11 @@ function handleMessage(workerId) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new proxy and loads the web worker
|
* Initializes a new proxy and loads the web worker
|
||||||
* @constructor
|
|
||||||
* @param {String} path The path to the worker or 'openpgp.worker.js' by default
|
* @param {String} path The path to the worker or 'openpgp.worker.js' by default
|
||||||
* @param {Number} n number of workers to initialize if path given
|
* @param {Number} n number of workers to initialize if path given
|
||||||
* @param {Object} config config The worker configuration
|
* @param {Object} config config The worker configuration
|
||||||
* @param {Array<Object>} worker alternative to path parameter: web worker initialized with 'openpgp.worker.js'
|
* @param {Array<Object>} worker alternative to path parameter: web worker initialized with 'openpgp.worker.js'
|
||||||
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function AsyncProxy({ path='openpgp.worker.js', n = 1, workers = [], config } = {}) {
|
function AsyncProxy({ path='openpgp.worker.js', n = 1, workers = [], config } = {}) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user