Documentation improvements in src/packet
This commit is contained in:
parent
a5e7562066
commit
4ded3f9d58
|
@ -1,6 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @module packet/all_packets
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import enums from '../enums.js';
|
import enums from '../enums.js';
|
||||||
|
@ -43,6 +42,8 @@ export { default as Trust } from './trust.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new packet
|
* Allocate a new packet
|
||||||
|
* @function newPacketFromTag
|
||||||
|
* @memberof module:packet
|
||||||
* @param {String} tag property name from {@link module:enums.packet}
|
* @param {String} tag property name from {@link module:enums.packet}
|
||||||
* @returns {Object} new packet object with type based on tag
|
* @returns {Object} new packet object with type based on tag
|
||||||
*/
|
*/
|
||||||
|
@ -52,7 +53,9 @@ export function newPacketFromTag(tag) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new packet from structured packet clone
|
* Allocate a new packet from structured packet clone
|
||||||
* See {@link https://w3c.github.io/html/infrastructure.html#safe-passing-of-structured-data}
|
* @see {@link https://w3c.github.io/html/infrastructure.html#safe-passing-of-structured-data}
|
||||||
|
* @function fromStructuredClone
|
||||||
|
* @memberof module:packet
|
||||||
* @param {Object} packetClone packet clone
|
* @param {Object} packetClone packet clone
|
||||||
* @returns {Object} new packet object with data from packet clone
|
* @returns {Object} new packet object with data from packet clone
|
||||||
*/
|
*/
|
||||||
|
@ -74,6 +77,7 @@ export function fromStructuredClone(packetClone) {
|
||||||
* Convert tag name to class name
|
* Convert tag name to class name
|
||||||
* @param {String} tag property name from {@link module:enums.packet}
|
* @param {String} tag property name from {@link module:enums.packet}
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
|
* @private
|
||||||
*/
|
*/
|
||||||
function packetClassFromTagName(tag) {
|
function packetClassFromTagName(tag) {
|
||||||
return tag.substr(0, 1).toUpperCase() + tag.substr(1);
|
return tag.substr(0, 1).toUpperCase() + tag.substr(1);
|
||||||
|
|
|
@ -26,14 +26,14 @@ import { Key } from '../key';
|
||||||
import { Message } from '../message';
|
import { Message } from '../message';
|
||||||
import { CleartextMessage } from '../cleartext';
|
import { CleartextMessage } from '../cleartext';
|
||||||
import { Signature } from '../signature';
|
import { Signature } from '../signature';
|
||||||
import Packetlist from './packetlist';
|
import List from './packetlist';
|
||||||
import type_keyid from '../type/keyid';
|
import type_keyid from '../type/keyid';
|
||||||
import util from '../util';
|
import util from '../util';
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// //
|
// //
|
||||||
// Packetlist --> Clone //
|
// List --> Clone //
|
||||||
// //
|
// //
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ function verificationObjectToClone(verObject) {
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// //
|
// //
|
||||||
// Clone --> Packetlist //
|
// Clone --> List //
|
||||||
// //
|
// //
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
|
@ -119,17 +119,17 @@ export function parseClonedPackets(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function packetlistCloneToKey(clone) {
|
function packetlistCloneToKey(clone) {
|
||||||
const packetlist = Packetlist.fromStructuredClone(clone);
|
const packetlist = List.fromStructuredClone(clone);
|
||||||
return new Key(packetlist);
|
return new Key(packetlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
function packetlistCloneToMessage(clone) {
|
function packetlistCloneToMessage(clone) {
|
||||||
const packetlist = Packetlist.fromStructuredClone(clone);
|
const packetlist = List.fromStructuredClone(clone);
|
||||||
return new Message(packetlist);
|
return new Message(packetlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
function packetlistCloneToCleartextMessage(clone) {
|
function packetlistCloneToCleartextMessage(clone) {
|
||||||
const packetlist = Packetlist.fromStructuredClone(clone.signature);
|
const packetlist = List.fromStructuredClone(clone.signature);
|
||||||
return new CleartextMessage(clone.text, new Signature(packetlist));
|
return new CleartextMessage(clone.text, new Signature(packetlist));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,6 @@ function packetlistCloneToSignature(clone) {
|
||||||
//signature is armored
|
//signature is armored
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
const packetlist = Packetlist.fromStructuredClone(clone);
|
const packetlist = List.fromStructuredClone(clone);
|
||||||
return new Signature(packetlist);
|
return new Signature(packetlist);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,20 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 pako
|
||||||
|
* @requires config
|
||||||
|
* @requires enums
|
||||||
|
* @requires util
|
||||||
|
* @requires compression/bzip2
|
||||||
|
*/
|
||||||
|
|
||||||
|
import pako from 'pako';
|
||||||
|
import config from '../config';
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
import Bzip2 from '../compression/bzip2.build.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Compressed Data Packet (Tag 8)
|
* Implementation of the Compressed Data Packet (Tag 8)
|
||||||
*
|
*
|
||||||
|
@ -22,71 +36,7 @@
|
||||||
* The Compressed Data packet contains compressed data. Typically,
|
* The Compressed Data packet contains compressed data. Typically,
|
||||||
* this packet is found as the contents of an encrypted packet, or following
|
* this packet is found as the contents of an encrypted packet, or following
|
||||||
* a Signature or One-Pass Signature packet, and contains a literal data packet.
|
* a Signature or One-Pass Signature packet, and contains a literal data packet.
|
||||||
* @requires compression/zlib
|
* @memberof module:packet
|
||||||
* @requires compression/rawinflate
|
|
||||||
* @requires compression/rawdeflate
|
|
||||||
* @requires compression/bzip2
|
|
||||||
* @requires enums
|
|
||||||
* @requires util
|
|
||||||
* @module packet/compressed
|
|
||||||
*/
|
|
||||||
|
|
||||||
import pako from 'pako';
|
|
||||||
import config from '../config';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
import util from '../util.js';
|
|
||||||
import Bzip2 from '../compression/bzip2.build.js';
|
|
||||||
|
|
||||||
const nodeZlib = util.getNodeZlib();
|
|
||||||
const Buffer = util.getNodeBuffer();
|
|
||||||
|
|
||||||
function node_zlib(func, options = {}) {
|
|
||||||
return function (data) {
|
|
||||||
return func(data, options);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function pako_zlib(constructor, options = {}) {
|
|
||||||
return function(data) {
|
|
||||||
const obj = new constructor(options);
|
|
||||||
obj.push(data, true);
|
|
||||||
return obj.result;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let compress_fns;
|
|
||||||
let decompress_fns;
|
|
||||||
if (nodeZlib) { // Use Node native zlib for DEFLATE compression/decompression
|
|
||||||
compress_fns = {
|
|
||||||
// eslint-disable-next-line no-sync
|
|
||||||
zip: node_zlib(nodeZlib.deflateRawSync, { level: config.deflate_level }),
|
|
||||||
// eslint-disable-next-line no-sync
|
|
||||||
zlib: node_zlib(nodeZlib.deflateSync, { level: config.deflate_level }),
|
|
||||||
bzip2: Bzip2.compressFile
|
|
||||||
};
|
|
||||||
|
|
||||||
decompress_fns = {
|
|
||||||
// eslint-disable-next-line no-sync
|
|
||||||
zip: node_zlib(nodeZlib.inflateRawSync),
|
|
||||||
// eslint-disable-next-line no-sync
|
|
||||||
zlib: node_zlib(nodeZlib.inflateSync),
|
|
||||||
bzip2: Bzip2.decompressFile
|
|
||||||
};
|
|
||||||
} else { // Use JS fallbacks
|
|
||||||
compress_fns = {
|
|
||||||
zip: pako_zlib(pako.Deflate, { raw: true, level: config.deflate_level }),
|
|
||||||
zlib: pako_zlib(pako.Deflate, { level: config.deflate_level }),
|
|
||||||
bzip2: Bzip2.compressFile
|
|
||||||
};
|
|
||||||
|
|
||||||
decompress_fns = {
|
|
||||||
zip: pako_zlib(pako.Inflate, { raw: true }),
|
|
||||||
zlib: pako_zlib(pako.Inflate),
|
|
||||||
bzip2: Bzip2.decompressFile
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Compressed() {
|
function Compressed() {
|
||||||
|
@ -167,3 +117,59 @@ Compressed.prototype.compress = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Compressed;
|
export default Compressed;
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
// //
|
||||||
|
// Helper functions //
|
||||||
|
// //
|
||||||
|
//////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
const nodeZlib = util.getNodeZlib();
|
||||||
|
const Buffer = util.getNodeBuffer();
|
||||||
|
|
||||||
|
function node_zlib(func, options = {}) {
|
||||||
|
return function (data) {
|
||||||
|
return func(data, options);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function pako_zlib(constructor, options = {}) {
|
||||||
|
return function(data) {
|
||||||
|
const obj = new constructor(options);
|
||||||
|
obj.push(data, true);
|
||||||
|
return obj.result;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let compress_fns;
|
||||||
|
let decompress_fns;
|
||||||
|
if (nodeZlib) { // Use Node native zlib for DEFLATE compression/decompression
|
||||||
|
compress_fns = {
|
||||||
|
// eslint-disable-next-line no-sync
|
||||||
|
zip: node_zlib(nodeZlib.deflateRawSync, { level: config.deflate_level }),
|
||||||
|
// eslint-disable-next-line no-sync
|
||||||
|
zlib: node_zlib(nodeZlib.deflateSync, { level: config.deflate_level }),
|
||||||
|
bzip2: Bzip2.compressFile
|
||||||
|
};
|
||||||
|
|
||||||
|
decompress_fns = {
|
||||||
|
// eslint-disable-next-line no-sync
|
||||||
|
zip: node_zlib(nodeZlib.inflateRawSync),
|
||||||
|
// eslint-disable-next-line no-sync
|
||||||
|
zlib: node_zlib(nodeZlib.inflateSync),
|
||||||
|
bzip2: Bzip2.decompressFile
|
||||||
|
};
|
||||||
|
} else { // Use JS fallbacks
|
||||||
|
compress_fns = {
|
||||||
|
zip: pako_zlib(pako.Deflate, { raw: true, level: config.deflate_level }),
|
||||||
|
zlib: pako_zlib(pako.Deflate, { level: config.deflate_level }),
|
||||||
|
bzip2: Bzip2.compressFile
|
||||||
|
};
|
||||||
|
|
||||||
|
decompress_fns = {
|
||||||
|
zip: pako_zlib(pako.Inflate, { raw: true }),
|
||||||
|
zlib: pako_zlib(pako.Inflate),
|
||||||
|
bzip2: Bzip2.decompressFile
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -6,15 +6,13 @@
|
||||||
* @module packet
|
* @module packet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as packets from './all_packets.js';
|
import * as packets from './all_packets';
|
||||||
import * as clone from './clone.js';
|
import * as clone from './clone';
|
||||||
import List from './packetlist.js';
|
import List from './packetlist';
|
||||||
|
|
||||||
const mod = {
|
const mod = {
|
||||||
/** @see module:packet/packetlist */
|
List,
|
||||||
List: List,
|
clone
|
||||||
/** @see module:packet/clone */
|
|
||||||
clone: clone
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const i in packets) {
|
for (const i in packets) {
|
||||||
|
|
|
@ -15,22 +15,22 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 util
|
||||||
|
*/
|
||||||
|
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Literal Data Packet (Tag 11)
|
* Implementation of the Literal Data Packet (Tag 11)
|
||||||
*
|
*
|
||||||
* {@link https://tools.ietf.org/html/rfc4880#section-5.9|RFC4880 5.9}:
|
* {@link https://tools.ietf.org/html/rfc4880#section-5.9|RFC4880 5.9}:
|
||||||
* A Literal Data packet contains the body of a message; data that is not to be
|
* A Literal Data packet contains the body of a message; data that is not to be
|
||||||
* further interpreted.
|
* further interpreted.
|
||||||
* @requires enums
|
|
||||||
* @requires util
|
|
||||||
* @module packet/literal
|
|
||||||
*/
|
|
||||||
|
|
||||||
import util from '../util.js';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Date} date the creation date of the literal package
|
* @param {Date} date the creation date of the literal package
|
||||||
|
* @memberof module:packet
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Literal(date=new Date()) {
|
function Literal(date=new Date()) {
|
||||||
|
|
|
@ -15,6 +15,12 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
import enums from '../enums';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the strange "Marker packet" (Tag 10)
|
* Implementation of the strange "Marker packet" (Tag 10)
|
||||||
*
|
*
|
||||||
|
@ -25,13 +31,7 @@
|
||||||
* the Marker packet.
|
* the Marker packet.
|
||||||
*
|
*
|
||||||
* Such a packet MUST be ignored when received.
|
* Such a packet MUST be ignored when received.
|
||||||
* @requires enums
|
* @memberof module:packet
|
||||||
* @module packet/marker
|
|
||||||
*/
|
|
||||||
|
|
||||||
import enums from '../enums.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Marker() {
|
function Marker() {
|
||||||
|
|
|
@ -15,6 +15,16 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 type/keyid
|
||||||
|
* @requires enums
|
||||||
|
* @requires util
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type_keyid from '../type/keyid';
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the One-Pass Signature Packets (Tag 4)
|
* Implementation of the One-Pass Signature Packets (Tag 4)
|
||||||
*
|
*
|
||||||
|
@ -24,27 +34,41 @@
|
||||||
* hashes needed to verify the signature. It allows the Signature
|
* hashes needed to verify the signature. It allows the Signature
|
||||||
* packet to be placed at the end of the message, so that the signer
|
* packet to be placed at the end of the message, so that the signer
|
||||||
* can compute the entire signed message in one pass.
|
* can compute the entire signed message in one pass.
|
||||||
* @requires util
|
* @memberof module:packet
|
||||||
* @requires enums
|
|
||||||
* @requires type/keyid
|
|
||||||
* @module packet/one_pass_signature
|
|
||||||
*/
|
|
||||||
|
|
||||||
import util from '../util.js';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
import type_keyid from '../type/keyid.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function OnePassSignature() {
|
function OnePassSignature() {
|
||||||
this.tag = enums.packet.onePassSignature; // The packet type
|
/**
|
||||||
this.version = null; // A one-octet version number. The current version is 3.
|
* Packet type
|
||||||
this.type = null; // A one-octet signature type. Signature types are described in {@link https://tools.ietf.org/html/rfc4880#section-5.2.1|RFC4880 Section 5.2.1}.
|
* @type {module:enums.packet}
|
||||||
this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880 9.4})
|
*/
|
||||||
this.publicKeyAlgorithm = null; // A one-octet number describing the public-key algorithm used. (See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC4880 9.1})
|
this.tag = enums.packet.onePassSignature;
|
||||||
this.signingKeyId = null; // An eight-octet number holding the Key ID of the signing key.
|
/** A one-octet version number. The current version is 3. */
|
||||||
this.flags = null; // A one-octet number holding a flag showing whether the signature is nested. A zero value indicates that the next packet is another One-Pass Signature packet that describes another signature to be applied to the same message data.
|
this.version = null;
|
||||||
|
/**
|
||||||
|
* A one-octet signature type.
|
||||||
|
* Signature types are described in
|
||||||
|
* {@link https://tools.ietf.org/html/rfc4880#section-5.2.1|RFC4880 Section 5.2.1}.
|
||||||
|
*/
|
||||||
|
this.type = null;
|
||||||
|
/**
|
||||||
|
* A one-octet number describing the hash algorithm used.
|
||||||
|
* @see {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880 9.4}
|
||||||
|
*/
|
||||||
|
this.hashAlgorithm = null;
|
||||||
|
/**
|
||||||
|
* A one-octet number describing the public-key algorithm used.
|
||||||
|
* @see {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC4880 9.1}
|
||||||
|
*/
|
||||||
|
this.publicKeyAlgorithm = null;
|
||||||
|
/** An eight-octet number holding the Key ID of the signing key. */
|
||||||
|
this.signingKeyId = null;
|
||||||
|
/**
|
||||||
|
* A one-octet number holding a flag showing whether the signature is nested.
|
||||||
|
* A zero value indicates that the next packet is another One-Pass Signature packet
|
||||||
|
* that describes another signature to be applied to the same message data.
|
||||||
|
*/
|
||||||
|
this.flags = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
* @module packet/packet
|
* @module packet/packet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import util from '../util.js';
|
import util from '../util';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
readSimpleLength: function(bytes) {
|
readSimpleLength: function(bytes) {
|
||||||
|
|
|
@ -1,30 +1,32 @@
|
||||||
/* eslint-disable callback-return */
|
/* eslint-disable callback-return */
|
||||||
/**
|
/**
|
||||||
* @fileoverview Provides a class for representing lists of OpenPGP packets.
|
* @fileoverview Provides a class for representing lists of OpenPGP packets.
|
||||||
* @requires util
|
* @requires packet/all_packets
|
||||||
* @requires enums
|
|
||||||
* @requires packet
|
|
||||||
* @requires packet/packet
|
* @requires packet/packet
|
||||||
* @module packet/packetlist
|
* @requires config
|
||||||
|
* @requires enums
|
||||||
|
* @requires util
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import util from '../util';
|
import * as packets from './all_packets';
|
||||||
import packetParser from './packet.js';
|
import packetParser from './packet';
|
||||||
import * as packets from './all_packets.js';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a list of openpgp packets.
|
* This class represents a list of openpgp packets.
|
||||||
* Take care when iterating over it - the packets themselves
|
* Take care when iterating over it - the packets themselves
|
||||||
* are stored as numerical indices.
|
* are stored as numerical indices.
|
||||||
|
* @memberof module:packet
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Packetlist() {
|
function List() {
|
||||||
/**
|
/**
|
||||||
* The number of packets contained within the list.
|
* The number of packets contained within the list.
|
||||||
* @readonly
|
* @readonly
|
||||||
* @type {Integer} */
|
* @type {Integer}
|
||||||
|
*/
|
||||||
this.length = 0;
|
this.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ function Packetlist() {
|
||||||
* Reads a stream of binary data and interprents it as a list of packets.
|
* Reads a stream of binary data and interprents it as a list of packets.
|
||||||
* @param {Uint8Array} A Uint8Array of bytes.
|
* @param {Uint8Array} A Uint8Array of bytes.
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.read = function (bytes) {
|
List.prototype.read = function (bytes) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < bytes.length) {
|
while (i < bytes.length) {
|
||||||
|
@ -65,7 +67,7 @@ Packetlist.prototype.read = function (bytes) {
|
||||||
* class instance.
|
* class instance.
|
||||||
* @returns {Uint8Array} A Uint8Array containing valid openpgp packets.
|
* @returns {Uint8Array} A Uint8Array containing valid openpgp packets.
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.write = function () {
|
List.prototype.write = function () {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
|
|
||||||
for (let i = 0; i < this.length; i++) {
|
for (let i = 0; i < this.length; i++) {
|
||||||
|
@ -80,13 +82,14 @@ Packetlist.prototype.write = function () {
|
||||||
/**
|
/**
|
||||||
* Adds a packet to the list. This is the only supported method of doing so;
|
* Adds a packet to the list. This is the only supported method of doing so;
|
||||||
* writing to packetlist[i] directly will result in an error.
|
* writing to packetlist[i] directly will result in an error.
|
||||||
|
* @param {Object} packet Packet to push
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.push = function (packet) {
|
List.prototype.push = function (packet) {
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.packets = packet.packets || new Packetlist();
|
packet.packets = packet.packets || new List();
|
||||||
|
|
||||||
this[this.length] = packet;
|
this[this.length] = packet;
|
||||||
this.length++;
|
this.length++;
|
||||||
|
@ -96,7 +99,7 @@ Packetlist.prototype.push = function (packet) {
|
||||||
* Remove a packet from the list and return it.
|
* Remove a packet from the list and return it.
|
||||||
* @returns {Object} The packet that was removed
|
* @returns {Object} The packet that was removed
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.pop = function() {
|
List.prototype.pop = function() {
|
||||||
if (this.length === 0) {
|
if (this.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -111,8 +114,8 @@ Packetlist.prototype.pop = function() {
|
||||||
/**
|
/**
|
||||||
* Creates a new PacketList with all packets that pass the test implemented by the provided function.
|
* Creates a new PacketList with all packets that pass the test implemented by the provided function.
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.filter = function (callback) {
|
List.prototype.filter = function (callback) {
|
||||||
const filtered = new Packetlist();
|
const filtered = new List();
|
||||||
|
|
||||||
for (let i = 0; i < this.length; i++) {
|
for (let i = 0; i < this.length; i++) {
|
||||||
if (callback(this[i], i, this)) {
|
if (callback(this[i], i, this)) {
|
||||||
|
@ -126,8 +129,8 @@ Packetlist.prototype.filter = function (callback) {
|
||||||
/**
|
/**
|
||||||
* Creates a new PacketList with all packets from the given types
|
* Creates a new PacketList with all packets from the given types
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.filterByTag = function (...args) {
|
List.prototype.filterByTag = function (...args) {
|
||||||
const filtered = new Packetlist();
|
const filtered = new List();
|
||||||
const that = this;
|
const that = this;
|
||||||
|
|
||||||
const handle = tag => packetType => tag === packetType;
|
const handle = tag => packetType => tag === packetType;
|
||||||
|
@ -144,7 +147,7 @@ Packetlist.prototype.filterByTag = function (...args) {
|
||||||
/**
|
/**
|
||||||
* Executes the provided callback once for each element
|
* Executes the provided callback once for each element
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.forEach = function (callback) {
|
List.prototype.forEach = function (callback) {
|
||||||
for (let i = 0; i < this.length; i++) {
|
for (let i = 0; i < this.length; i++) {
|
||||||
callback(this[i], i, this);
|
callback(this[i], i, this);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +157,7 @@ Packetlist.prototype.forEach = function (callback) {
|
||||||
* Returns an array containing return values of callback
|
* Returns an array containing return values of callback
|
||||||
* on each element
|
* on each element
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.map = function (callback) {
|
List.prototype.map = function (callback) {
|
||||||
const packetArray = [];
|
const packetArray = [];
|
||||||
|
|
||||||
for (let i = 0; i < this.length; i++) {
|
for (let i = 0; i < this.length; i++) {
|
||||||
|
@ -171,7 +174,7 @@ Packetlist.prototype.map = function (callback) {
|
||||||
* @returns {Promise<Boolean>}
|
* @returns {Promise<Boolean>}
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.some = async function (callback) {
|
List.prototype.some = async function (callback) {
|
||||||
for (let i = 0; i < this.length; i++) {
|
for (let i = 0; i < this.length; i++) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
if (await callback(this[i], i, this)) {
|
if (await callback(this[i], i, this)) {
|
||||||
|
@ -185,7 +188,7 @@ Packetlist.prototype.some = async function (callback) {
|
||||||
* Executes the callback function once for each element,
|
* Executes the callback function once for each element,
|
||||||
* returns true if all callbacks returns a truthy value
|
* returns true if all callbacks returns a truthy value
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.every = function (callback) {
|
List.prototype.every = function (callback) {
|
||||||
for (let i = 0; i < this.length; i++) {
|
for (let i = 0; i < this.length; i++) {
|
||||||
if (!callback(this[i], i, this)) {
|
if (!callback(this[i], i, this)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -199,7 +202,7 @@ Packetlist.prototype.every = function (callback) {
|
||||||
* @param {module:enums.packet} type The packet type
|
* @param {module:enums.packet} type The packet type
|
||||||
* @returns {module:packet/packet|null}
|
* @returns {module:packet/packet|null}
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.findPacket = function (type) {
|
List.prototype.findPacket = function (type) {
|
||||||
const packetlist = this.filterByTag(type);
|
const packetlist = this.filterByTag(type);
|
||||||
if (packetlist.length) {
|
if (packetlist.length) {
|
||||||
return packetlist[0];
|
return packetlist[0];
|
||||||
|
@ -220,7 +223,7 @@ Packetlist.prototype.findPacket = function (type) {
|
||||||
/**
|
/**
|
||||||
* Returns array of found indices by tag
|
* Returns array of found indices by tag
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.indexOfTag = function (...args) {
|
List.prototype.indexOfTag = function (...args) {
|
||||||
const tagIndex = [];
|
const tagIndex = [];
|
||||||
const that = this;
|
const that = this;
|
||||||
|
|
||||||
|
@ -237,11 +240,11 @@ Packetlist.prototype.indexOfTag = function (...args) {
|
||||||
/**
|
/**
|
||||||
* Returns slice of packetlist
|
* Returns slice of packetlist
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.slice = function (begin, end) {
|
List.prototype.slice = function (begin, end) {
|
||||||
if (!end) {
|
if (!end) {
|
||||||
end = this.length;
|
end = this.length;
|
||||||
}
|
}
|
||||||
const part = new Packetlist();
|
const part = new List();
|
||||||
for (let i = begin; i < end; i++) {
|
for (let i = begin; i < end; i++) {
|
||||||
part.push(this[i]);
|
part.push(this[i]);
|
||||||
}
|
}
|
||||||
|
@ -251,7 +254,7 @@ Packetlist.prototype.slice = function (begin, end) {
|
||||||
/**
|
/**
|
||||||
* Concatenates packetlist or array of packets
|
* Concatenates packetlist or array of packets
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.concat = function (packetlist) {
|
List.prototype.concat = function (packetlist) {
|
||||||
if (packetlist) {
|
if (packetlist) {
|
||||||
for (let i = 0; i < packetlist.length; i++) {
|
for (let i = 0; i < packetlist.length; i++) {
|
||||||
this.push(packetlist[i]);
|
this.push(packetlist[i]);
|
||||||
|
@ -266,17 +269,17 @@ Packetlist.prototype.concat = function (packetlist) {
|
||||||
* @param {Object} packetClone packetlist clone
|
* @param {Object} packetClone packetlist clone
|
||||||
* @returns {Object} new packetlist object with data from packetlist clone
|
* @returns {Object} new packetlist object with data from packetlist clone
|
||||||
*/
|
*/
|
||||||
Packetlist.fromStructuredClone = function(packetlistClone) {
|
List.fromStructuredClone = function(packetlistClone) {
|
||||||
const packetlist = new Packetlist();
|
const packetlist = new List();
|
||||||
for (let i = 0; i < packetlistClone.length; i++) {
|
for (let i = 0; i < packetlistClone.length; i++) {
|
||||||
packetlist.push(packets.fromStructuredClone(packetlistClone[i]));
|
packetlist.push(packets.fromStructuredClone(packetlistClone[i]));
|
||||||
if (packetlist[i].packets.length !== 0) {
|
if (packetlist[i].packets.length !== 0) {
|
||||||
packetlist[i].packets = this.fromStructuredClone(packetlist[i].packets);
|
packetlist[i].packets = this.fromStructuredClone(packetlist[i].packets);
|
||||||
} else {
|
} else {
|
||||||
packetlist[i].packets = new Packetlist();
|
packetlist[i].packets = new List();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return packetlist;
|
return packetlist;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Packetlist;
|
export default List;
|
||||||
|
|
|
@ -16,28 +16,30 @@
|
||||||
// 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)
|
* Implementation of the Key Material Packet (Tag 5,6,7,14)
|
||||||
*
|
*
|
||||||
* {@link https://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}:
|
* {@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
|
* A key material packet contains all the information about a public or
|
||||||
* private key. There are four variants of this packet type, and two
|
* private key. There are four variants of this packet type, and two
|
||||||
* major versions. Consequently, this section is complex.
|
* major versions. Consequently, this section is complex.
|
||||||
|
* @requires type/keyid
|
||||||
|
* @requires type/mpi
|
||||||
* @requires crypto
|
* @requires crypto
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @requires util
|
* @requires util
|
||||||
* @requires type/keyid
|
|
||||||
* @module packet/public_key
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import type_keyid from '../type/keyid';
|
||||||
|
import type_mpi from '../type/mpi';
|
||||||
import crypto from '../crypto';
|
import crypto from '../crypto';
|
||||||
import enums from '../enums';
|
import enums from '../enums';
|
||||||
import util from '../util';
|
import util from '../util';
|
||||||
import type_keyid from '../type/keyid';
|
|
||||||
import type_mpi from '../type/mpi';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function PublicKey() {
|
function PublicKey() {
|
||||||
|
|
|
@ -15,6 +15,22 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 type/ecdh_symkey
|
||||||
|
* @requires type/keyid
|
||||||
|
* @requires type/mpi
|
||||||
|
* @requires crypto
|
||||||
|
* @requires enums
|
||||||
|
* @requires util
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type_ecdh_symkey from '../type/ecdh_symkey';
|
||||||
|
import type_keyid from '../type/keyid';
|
||||||
|
import type_mpi from '../type/mpi';
|
||||||
|
import crypto from '../crypto';
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public-Key Encrypted Session Key Packets (Tag 1)
|
* Public-Key Encrypted Session Key Packets (Tag 1)
|
||||||
*
|
*
|
||||||
|
@ -30,23 +46,7 @@
|
||||||
* The recipient of the message finds a session key that is encrypted to their
|
* The recipient of the message finds a session key that is encrypted to their
|
||||||
* public key, decrypts the session key, and then uses the session key to
|
* public key, decrypts the session key, and then uses the session key to
|
||||||
* decrypt the message.
|
* decrypt the message.
|
||||||
* @requires crypto
|
* @memberof module:packet
|
||||||
* @requires enums
|
|
||||||
* @requires type/ecdh_symkey
|
|
||||||
* @requires type/keyid
|
|
||||||
* @requires type/mpi
|
|
||||||
* @requires util
|
|
||||||
* @module packet/public_key_encrypted_session_key
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type_keyid from '../type/keyid.js';
|
|
||||||
import util from '../util.js';
|
|
||||||
import type_ecdh_symkey from '../type/ecdh_symkey.js';
|
|
||||||
import type_mpi from '../type/mpi.js';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
import crypto from '../crypto';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function PublicKeyEncryptedSessionKey() {
|
function PublicKeyEncryptedSessionKey() {
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
/**
|
/**
|
||||||
* @requires packet/public_key
|
* @requires packet/public_key
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @module packet/public_subkey
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import publicKey from './public_key.js';
|
import publicKey from './public_key';
|
||||||
import enums from '../enums.js';
|
import enums from '../enums';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Public-Subkey packet (tag 14) has exactly the same format as a
|
* A Public-Subkey packet (tag 14) has exactly the same format as a
|
||||||
|
@ -30,8 +29,9 @@ import enums from '../enums.js';
|
||||||
* associated with a top-level key. By convention, the top-level key
|
* associated with a top-level key. By convention, the top-level key
|
||||||
* provides signature services, and the subkeys provide encryption
|
* provides signature services, and the subkeys provide encryption
|
||||||
* services.
|
* services.
|
||||||
|
* @memberof module:packet
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends module:packet/public_key
|
* @extends module:packet.PublicKey
|
||||||
*/
|
*/
|
||||||
function PublicSubkey() {
|
function PublicSubkey() {
|
||||||
publicKey.call(this);
|
publicKey.call(this);
|
||||||
|
|
|
@ -16,34 +16,35 @@
|
||||||
// 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)
|
* Implementation of the Key Material Packet (Tag 5,6,7,14)
|
||||||
*
|
*
|
||||||
* {@link https://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}:
|
* {@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
|
* A key material packet contains all the information about a public or
|
||||||
* private key. There are four variants of this packet type, and two
|
* private key. There are four variants of this packet type, and two
|
||||||
* major versions. Consequently, this section is complex.
|
* major versions. Consequently, this section is complex.
|
||||||
* @requires crypto
|
|
||||||
* @requires enums
|
|
||||||
* @requires packet/public_key
|
* @requires packet/public_key
|
||||||
* @requires type/keyid
|
* @requires type/keyid
|
||||||
* @requires type/s2k
|
* @requires type/s2k
|
||||||
|
* @requires crypto
|
||||||
|
* @requires enums
|
||||||
* @requires util
|
* @requires util
|
||||||
* @module packet/secret_key
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import publicKey from './public_key.js';
|
import publicKey from './public_key';
|
||||||
import enums from '../enums.js';
|
|
||||||
import util from '../util.js';
|
|
||||||
import crypto from '../crypto';
|
|
||||||
import type_s2k from '../type/s2k.js';
|
|
||||||
import type_keyid from '../type/keyid.js';
|
import type_keyid from '../type/keyid.js';
|
||||||
|
import type_s2k from '../type/s2k';
|
||||||
|
import crypto from '../crypto';
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Secret-Key packet contains all the information that is found in a
|
* A Secret-Key packet contains all the information that is found in a
|
||||||
* Public-Key packet, including the public-key material, but also
|
* Public-Key packet, including the public-key material, but also
|
||||||
* includes the secret-key material after all the public-key fields.
|
* includes the secret-key material after all the public-key fields.
|
||||||
|
* @memberof module:packet
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends module:packet/public_key
|
* @extends module:packet.PublicKey
|
||||||
*/
|
*/
|
||||||
function SecretKey() {
|
function SecretKey() {
|
||||||
publicKey.call(this);
|
publicKey.call(this);
|
||||||
|
|
|
@ -18,17 +18,17 @@
|
||||||
/**
|
/**
|
||||||
* @requires packet/secret_key
|
* @requires packet/secret_key
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @module packet/secret_subkey
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import secretKey from './secret_key.js';
|
import secretKey from './secret_key';
|
||||||
import enums from '../enums.js';
|
import enums from '../enums';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Secret-Subkey packet (tag 7) is the subkey analog of the Secret
|
* A Secret-Subkey packet (tag 7) is the subkey analog of the Secret
|
||||||
* Key packet and has exactly the same format.
|
* Key packet and has exactly the same format.
|
||||||
|
* @memberof module:packet
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends module:packet/secret_key
|
* @extends module:packet.SecretKey
|
||||||
*/
|
*/
|
||||||
function SecretSubkey() {
|
function SecretSubkey() {
|
||||||
secretKey.call(this);
|
secretKey.call(this);
|
||||||
|
|
|
@ -15,6 +15,22 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 packet/packet
|
||||||
|
* @requires type/keyid
|
||||||
|
* @requires type/mpi
|
||||||
|
* @requires crypto
|
||||||
|
* @requires enums
|
||||||
|
* @requires util
|
||||||
|
*/
|
||||||
|
|
||||||
|
import packet from './packet';
|
||||||
|
import type_keyid from '../type/keyid.js';
|
||||||
|
import type_mpi from '../type/mpi.js';
|
||||||
|
import crypto from '../crypto';
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Signature Packet (Tag 2)
|
* Implementation of the Signature Packet (Tag 2)
|
||||||
*
|
*
|
||||||
|
@ -22,23 +38,7 @@
|
||||||
* A Signature packet describes a binding between some public key and
|
* A Signature packet describes a binding between some public key and
|
||||||
* some data. The most common signatures are a signature of a file or a
|
* some data. The most common signatures are a signature of a file or a
|
||||||
* block of text, and a signature that is a certification of a User ID.
|
* block of text, and a signature that is a certification of a User ID.
|
||||||
* @requires crypto
|
* @memberof module:packet
|
||||||
* @requires enums
|
|
||||||
* @requires packet/packet
|
|
||||||
* @requires type/keyid
|
|
||||||
* @requires type/mpi
|
|
||||||
* @requires util
|
|
||||||
* @module packet/signature
|
|
||||||
*/
|
|
||||||
|
|
||||||
import util from '../util.js';
|
|
||||||
import packet from './packet.js';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
import crypto from '../crypto';
|
|
||||||
import type_mpi from '../type/mpi.js';
|
|
||||||
import type_keyid from '../type/keyid.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {Date} date the creation date of the signature
|
* @param {Date} date the creation date of the signature
|
||||||
*/
|
*/
|
||||||
|
@ -363,11 +363,13 @@ Signature.prototype.write_all_sub_packets = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a string representation of a sub signature packet (See {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.1|RFC 4880 5.2.3.1})
|
* Creates a string representation of a sub signature packet
|
||||||
* @param {Integer} type subpacket signature type. Signature types as described
|
* @see {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.1|RFC4880 5.2.3.1}
|
||||||
* in {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.2|RFC4880 Section 5.2.3.2}
|
* @see {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.2|RFC4880 5.2.3.2}
|
||||||
|
* @param {Integer} type subpacket signature type.
|
||||||
* @param {String} data data to be included
|
* @param {String} data data to be included
|
||||||
* @returns {String} a string-representation of a sub signature packet (See {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.1|RFC 4880 5.2.3.1})
|
* @returns {String} a string-representation of a sub signature packet
|
||||||
|
* @private
|
||||||
*/
|
*/
|
||||||
function write_sub_packet(type, data) {
|
function write_sub_packet(type, data) {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
|
|
|
@ -16,15 +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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Symmetrically Encrypted Authenticated Encryption with
|
|
||||||
* Additional Data (AEAD) Protected Data Packet
|
|
||||||
*
|
|
||||||
* {@link https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1}:
|
|
||||||
* AEAD Protected Data Packet
|
|
||||||
* @requires crypto
|
* @requires crypto
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @requires util
|
* @requires util
|
||||||
* @module packet/sym_encrypted_aead_protected
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import crypto from '../crypto';
|
import crypto from '../crypto';
|
||||||
|
@ -35,6 +29,12 @@ const VERSION = 1; // A one-octet version number of the data packet.
|
||||||
const IV_LEN = crypto.gcm.ivLength; // currently only AES-GCM is supported
|
const IV_LEN = crypto.gcm.ivLength; // currently only AES-GCM is supported
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Implementation of the Symmetrically Encrypted Authenticated Encryption with
|
||||||
|
* Additional Data (AEAD) Protected Data Packet
|
||||||
|
*
|
||||||
|
* {@link https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1}:
|
||||||
|
* AEAD Protected Data Packet
|
||||||
|
* @memberof module:packet
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function SymEncryptedAEADProtected() {
|
function SymEncryptedAEADProtected() {
|
||||||
|
|
|
@ -16,19 +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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Sym. Encrypted Integrity Protected Data Packet (Tag 18)
|
|
||||||
*
|
|
||||||
* {@link https://tools.ietf.org/html/rfc4880#section-5.13|RFC4880 5.13}:
|
|
||||||
* The Symmetrically Encrypted Integrity Protected Data packet is
|
|
||||||
* a variant of the Symmetrically Encrypted Data packet. It is a new feature
|
|
||||||
* created for OpenPGP that addresses the problem of detecting a modification to
|
|
||||||
* encrypted data. It is used in combination with a Modification Detection Code
|
|
||||||
* packet.
|
|
||||||
* @requires asmcrypto.js
|
* @requires asmcrypto.js
|
||||||
* @requires crypto
|
* @requires crypto
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @requires util
|
* @requires util
|
||||||
* @module packet/sym_encrypted_integrity_protected
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AES_CFB } from 'asmcrypto.js/src/aes/cfb/exports';
|
import { AES_CFB } from 'asmcrypto.js/src/aes/cfb/exports';
|
||||||
|
@ -42,6 +33,15 @@ const Buffer = util.getNodeBuffer();
|
||||||
const VERSION = 1; // A one-octet version number of the data packet.
|
const VERSION = 1; // A one-octet version number of the data packet.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Implementation of the Sym. Encrypted Integrity Protected Data Packet (Tag 18)
|
||||||
|
*
|
||||||
|
* {@link https://tools.ietf.org/html/rfc4880#section-5.13|RFC4880 5.13}:
|
||||||
|
* The Symmetrically Encrypted Integrity Protected Data packet is
|
||||||
|
* a variant of the Symmetrically Encrypted Data packet. It is a new feature
|
||||||
|
* created for OpenPGP that addresses the problem of detecting a modification to
|
||||||
|
* encrypted data. It is used in combination with a Modification Detection Code
|
||||||
|
* packet.
|
||||||
|
* @memberof module:packet
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function SymEncryptedIntegrityProtected() {
|
function SymEncryptedIntegrityProtected() {
|
||||||
|
|
|
@ -15,6 +15,18 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 type/s2k
|
||||||
|
* @requires crypto
|
||||||
|
* @requires enums
|
||||||
|
* @requires util
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type_s2k from '../type/s2k';
|
||||||
|
import crypto from '../crypto';
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public-Key Encrypted Session Key Packets (Tag 1)
|
* Public-Key Encrypted Session Key Packets (Tag 1)
|
||||||
*
|
*
|
||||||
|
@ -30,19 +42,7 @@
|
||||||
* The recipient of the message finds a session key that is encrypted to their
|
* The recipient of the message finds a session key that is encrypted to their
|
||||||
* public key, decrypts the session key, and then uses the session key to
|
* public key, decrypts the session key, and then uses the session key to
|
||||||
* decrypt the message.
|
* decrypt the message.
|
||||||
* @requires util
|
* @memberof module:packet
|
||||||
* @requires crypto
|
|
||||||
* @requires enums
|
|
||||||
* @requires type/s2k
|
|
||||||
* @module packet/sym_encrypted_session_key
|
|
||||||
*/
|
|
||||||
|
|
||||||
import util from '../util.js';
|
|
||||||
import type_s2k from '../type/s2k.js';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
import crypto from '../crypto';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function SymEncryptedSessionKey() {
|
function SymEncryptedSessionKey() {
|
||||||
|
|
|
@ -15,6 +15,16 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 config
|
||||||
|
* @requires crypto
|
||||||
|
* @requires enums
|
||||||
|
*/
|
||||||
|
|
||||||
|
import config from '../config';
|
||||||
|
import crypto from '../crypto';
|
||||||
|
import enums from '../enums';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Symmetrically Encrypted Data Packet (Tag 9)
|
* Implementation of the Symmetrically Encrypted Data Packet (Tag 9)
|
||||||
*
|
*
|
||||||
|
@ -24,16 +34,7 @@
|
||||||
* packets (usually a literal data packet or compressed data packet, but in
|
* packets (usually a literal data packet or compressed data packet, but in
|
||||||
* theory other Symmetrically Encrypted Data packets or sequences of packets
|
* theory other Symmetrically Encrypted Data packets or sequences of packets
|
||||||
* that form whole OpenPGP messages).
|
* that form whole OpenPGP messages).
|
||||||
* @requires crypto
|
* @memberof module:packet
|
||||||
* @requires enums
|
|
||||||
* @module packet/symmetrically_encrypted
|
|
||||||
*/
|
|
||||||
|
|
||||||
import crypto from '../crypto';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
import config from '../config';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function SymmetricallyEncrypted() {
|
function SymmetricallyEncrypted() {
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
/**
|
||||||
|
* @requires enums
|
||||||
|
*/
|
||||||
|
|
||||||
|
import enums from '../enums';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Trust Packet (Tag 12)
|
* Implementation of the Trust Packet (Tag 12)
|
||||||
*
|
*
|
||||||
|
@ -12,13 +18,7 @@
|
||||||
* Trust packets SHOULD NOT be emitted to output streams that are
|
* Trust packets SHOULD NOT be emitted to output streams that are
|
||||||
* transferred to other users, and they SHOULD be ignored on any input
|
* transferred to other users, and they SHOULD be ignored on any input
|
||||||
* other than local keyring files.
|
* other than local keyring files.
|
||||||
* @requires enums
|
* @memberof module:packet
|
||||||
* @module packet/trust
|
|
||||||
*/
|
|
||||||
|
|
||||||
import enums from '../enums.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Trust() {
|
function Trust() {
|
||||||
|
|
|
@ -15,6 +15,16 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 packet
|
||||||
|
* @requires enums
|
||||||
|
* @requires util
|
||||||
|
*/
|
||||||
|
|
||||||
|
import packet from './packet';
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the User Attribute Packet (Tag 17)
|
* Implementation of the User Attribute Packet (Tag 17)
|
||||||
*
|
*
|
||||||
|
@ -31,16 +41,7 @@
|
||||||
* User Attribute packet. A simple way to do this is by treating the
|
* User Attribute packet. A simple way to do this is by treating the
|
||||||
* User Attribute packet as a User ID packet with opaque contents, but
|
* User Attribute packet as a User ID packet with opaque contents, but
|
||||||
* an implementation may use any method desired.
|
* an implementation may use any method desired.
|
||||||
* module packet/user_attribute
|
* @memberof module:packet
|
||||||
* @requires enums
|
|
||||||
* @module packet/user_attribute
|
|
||||||
*/
|
|
||||||
|
|
||||||
import util from '../util.js';
|
|
||||||
import packet from './packet.js';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function UserAttribute() {
|
function UserAttribute() {
|
||||||
|
|
|
@ -15,6 +15,14 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// 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 util
|
||||||
|
*/
|
||||||
|
|
||||||
|
import enums from '../enums';
|
||||||
|
import util from '../util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the User ID Packet (Tag 13)
|
* Implementation of the User ID Packet (Tag 13)
|
||||||
*
|
*
|
||||||
|
@ -23,15 +31,7 @@
|
||||||
* includes an RFC 2822 [RFC2822] mail name-addr, but there are no
|
* includes an RFC 2822 [RFC2822] mail name-addr, but there are no
|
||||||
* restrictions on its content. The packet length in the header
|
* restrictions on its content. The packet length in the header
|
||||||
* specifies the length of the User ID.
|
* specifies the length of the User ID.
|
||||||
* @requires util
|
* @memberof module:packet
|
||||||
* @requires enums
|
|
||||||
* @module packet/userid
|
|
||||||
*/
|
|
||||||
|
|
||||||
import util from '../util.js';
|
|
||||||
import enums from '../enums.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Userid() {
|
function Userid() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user