@@ -600,7 +508,7 @@ an attribute "data" containing the bytes and "type" for the ASCII armor type
-
<inner> get_type(text) → {Integer}
+
<inner> addheader() → {String}
@@ -608,7 +516,8 @@ an attribute "data" containing the bytes and "type" for the ASCII armor type
- Finds out which Ascii Armoring type is used. This is an internal function
+ Add additional information to the armor version of an OpenPGP binary
+packet block.
@@ -617,60 +526,15 @@ an attribute "data" containing the bytes and "type" for the ASCII armor type
-
Parameters:
-
-
-
-
-
-
-
Name
-
-
-
Type
-
-
-
-
-
-
Description
-
-
-
-
-
-
-
-
-
text
-
-
-
-
-
-String
-
-
-
-
-
-
-
-
-
-
[String] ascii armored text
-
-
-
-
-
-
+
Version:
+
2011-12-16
+
@@ -679,6 +543,13 @@ an attribute "data" containing the bytes and "type" for the ASCII armor type
+
Author:
+
+
+
Alex
+
+
+
@@ -689,7 +560,7 @@ an attribute "data" containing the bytes and "type" for the ASCII armor type
@@ -714,13 +585,7 @@ an attribute "data" containing the bytes and "type" for the ASCII armor type
- 0 = MESSAGE PART n of m
- 1 = MESSAGE PART n
- 2 = SIGNED MESSAGE
- 3 = PGP MESSAGE
- 4 = PUBLIC KEY BLOCK
- 5 = PRIVATE KEY BLOCK
- null = unknown
+ The header information
@@ -731,7 +596,7 @@ an attribute "data" containing the bytes and "type" for the ASCII armor type
-Integer
+String
@@ -834,7 +699,7 @@ an attribute "data" containing the bytes and "type" for the ASCII armor type
The algorithm _encrypt_ function to encrypt
- data in one block_size encryption.
-
-
-
-
-
-
-
block_size
-
-
-
-
-
-Integer
-
-
-
-
-
-
-
-
-
-
the block size in bytes of the algorithm used
-
-
-
-
-
-
-
plaintext
+
cipherfn
@@ -202,7 +163,8 @@ blockcipher to decrypt a message
-
ciphertext to be decrypted provided as a string
+
the algorithm cipher class to decrypt
+ data in one block_size encryption, @see module:crypto/cipher.
@@ -215,7 +177,7 @@ blockcipher to decrypt a message
-openpgp_byte_array
+String
@@ -225,8 +187,31 @@ blockcipher to decrypt a message
-
key to be used to decrypt the ciphertext. This will be passed to the
- blockcipherfn
+
binary string representation of key to be used to decrypt the ciphertext.
+This will be passed to the cipherfn
+
+
+
+
+
+
+
ciphertext
+
+
+
+
+
+String
+
+
+
+
+
+
+
+
+
+
to be decrypted provided as a string
@@ -249,7 +234,7 @@ blockcipher to decrypt a message
-
a boolean value specifying if a resync of the
+
a boolean value specifying if a resync of the
IV should be used or not. The encrypteddatapacket uses the
"old" style with a resync. Decryption within an
encryptedintegrityprotecteddata packet is not resyncing the IV.
@@ -283,7 +268,7 @@ blockcipher to decrypt a message
@@ -400,13 +385,13 @@ using the specified blockcipher to encrypt a message
-
blockcipherfn
+
cipherfn
-openpgp_block_cipher_fn
+String
@@ -416,31 +401,8 @@ using the specified blockcipher to encrypt a message
-
the algorithm encrypt function to encrypt
- data in one block_size encryption.
-
-
-
-
-
-
-
block_size
-
-
-
-
-
-Integer
-
-
-
-
-
-
-
-
-
-
the block size in bytes of the algorithm used
+
the algorithm cipher class to encrypt
+ data in one block_size encryption, @see module:crypto/cipher.
@@ -476,7 +438,7 @@ using the specified blockcipher to encrypt a message
-openpgp_byte_array
+String
@@ -486,8 +448,8 @@ using the specified blockcipher to encrypt a message
-
key to be used to encrypt the data. This will be passed to the
- blockcipherfn
+
binary string representation of key to be used to encrypt the plaintext.
+This will be passed to the cipherfn
@@ -510,7 +472,7 @@ using the specified blockcipher to encrypt a message
-
a boolean value specifying if a resync of the
+
a boolean value specifying if a resync of the
IV should be used or not. The encrypteddatapacket uses the
"old" style with a resync. Encryption within an
encryptedintegrityprotecteddata packet is not resyncing the IV.
@@ -544,7 +506,7 @@ using the specified blockcipher to encrypt a message
@@ -815,13 +762,13 @@ using the specified blockcipher to encrypt a message
diff --git a/doc/cfb.js.html b/doc/cfb.js.html
index 658567e1..15be6066 100644
--- a/doc/cfb.js.html
+++ b/doc/cfb.js.html
@@ -42,40 +42,28 @@
* materials provided with the application or distribution.
*/
-/** @module crypto/cfb */
+/**
+ * @requires crypto/cipher
+ * @requires util
+ * @module crypto/cfb
+ */
var util = require('../util'),
cipher = require('./cipher');
module.exports = {
- /**
- * An array of bytes, that is integers with values from 0 to 255
- * @typedef {(Array|Uint8Array)} openpgp_byte_array
- */
-
- /**
- * Block cipher function
- * @callback openpgp_block_cipher_fn
- * @param {openpgp_byte_array} block A block to perform operations on
- * @param {openpgp_byte_array} key to use in encryption/decryption
- * @return {openpgp_byte_array} Encrypted/decrypted block
- */
-
-
- // --------------------------------------
/**
* This function encrypts a given with the specified prefixrandom
* using the specified blockcipher to encrypt a message
* @param {String} prefixrandom random bytes of block_size length provided
* as a string to be used in prefixing the data
- * @param {openpgp_block_cipher_fn} blockcipherfn the algorithm encrypt function to encrypt
- * data in one block_size encryption.
- * @param {Integer} block_size the block size in bytes of the algorithm used
+ * @param {String} cipherfn the algorithm cipher class to encrypt
+ * data in one block_size encryption, @see module:crypto/cipher.
* @param {String} plaintext data to be encrypted provided as a string
- * @param {openpgp_byte_array} key key to be used to encrypt the data. This will be passed to the
- * blockcipherfn
- * @param {Boolean} resync a boolean value specifying if a resync of the
+ * @param {String} key binary string representation of key to be used to encrypt the plaintext.
+ * This will be passed to the cipherfn
+ * @param {Boolean} resync a boolean value specifying if a resync of the
* IV should be used or not. The encrypteddatapacket uses the
* "old" style with a resync. Encryption within an
* encryptedintegrityprotecteddata packet is not resyncing the IV.
@@ -178,9 +166,10 @@ module.exports = {
/**
* Decrypts the prefixed data for the Modification Detection Code (MDC) computation
- * @param {openpgp_block_cipher_fn} cipherfn.encrypt Cipher function to use
- * @param {Integer} block_size Blocksize of the algorithm
- * @param {openpgp_byte_array} key The key for encryption
+ * @param {String} cipherfn.encrypt Cipher function to use,
+ * @see module:crypto/cipher.
+ * @param {String} key binary string representation of key to be used to check the mdc
+ * This will be passed to the cipherfn
* @param {String} ciphertext The encrypted data
* @return {String} plaintext Data of D(ciphertext) with blocksize length +2
*/
@@ -211,13 +200,12 @@ module.exports = {
/**
* This function decrypts a given plaintext using the specified
* blockcipher to decrypt a message
- * @param {openpgp_block_cipher_fn} blockcipherfn The algorithm _encrypt_ function to encrypt
- * data in one block_size encryption.
- * @param {Integer} block_size the block size in bytes of the algorithm used
- * @param {String} plaintext ciphertext to be decrypted provided as a string
- * @param {openpgp_byte_array} key key to be used to decrypt the ciphertext. This will be passed to the
- * blockcipherfn
- * @param {Boolean} resync a boolean value specifying if a resync of the
+ * @param {String} cipherfn the algorithm cipher class to decrypt
+ * data in one block_size encryption, @see module:crypto/cipher.
+ * @param {String} key binary string representation of key to be used to decrypt the ciphertext.
+ * This will be passed to the cipherfn
+ * @param {String} ciphertext to be decrypted provided as a string
+ * @param {Boolean} resync a boolean value specifying if a resync of the
* IV should be used or not. The encrypteddatapacket uses the
* "old" style with a resync. Decryption within an
* encryptedintegrityprotecteddata packet is not resyncing the IV.
@@ -262,7 +250,7 @@ module.exports = {
for (n = block_size + 2; n < ciphertext.length; n += block_size) {
ablock = cipherfn.encrypt(iblock);
- for (i = 0; i < block_size && i + n < ciphertext.length; i++) {
+ for (i = 0; i < block_size && i + n < ciphertext.length; i++) {
iblock[i] = ciphertext.charCodeAt(n + i);
text.push(String.fromCharCode(ablock[i] ^ iblock[i]));
}
@@ -271,7 +259,7 @@ module.exports = {
for (i = 0; i < block_size; i++) iblock[i] = ciphertext.charCodeAt(i);
for (n = block_size; n < ciphertext.length; n += block_size) {
ablock = cipherfn.encrypt(iblock);
- for (i = 0; i < block_size && i + n < ciphertext.length; i++) {
+ for (i = 0; i < block_size && i + n < ciphertext.length; i++) {
iblock[i] = ciphertext.charCodeAt(n + i);
text.push(String.fromCharCode(ablock[i] ^ iblock[i]));
}
@@ -346,13 +334,13 @@ module.exports = {
diff --git a/doc/cipher.html b/doc/cipher.html
new file mode 100644
index 00000000..170d25ee
--- /dev/null
+++ b/doc/cipher.html
@@ -0,0 +1,421 @@
+
+
+
+
+ JSDoc: Module: crypto/cipher
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/cleartext.js.html b/doc/cleartext.js.html
index c7e9b9c8..d2f4b8bc 100644
--- a/doc/cleartext.js.html
+++ b/doc/cleartext.js.html
@@ -42,12 +42,18 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module cleartext */
+/**
+ * @requires config
+ * @requires encoding/armor
+ * @requires enums
+ * @requires packet
+ * @module cleartext
+ */
-var config = require('./config');
-var packet = require('./packet');
-var enums = require('./enums.js');
-var armor = require('./encoding/armor.js');
+var config = require('./config'),
+ packet = require('./packet'),
+ enums = require('./enums.js'),
+ armor = require('./encoding/armor.js');
/**
* @class
@@ -154,6 +160,7 @@ CleartextMessage.prototype.armor = function() {
* reads an OpenPGP cleartext signed message and returns a CleartextMessage object
* @param {String} armoredText text to be parsed
* @return {module:cleartext~CleartextMessage} new cleartext message object
+ * @static
*/
function readArmored(armoredText) {
var input = armor.decode(armoredText);
@@ -178,13 +185,13 @@ exports.readArmored = readArmored;
diff --git a/doc/compressed.html b/doc/compressed.html
index 68d273b0..08cf71d8 100644
--- a/doc/compressed.html
+++ b/doc/compressed.html
@@ -36,8 +36,15 @@
+
Implementation of the Compressed Data Packet (Tag 8)
+
+RFC4880 5.6: The Compressed Data packet contains compressed data. Typically,
+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.
diff --git a/doc/compressed.js.html b/doc/compressed.js.html
index 2838d321..dd8ac616 100644
--- a/doc/compressed.js.html
+++ b/doc/compressed.js.html
@@ -42,38 +42,47 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/compressed */
+/**
+ * Implementation of the Compressed Data Packet (Tag 8)<br/>
+ * <br/>
+ * RFC4880 5.6: The Compressed Data packet contains compressed data. Typically,
+ * 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.
+ * @requires compression/jxg
+ * @requires encoding/base64
+ * @requires enums
+ * @module packet/compressed
+ */
var enums = require('../enums.js'),
JXG = require('../compression/jxg.js'),
base64 = require('../encoding/base64.js');
/**
- * @class
- * @classdesc Implementation of the Compressed Data Packet (Tag 8)
- *
- * RFC4880 5.6:
- * The Compressed Data packet contains compressed data. Typically, 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.
+ * @constructor
*/
-module.exports = function packet_compressed() {
- /** @type {module:packet/packetlist} */
- this.packets;
- /** @type {compression} */
+module.exports = function () {
+ /**
+ * List of packets
+ * @type {module:packet/packetlist}
+ */
+ this.packets = null;
+ /**
+ * Compression algorithm
+ * @type {compression}
+ */
this.algorithm = 'uncompressed';
+ /**
+ * Compressed packet data
+ * @type {String}
+ */
this.compressed = null;
/**
* Parsing function for the packet.
- * @param {String} input Payload of a tag 8 packet
- * @param {Integer} position Position to start reading from the input string
- * @param {Integer} len length of the packet or the remaining length of
- * input at position
- * @return {module:packet/compressed} Object representation
+ * @param {String} bytes Payload of a tag 8 packet
*/
this.read = function(bytes) {
// One octet that gives the algorithm used to compress the packet.
@@ -87,6 +96,10 @@ module.exports = function packet_compressed() {
+ /**
+ * Return the compressed packet.
+ * @return {String} binary compressed packet
+ */
this.write = function() {
if (this.compressed == null)
this.compress();
@@ -98,7 +111,6 @@ module.exports = function packet_compressed() {
/**
* Decompression method for decompressing the compressed data
* read by read_packet
- * @return {String} The decompressed data
*/
this.decompress = function() {
var decompressed;
@@ -155,9 +167,6 @@ module.exports = function packet_compressed() {
/**
* Compress the packet data (member decompressedData)
- * @param {Integer} type Algorithm to be used // See RFC 4880 9.3
- * @param {String} data Data to be compressed
- * @return {String} The compressed data stored in attribute compressedData
*/
this.compress = function() {
switch (this.algorithm) {
@@ -200,13 +209,13 @@ module.exports = function packet_compressed() {
diff --git a/doc/config-config.html b/doc/config-config.html
deleted file mode 100644
index eb8dc336..00000000
--- a/doc/config-config.html
+++ /dev/null
@@ -1,457 +0,0 @@
-
-
-
-
- JSDoc: Class: config
-
-
-
-
-
-
-
-
-
-
-
- This object contains configuration values and implements
-storing and retrieving configuration them from HTML5 local storage.
-
-This object can be accessed after calling openpgp.init()
-using openpgp.config
-Stored config parameters can be accessed using
-openpgp.config.config
-
/** @module config/config_localStorage */
-
-/**
- *
- * This object storing and retrieving configuration from HTML5 local storage.
- *
- * This object can be accessed after calling openpgp.init()
- * @class
- * @classdesc Implementation of the config handler for localstorage
- */
-module.exports = function () {
-
- /**
- * Reads the config out of the HTML5 local storage
- * and initializes the object config.
- * if config is null the default config will be used
- */
- function read() {
- var cf = JSON.parse(window.localStorage.getItem("config"));
- if (cf === null) {
- this.config = this.default_config;
- this.write();
- } else
- this.config = cf;
- }
-
- /**
- * Writes the config to HTML5 local storage
- */
- function write() {
- window.localStorage.setItem("config", JSON.stringify(this.config));
- }
-
- this.read = read;
- this.write = write;
-}
-
/**
+ * @module enums
+ */
module.exports = {
/** A string to key specifier type
* @enum {Integer}
+ * @readonly
*/
s2k: {
simple: 0,
@@ -41,6 +44,7 @@ module.exports = {
/** RFC4880, section 9.1
* @enum {Integer}
+ * @readonly
*/
publicKey: {
rsa_encrypt_sign: 1,
@@ -52,6 +56,7 @@ module.exports = {
/** RFC4880, section 9.2
* @enum {Integer}
+ * @readonly
*/
symmetric: {
plaintext: 0,
@@ -68,6 +73,7 @@ module.exports = {
/** RFC4880, section 9.3
* @enum {Integer}
+ * @readonly
*/
compression: {
uncompressed: 0,
@@ -80,6 +86,7 @@ module.exports = {
/** RFC4880, section 9.4
* @enum {Integer}
+ * @readonly
*/
hash: {
md5: 1,
@@ -91,9 +98,9 @@ module.exports = {
sha224: 11
},
-
/** A list of packet types and numeric tags associated with them.
* @enum {Integer}
+ * @readonly
*/
packet: {
public_key_encrypted_session_key: 1,
@@ -115,9 +122,9 @@ module.exports = {
modification_detection_code: 19
},
-
/** Data types in the literal packet
* @enum {Integer}
+ * @readonly
*/
literal: {
/** Binary data 'b' */
@@ -131,41 +138,42 @@ module.exports = {
/** One pass signature packet type
* @enum {Integer}
+ * @readonly
*/
signature: {
/** 0x00: Signature of a binary document. */
binary: 0,
- /** 0x01: Signature of a canonical text document.
+ /** 0x01: Signature of a canonical text document.<br/>
* Canonicalyzing the document by converting line endings. */
text: 1,
- /** 0x02: Standalone signature.
+ /** 0x02: Standalone signature.<br/>
* This signature is a signature of only its own subpacket contents.
* It is calculated identically to a signature over a zero-lengh
* binary document. Note that it doesn't make sense to have a V3
* standalone signature. */
standalone: 2,
- /** 0x10: Generic certification of a User ID and Public-Key packet.
+ /** 0x10: Generic certification of a User ID and Public-Key packet.<br/>
* The issuer of this certification does not make any particular
* assertion as to how well the certifier has checked that the owner
* of the key is in fact the person described by the User ID. */
cert_generic: 16,
- /** 0x11: Persona certification of a User ID and Public-Key packet.
+ /** 0x11: Persona certification of a User ID and Public-Key packet.<br/>
* The issuer of this certification has not done any verification of
* the claim that the owner of this key is the User ID specified. */
cert_persona: 17,
- /** 0x12: Casual certification of a User ID and Public-Key packet.
+ /** 0x12: Casual certification of a User ID and Public-Key packet.<br/>
* The issuer of this certification has done some casual
* verification of the claim of identity. */
cert_casual: 18,
- /** 0x13: Positive certification of a User ID and Public-Key packet.
+ /** 0x13: Positive certification of a User ID and Public-Key packet.<br/>
* The issuer of this certification has done substantial
- * verification of the claim of identity.
- *
+ * verification of the claim of identity.<br/>
+ * <br/>
* Most OpenPGP implementations make their "key signatures" as 0x10
* certifications. Some implementations can issue 0x11-0x13
* certifications, but few differentiate between the types. */
cert_positive: 19,
- /** 0x30: Certification revocation signature
+ /** 0x30: Certification revocation signature<br/>
* This signature revokes an earlier User ID certification signature
* (signature class 0x10 through 0x13) or direct-key signature
* (0x1F). It should be issued by the same key that issued the
@@ -174,7 +182,7 @@ module.exports = {
* revokes, and should have a later creation date than that
* certificate. */
cert_revocation: 48,
- /** 0x18: Subkey Binding Signature
+ /** 0x18: Subkey Binding Signature<br/>
* This signature is a statement by the top-level signing key that
* indicates that it owns the subkey. This signature is calculated
* directly on the primary key and subkey, and not on any User ID or
@@ -183,12 +191,12 @@ module.exports = {
* contains a 0x19 signature made by the signing subkey on the
* primary key and subkey. */
subkey_binding: 24,
- /** 0x19: Primary Key Binding Signature
+ /** 0x19: Primary Key Binding Signature<br/>
* This signature is a statement by a signing subkey, indicating
* that it is owned by the primary key and subkey. This signature
* is calculated the same way as a 0x18 signature: directly on the
- * primary key and subkey, and not on any User ID or other packets.
-
+ * primary key and subkey, and not on any User ID or other packets.<br/>
+ * <br/>
* When a signature is made over a key, the hash data starts with the
* octet 0x99, followed by a two-octet length of the key, and then body
* of the key packet. (Note that this is an old-style packet header for
@@ -197,7 +205,7 @@ module.exports = {
* the subkey using the same format as the main key (also using 0x99 as
* the first octet). */
key_binding: 25,
- /** 0x1F: Signature directly on a key
+ /** 0x1F: Signature directly on a key<br/>
* This signature is calculated directly on a key. It binds the
* information in the Signature subpackets to the key, and is
* appropriate to be used for subpackets that provide information
@@ -206,26 +214,27 @@ module.exports = {
* about the key itself, rather than the binding between a key and a
* name. */
key: 31,
- /** 0x20: Key revocation signature
+ /** 0x20: Key revocation signature<br/>
* The signature is calculated directly on the key being revoked. A
* revoked key is not to be used. Only revocation signatures by the
* key being revoked, or by an authorized revocation key, should be
* considered valid revocation signatures.a */
key_revocation: 32,
- /** 0x28: Subkey revocation signature
+ /** 0x28: Subkey revocation signature<br/>
* The signature is calculated directly on the subkey being revoked.
* A revoked subkey is not to be used. Only revocation signatures
* by the top-level signature key that is bound to this subkey, or
* by an authorized revocation key, should be considered valid
- * revocation signatures.
+ * revocation signatures.<br/>
+ * <br/>
* Key revocation signatures (types 0x20 and 0x28)
* hash only the key being revoked. */
subkey_revocation: 40,
- /** 0x40: Timestamp signature.
+ /** 0x40: Timestamp signature.<br/>
* This signature is only meaningful for the timestamp contained in
* it. */
timestamp: 64,
- /** 0x50: Third-Party Confirmation signature.
+ /** 0x50: Third-Party Confirmation signature.<br/>
* This signature is a signature over some other OpenPGP Signature
* packet(s). It is analogous to a notary seal on the signed data.
* A third-party signature SHOULD include Signature Target
@@ -238,6 +247,7 @@ module.exports = {
/** Signature subpacket type
* @enum {Integer}
+ * @readonly
*/
signatureSubpacket: {
signature_creation_time: 2,
@@ -268,28 +278,30 @@ module.exports = {
/** Key flags
* @enum {Integer}
+ * @readonly
*/
keyFlags: {
- // 0x01 - This key may be used to certify other keys.
+ /** 0x01 - This key may be used to certify other keys. */
certify_keys: 1,
- // 0x02 - This key may be used to sign data.
+ /** 0x02 - This key may be used to sign data. */
sign_data: 2,
- // 0x04 - This key may be used to encrypt communications.
+ /** 0x04 - This key may be used to encrypt communications. */
encrypt_communication: 4,
- // 0x08 - This key may be used to encrypt storage.
+ /** 0x08 - This key may be used to encrypt storage. */
encrypt_storage: 8,
- // 0x10 - The private component of this key may have been split
- // by a secret-sharing mechanism.
+ /** 0x10 - The private component of this key may have been split
+ * by a secret-sharing mechanism. */
split_private_key: 16,
- // 0x20 - This key may be used for authentication.
+ /** 0x20 - This key may be used for authentication. */
authentication: 32,
- // 0x80 - The private component of this key may be in the
- // possession of more than one person.
+ /** 0x80 - The private component of this key may be in the
+ * possession of more than one person. */
shared_private_key: 128
},
/** Key status
* @enum {Integer}
+ * @readonly
*/
keyStatus: {
invalid: 0,
@@ -301,6 +313,7 @@ module.exports = {
/** Armor type
* @enum {Integer}
+ * @readonly
*/
armor: {
multipart_section: 0,
@@ -339,13 +352,13 @@ module.exports = {
diff --git a/doc/global.html b/doc/global.html
deleted file mode 100644
index f44c208b..00000000
--- a/doc/global.html
+++ /dev/null
@@ -1,406 +0,0 @@
-
-
-
-
- JSDoc: Global
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/index.html b/doc/index.html
index 02a23fea..805791ca 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -40,6 +40,48 @@
+
+
[
+
+
What is OpenPGP.js?
+
+
OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.
+
+
How do I use it?
+
+
As a developer, the best place to start is in the resources/ directory. Within this you will find a basic example implementation and the "binary" files for this library. It is likely that you will want to use resources/openpgp.min.js on your site, this is a minified version of our library.
+
+
I need some help
+
+
Mailing List
+
+
You can sign up for our mailing list and ask for help there. We've recently worked on getting our archive up and running.
+
+
Documentation
+
+
A jsdoc build of our code comments is available at doc/index.html. Public calls should generally be made through the OpenPGP object doc/openpgp.html.
+
+
How do I get involved?
+
+
You want to help, great! Go ahead and fork our repo, make your changes and make a pull request. Please be sure that you run make minify from the root directory to concatenate and minify the library into the resources/ directory.
+
+
It is extra awesome if you write tests for the code you change. Our test coverage is relatively weak, so if you can add cases that is great.
+
+
What License do you use?
+
+
GNU Lesser General Public License (2.1). Please take a look at the LICENSE file for more information.
+
+
What are the requirements to use it?
+
+
OpenPGP.js currently only fully supports Chrome. Firefox support should be coming soon with the advent of Firefox 23 with native javascript support for window.crypto.getRandomValues. If you can help us support more browsers and situations, please chip in!
+
+
Resources
+
+
Below is a collection of resources, many of these were projects that were in someway a precursor to the current OpenPGP.js project. If you'd like to add your link here, please do so in a pull request or email to the list.
+
@@ -105,13 +111,13 @@
diff --git a/doc/jsbn.js.html b/doc/jsbn.js.html
index cf1f4c41..9c817157 100644
--- a/doc/jsbn.js.html
+++ b/doc/jsbn.js.html
@@ -59,7 +59,10 @@
*/
-/** @module crypto/public_key/jsbn */
+/**
+ * @requires util
+ * @module crypto/public_key/jsbn
+ */
var util = require('../../util');
@@ -70,14 +73,14 @@ var dbits;
// JavaScript engine analysis
var canary = 0xdeadbeefcafe;
-var j_lm = ((canary & 0xffffff) == 0xefcafe);
+var j_lm = ((canary & 0xffffff) == 0xefcafe);
// (public) Constructor
function BigInteger(a, b, c) {
if (a != null)
if ("number" == typeof a) this.fromNumber(a, b, c);
- else if (b == null && "string" != typeof a) this.fromString(a, 256);
+ else if (b == null && "string" != typeof a) this.fromString(a, 256);
else this.fromString(a, b);
}
@@ -100,7 +103,7 @@ function am1(i, x, w, j, c, n) {
while (--n >= 0) {
var v = x * this[i++] + w[j] + c;
c = Math.floor(v / 0x4000000);
- w[j++] = v & 0x3ffffff;
+ w[j++] = v & 0x3ffffff;
}
return c;
}
@@ -109,15 +112,15 @@ function am1(i, x, w, j, c, n) {
// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
function am2(i, x, w, j, c, n) {
- var xl = x & 0x7fff,
+ var xl = x & 0x7fff,
xh = x >> 15;
while (--n >= 0) {
- var l = this[i] & 0x7fff;
+ var l = this[i] & 0x7fff;
var h = this[i++] >> 15;
var m = xh * l + h * xl;
- l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
+ l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
- w[j++] = l & 0x3fffffff;
+ w[j++] = l & 0x3fffffff;
}
return c;
}
@@ -125,24 +128,24 @@ function am2(i, x, w, j, c, n) {
// browsers slow down when dealing with 32-bit numbers.
function am3(i, x, w, j, c, n) {
- var xl = x & 0x3fff,
+ var xl = x & 0x3fff,
xh = x >> 14;
while (--n >= 0) {
- var l = this[i] & 0x3fff;
+ var l = this[i] & 0x3fff;
var h = this[i++] >> 14;
var m = xh * l + h * xl;
- l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
+ l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
c = (l >> 28) + (m >> 14) + xh * h;
- w[j++] = l & 0xfffffff;
+ w[j++] = l & 0xfffffff;
}
return c;
}
-/*if(j_lm && (navigator != undefined &&
+/*if(j_lm && (navigator != undefined &&
navigator.appName == "Microsoft Internet Explorer")) {
BigInteger.prototype.am = am2;
dbits = 30;
}
-else if(j_lm && (navigator != undefined && navigator.appName != "Netscape")) {*/
+else if(j_lm && (navigator != undefined && navigator.appName != "Netscape")) {*/
BigInteger.prototype.am = am1;
dbits = 26;
/*}
@@ -226,7 +229,7 @@ function bnpFromString(s, b) {
mi = false,
sh = 0;
while (--i >= 0) {
- var x = (k == 8) ? s[i] & 0xff : intAt(s, i);
+ var x = (k == 8) ? s[i] & 0xff : intAt(s, i);
if (x < 0) {
if (s.charAt(i) == "-") mi = true;
continue;
@@ -235,14 +238,14 @@ function bnpFromString(s, b) {
if (sh == 0)
this[this.t++] = x;
else if (sh + k > this.DB) {
- this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
+ this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
this[this.t++] = (x >> (this.DB - sh));
} else
this[this.t - 1] |= x << sh;
sh += k;
if (sh >= this.DB) sh -= this.DB;
}
- if (k == 8 && (s[0] & 0x80) != 0) {
+ if (k == 8 && (s[0] & 0x80) != 0) {
this.s = -1;
if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
}
@@ -253,8 +256,8 @@ function bnpFromString(s, b) {
// (protected) clamp off excess high words
function bnpClamp() {
- var c = this.s & this.DM;
- while (this.t > 0 && this[this.t - 1] == c)--this.t;
+ var c = this.s & this.DM;
+ while (this.t > 0 && this[this.t - 1] == c)--this.t;
}
// (public) return string representation in given radix
@@ -274,16 +277,16 @@ function bnToString(b) {
i = this.t;
var p = this.DB - (i * this.DB) % k;
if (i-- > 0) {
- if (p < this.DB && (d = this[i] >> p) > 0) {
+ if (p < this.DB && (d = this[i] >> p) > 0) {
m = true;
r = int2char(d);
}
while (i >= 0) {
if (p < k) {
- d = (this[i] & ((1 << p) - 1)) << (k - p);
+ d = (this[i] & ((1 << p) - 1)) << (k - p);
d |= this[--i] >> (p += this.DB - k);
} else {
- d = (this[i] >> (p -= k)) & km;
+ d = (this[i] >> (p -= k)) & km;
if (p <= 0) {
p += this.DB;
--i;
@@ -354,7 +357,7 @@ function nbits(x) {
function bnBitLength() {
if (this.t <= 0) return 0;
- return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
+ return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
}
// (protected) r = this << n*DB
@@ -382,11 +385,11 @@ function bnpLShiftTo(n, r) {
var cbs = this.DB - bs;
var bm = (1 << cbs) - 1;
var ds = Math.floor(n / this.DB),
- c = (this.s << bs) & this.DM,
+ c = (this.s << bs) & this.DM,
i;
for (i = this.t - 1; i >= 0; --i) {
r[i + ds + 1] = (this[i] >> cbs) | c;
- c = (this[i] & bm) << bs;
+ c = (this[i] & bm) << bs;
}
for (i = ds - 1; i >= 0; --i) r[i] = 0;
r[ds] = c;
@@ -409,10 +412,10 @@ function bnpRShiftTo(n, r) {
var bm = (1 << bs) - 1;
r[0] = this[ds] >> bs;
for (var i = ds + 1; i < this.t; ++i) {
- r[i - ds - 1] |= (this[i] & bm) << cbs;
+ r[i - ds - 1] |= (this[i] & bm) << cbs;
r[i - ds] = this[i] >> bs;
}
- if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
+ if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
r.t = this.t - ds;
r.clamp();
}
@@ -425,14 +428,14 @@ function bnpSubTo(a, r) {
m = Math.min(a.t, this.t);
while (i < m) {
c += this[i] - a[i];
- r[i++] = c & this.DM;
+ r[i++] = c & this.DM;
c >>= this.DB;
}
if (a.t < this.t) {
c -= a.s;
while (i < this.t) {
c += this[i];
- r[i++] = c & this.DM;
+ r[i++] = c & this.DM;
c >>= this.DB;
}
c += this.s;
@@ -440,7 +443,7 @@ function bnpSubTo(a, r) {
c += this.s;
while (i < a.t) {
c -= a[i];
- r[i++] = c & this.DM;
+ r[i++] = c & this.DM;
c >>= this.DB;
}
c -= a.s;
@@ -551,7 +554,7 @@ function bnpDivRemTo(m, q, r) {
function bnMod(a) {
var r = nbi();
this.abs().divRemTo(a, null, r);
- if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
+ if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
return r;
}
@@ -604,11 +607,11 @@ Classic.prototype.sqrTo = cSqrTo;
function bnpInvDigit() {
if (this.t < 1) return 0;
var x = this[0];
- if ((x & 1) == 0) return 0;
- var y = x & 3; // y == 1/x mod 2^2
- y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
- y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
- y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
+ if ((x & 1) == 0) return 0;
+ var y = x & 3; // y == 1/x mod 2^2
+ y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
+ y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
+ y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
// last step - calculate inverse mod DV directly;
// assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
@@ -621,7 +624,7 @@ function bnpInvDigit() {
function Montgomery(m) {
this.m = m;
this.mp = m.invDigit();
- this.mpl = this.mp & 0x7fff;
+ this.mpl = this.mp & 0x7fff;
this.mph = this.mp >> 15;
this.um = (1 << (m.DB - 15)) - 1;
this.mt2 = 2 * m.t;
@@ -633,7 +636,7 @@ function montConvert(x) {
var r = nbi();
x.abs().dlShiftTo(this.m.t, r);
r.divRemTo(this.m, null, r);
- if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
+ if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
return r;
}
@@ -653,8 +656,8 @@ function montReduce(x) {
x[x.t++] = 0;
for (var i = 0; i < this.m.t; ++i) {
// faster way of calculating u0 = x[i]*mp mod DV
- var j = x[i] & 0x7fff;
- var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
+ var j = x[i] & 0x7fff;
+ var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
// use am to combine the multiply-shift-add into one call
j = i + this.m.t;
x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
@@ -692,7 +695,7 @@ Montgomery.prototype.sqrTo = montSqrTo;
// (protected) true iff this is even
function bnpIsEven() {
- return ((this.t > 0) ? (this[0] & 1) : this.s) == 0;
+ return ((this.t > 0) ? (this[0] & 1) : this.s) == 0;
}
// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
@@ -706,7 +709,7 @@ function bnpExp(e, z) {
g.copyTo(r);
while (--i >= 0) {
z.sqrTo(r, r2);
- if ((e & (1 << i)) > 0) z.mulTo(r2, g, r);
+ if ((e & (1 << i)) > 0) z.mulTo(r2, g, r);
else {
var t = r;
r = r2;
@@ -830,7 +833,7 @@ function bnIntValue() {
} else if (this.t == 1) return this[0];
else if (this.t == 0) return 0;
// assumes 16 < DB < 32
- return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
+ return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
}
// (public) return value as byte
@@ -855,7 +858,7 @@ function bnpChunkSize(r) {
function bnSigNum() {
if (this.s < 0) return -1;
- else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
+ else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
else return 1;
}
@@ -891,7 +894,7 @@ function bnpFromRadix(s, b) {
for (var i = 0; i < s.length; ++i) {
var x = intAt(s, i);
if (x < 0) {
- if (s.charAt(i) == "-" && this.signum() == 0) mi = true;
+ if (s.charAt(i) == "-" && this.signum() == 0) mi = true;
continue;
}
w = b * w + x;
@@ -928,10 +931,10 @@ function bnpFromNumber(a, b, c) {
} else {
// new BigInteger(int,RNG)
var x = new Array(),
- t = a & 7;
+ t = a & 7;
x.length = (a >> 3) + 1;
b.nextBytes(x);
- if (t > 0) x[0] &= ((1 << t) - 1);
+ if (t > 0) x[0] &= ((1 << t) - 1);
else x[0] = 0;
this.fromString(x, 256);
}
@@ -946,21 +949,21 @@ function bnToByteArray() {
var p = this.DB - (i * this.DB) % 8,
d, k = 0;
if (i-- > 0) {
- if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p)
+ if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p)
r[k++] = d | (this.s << (this.DB - p));
while (i >= 0) {
if (p < 8) {
- d = (this[i] & ((1 << p) - 1)) << (8 - p);
+ d = (this[i] & ((1 << p) - 1)) << (8 - p);
d |= this[--i] >> (p += this.DB - 8);
} else {
- d = (this[i] >> (p -= 8)) & 0xff;
+ d = (this[i] >> (p -= 8)) & 0xff;
if (p <= 0) {
p += this.DB;
--i;
}
}
- //if((d&0x80) != 0) d |= -256;
- //if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
+ //if((d&0x80) != 0) d |= -256;
+ //if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
if (k > 0 || d != this.s) r[k++] = d;
}
}
@@ -985,11 +988,11 @@ function bnpBitwiseTo(a, op, r) {
var i, f, m = Math.min(a.t, this.t);
for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]);
if (a.t < this.t) {
- f = a.s & this.DM;
+ f = a.s & this.DM;
for (i = m; i < this.t; ++i) r[i] = op(this[i], f);
r.t = this.t;
} else {
- f = this.s & this.DM;
+ f = this.s & this.DM;
for (i = m; i < a.t; ++i) r[i] = op(f, a[i]);
r.t = a.t;
}
@@ -997,10 +1000,10 @@ function bnpBitwiseTo(a, op, r) {
r.clamp();
}
-// (public) this & a
+// (public) this & a
function op_and(x, y) {
- return x & y;
+ return x & y;
}
function bnAnd(a) {
@@ -1033,10 +1036,10 @@ function bnXor(a) {
return r;
}
-// (public) this & ~a
+// (public) this & ~a
function op_andnot(x, y) {
- return x & ~y;
+ return x & ~y;
}
function bnAndNot(a) {
@@ -1049,7 +1052,7 @@ function bnAndNot(a) {
function bnNot() {
var r = nbi();
- for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i];
+ for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i];
r.t = this.t;
r.s = ~this.s;
return r;
@@ -1078,23 +1081,23 @@ function bnShiftRight(n) {
function lbit(x) {
if (x == 0) return -1;
var r = 0;
- if ((x & 0xffff) == 0) {
+ if ((x & 0xffff) == 0) {
x >>= 16;
r += 16;
}
- if ((x & 0xff) == 0) {
+ if ((x & 0xff) == 0) {
x >>= 8;
r += 8;
}
- if ((x & 0xf) == 0) {
+ if ((x & 0xf) == 0) {
x >>= 4;
r += 4;
}
- if ((x & 3) == 0) {
+ if ((x & 3) == 0) {
x >>= 2;
r += 2;
}
- if ((x & 1) == 0)++r;
+ if ((x & 1) == 0)++r;
return r;
}
@@ -1112,7 +1115,7 @@ function bnGetLowestSetBit() {
function cbit(x) {
var r = 0;
while (x != 0) {
- x &= x - 1;
+ x &= x - 1;
++r;
}
return r;
@@ -1122,7 +1125,7 @@ function cbit(x) {
function bnBitCount() {
var r = 0,
- x = this.s & this.DM;
+ x = this.s & this.DM;
for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x);
return r;
}
@@ -1132,7 +1135,7 @@ function bnBitCount() {
function bnTestBit(n) {
var j = Math.floor(n / this.DB);
if (j >= this.t) return (this.s != 0);
- return ((this[j] & (1 << (n % this.DB))) != 0);
+ return ((this[j] & (1 << (n % this.DB))) != 0);
}
// (protected) this op (1<<n)
@@ -1149,7 +1152,7 @@ function bnSetBit(n) {
return this.changeBit(n, op_or);
}
-// (public) this & ~(1<<n)
+// (public) this & ~(1<<n)
function bnClearBit(n) {
return this.changeBit(n, op_andnot);
@@ -1169,14 +1172,14 @@ function bnpAddTo(a, r) {
m = Math.min(a.t, this.t);
while (i < m) {
c += this[i] + a[i];
- r[i++] = c & this.DM;
+ r[i++] = c & this.DM;
c >>= this.DB;
}
if (a.t < this.t) {
c += a.s;
while (i < this.t) {
c += this[i];
- r[i++] = c & this.DM;
+ r[i++] = c & this.DM;
c >>= this.DB;
}
c += this.s;
@@ -1184,7 +1187,7 @@ function bnpAddTo(a, r) {
c += this.s;
while (i < a.t) {
c += a[i];
- r[i++] = c & this.DM;
+ r[i++] = c & this.DM;
c >>= this.DB;
}
c += a.s;
@@ -1431,14 +1434,14 @@ function bnModPow(e, m) {
t;
i = nbits(e[j]) - 1;
while (j >= 0) {
- if (i >= k1) w = (e[j] >> (i - k1)) & km;
+ if (i >= k1) w = (e[j] >> (i - k1)) & km;
else {
- w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
+ w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
if (j > 0) w |= e[j - 1] >> (this.DB + i - k1);
}
n = k;
- while ((w & 1) == 0) {
+ while ((w & 1) == 0) {
w >>= 1;
--n;
}
@@ -1464,7 +1467,7 @@ function bnModPow(e, m) {
z.mulTo(r2, g[w], r);
}
- while (j >= 0 && (e[j] & (1 << i)) == 0) {
+ while (j >= 0 && (e[j] & (1 << i)) == 0) {
z.sqrTo(r, r2);
t = r;
r = r2;
@@ -1527,7 +1530,7 @@ function bnpModInt(n) {
function bnModInverse(m) {
var ac = m.isEven();
- if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
+ if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
var u = m.clone(),
v = this.clone();
var a = nbv(1),
@@ -1590,7 +1593,7 @@ var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
function bnIsProbablePrime(t) {
var i, x = this.abs();
- if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
+ if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
for (i = 0; i < lowprimes.length; ++i)
if (x[0] == lowprimes[i]) return true;
return false;
@@ -1600,7 +1603,7 @@ function bnIsProbablePrime(t) {
while (i < lowprimes.length) {
var m = lowprimes[i],
j = i + 1;
- while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
+ while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
m = x.modInt(m);
while (i < j) if (m % lowprimes[i++] == 0) return false;
}
@@ -1639,8 +1642,8 @@ function bnToMPI() {
var ba = this.toByteArray();
var size = (ba.length - 1) * 8 + nbits(ba[0]);
var result = "";
- result += String.fromCharCode((size & 0xFF00) >> 8);
- result += String.fromCharCode(size & 0xFF);
+ result += String.fromCharCode((size & 0xFF00) >> 8);
+ result += String.fromCharCode(size & 0xFF);
result += util.bin2str(ba);
return result;
}
@@ -1665,9 +1668,9 @@ function bnpMillerRabin(t) {
bases.push(j);
a.fromInt(j);
var y = a.modPow(r, this);
- if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
+ if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
var j = 1;
- while (j++ < k && y.compareTo(n1) != 0) {
+ while (j++ < k && y.compareTo(n1) != 0) {
y = y.modPowInt(2, this);
if (y.compareTo(BigInteger.ONE) == 0) return false;
}
@@ -1742,13 +1745,13 @@ BigInteger.prototype.square = bnSquare;
diff --git a/doc/jxg.js.html b/doc/jxg.js.html
index 1ad13b53..4f7a3268 100644
--- a/doc/jxg.js.html
+++ b/doc/jxg.js.html
@@ -178,11 +178,11 @@ JXG.Util.Unzip = function(barray) {
function readBit() {
var carry;
bits++;
- carry = (bb & 1);
+ carry = (bb & 1);
bb >>= 1;
if (bb == 0) {
bb = readByte();
- carry = (bb & 1);
+ carry = (bb & 1);
bb = (bb >> 1) | 0x80;
}
return carry;
@@ -329,13 +329,13 @@ JXG.Util.Unzip = function(barray) {
var tmp;
for(tmp=currentTree;tmp<Places;tmp++) {
fprintf(stdout, "0x%03x 0x%03x (0x%04x)",tmp-currentTree, tmp->jump?tmp->jump-currentTree:0,(tmp->jump?tmp->jump-currentTree:0)*6+0xcf0);
- if(!(tmp.b0 & 0x8000)) {
- //fprintf(stdout, " 0x%03x (%c)", tmp->b0,(tmp->b0<256 && isprint(tmp->b0))?tmp->b0:'�');
+ if(!(tmp.b0 & 0x8000)) {
+ //fprintf(stdout, " 0x%03x (%c)", tmp->b0,(tmp->b0<256 && isprint(tmp->b0))?tmp->b0:'�');
}
- if(!(tmp.b1 & 0x8000)) {
- if((tmp.b0 & 0x8000))
+ if(!(tmp.b1 & 0x8000)) {
+ if((tmp.b0 & 0x8000))
fprintf(stdout, " ");
- fprintf(stdout, " 0x%03x (%c)", tmp->b1,(tmp->b1<256 && isprint(tmp->b1))?tmp->b1:'�');
+ fprintf(stdout, " 0x%03x (%c)", tmp->b1,(tmp->b1<256 && isprint(tmp->b1))?tmp->b1:'�');
}
fprintf(stdout, "\n");
}
@@ -355,7 +355,7 @@ JXG.Util.Unzip = function(barray) {
if (debug)
document.write("b=" + b);
if (b) {
- if (!(X.b1 & 0x8000)) {
+ if (!(X.b1 & 0x8000)) {
if (debug)
document.write("ret1");
return X.b1; /* If leaf node, return data */
@@ -370,7 +370,7 @@ JXG.Util.Unzip = function(barray) {
}
//xtreepos++;
} else {
- if (!(X.b0 & 0x8000)) {
+ if (!(X.b0 & 0x8000)) {
if (debug)
document.write("ret2");
return X.b0; /* If leaf node, return data */
@@ -427,7 +427,7 @@ JXG.Util.Unzip = function(barray) {
cSum = readByte();
cSum |= (readByte() << 8);
- if (((blockLen ^ ~cSum) & 0xffff)) {
+ if (((blockLen ^ ~cSum) & 0xffff)) {
document.write("BlockLen checksum mismatch\n");
}
while (blockLen--) {
@@ -497,7 +497,7 @@ JXG.Util.Unzip = function(barray) {
/*fprintf(errfp, "@%d (l%02x,d%04x)\n", SIZE, len, dist);*/
for (j = 0; j < len; j++) {
- var c = buf32k[(bIdx - dist) & 0x7fff];
+ var c = buf32k[(bIdx - dist) & 0x7fff];
addBuffer(c);
}
}
@@ -585,7 +585,7 @@ JXG.Util.Unzip = function(barray) {
}
/*for(j=0; j<literalCodes+distCodes; j++) {
//fprintf(errfp, "%d ", ll[j]);
- if ((j&7)==7)
+ if ((j&7)==7)
fprintf(errfp, "\n");
}
fprintf(errfp, "\n");*/
@@ -634,7 +634,7 @@ JXG.Util.Unzip = function(barray) {
if (bIdx - dist < 0) {
break outer;
}
- var c = buf32k[(bIdx - dist) & 0x7fff];
+ var c = buf32k[(bIdx - dist) & 0x7fff];
addBuffer(c);
}
} else {
@@ -710,7 +710,7 @@ JXG.Util.Unzip = function(barray) {
tmp[1] = readByte();
if (debug)
alert("type: " + tmp[0] + " " + tmp[1]);
- if (tmp[0] == parseInt("78", 16) && tmp[1] == parseInt("da", 16)) { //GZIP
+ if (tmp[0] == parseInt("78", 16) && tmp[1] == parseInt("da", 16)) { //GZIP
if (debug)
alert("GEONExT-GZIP");
DeflateLoop();
@@ -721,7 +721,7 @@ JXG.Util.Unzip = function(barray) {
unzipped[files][1] = "geonext.gxt";
files++;
}
- if (tmp[0] == parseInt("78", 16) && tmp[1] == parseInt("9c", 16)) { //ZLIB
+ if (tmp[0] == parseInt("78", 16) && tmp[1] == parseInt("9c", 16)) { //ZLIB
if (debug)
alert("ZLIB");
DeflateLoop();
@@ -732,7 +732,7 @@ JXG.Util.Unzip = function(barray) {
unzipped[files][1] = "ZLIB";
files++;
}
- if (tmp[0] == parseInt("1f", 16) && tmp[1] == parseInt("8b", 16)) { //GZIP
+ if (tmp[0] == parseInt("1f", 16) && tmp[1] == parseInt("8b", 16)) { //GZIP
if (debug)
alert("GZIP");
//DeflateLoop();
@@ -744,11 +744,11 @@ JXG.Util.Unzip = function(barray) {
unzipped[files][1] = "file";
files++;
}
- if (tmp[0] == parseInt("50", 16) && tmp[1] == parseInt("4b", 16)) { //ZIP
+ if (tmp[0] == parseInt("50", 16) && tmp[1] == parseInt("4b", 16)) { //ZIP
modeZIP = true;
tmp[2] = readByte();
tmp[3] = readByte();
- if (tmp[2] == parseInt("3", 16) && tmp[3] == parseInt("4", 16)) {
+ if (tmp[2] == parseInt("3", 16) && tmp[3] == parseInt("4", 16)) {
//MODE_ZIP
tmp[0] = readByte();
tmp[1] = readByte();
@@ -821,7 +821,7 @@ JXG.Util.Unzip = function(barray) {
CRC = 0xffffffff;
SIZE = 0;
- if (size == 0 && fileOut.charAt(fileout.length - 1) == "/") {
+ if (size == 0 && fileOut.charAt(fileout.length - 1) == "/") {
//skipdir
if (debug)
alert("skipdir");
@@ -846,15 +846,15 @@ JXG.Util.Unzip = function(barray) {
tmp = [],
compSize, size, os, i, c;
- if ((gpflags & 8)) {
+ if ((gpflags & 8)) {
tmp[0] = readByte();
tmp[1] = readByte();
tmp[2] = readByte();
tmp[3] = readByte();
- if (tmp[0] == parseInt("50", 16) &&
- tmp[1] == parseInt("4b", 16) &&
- tmp[2] == parseInt("07", 16) &&
+ if (tmp[0] == parseInt("50", 16) &&
+ tmp[1] == parseInt("4b", 16) &&
+ tmp[2] == parseInt("07", 16) &&
tmp[3] == parseInt("08", 16)) {
crc = readByte();
crc |= (readByte() << 8);
@@ -890,7 +890,7 @@ JXG.Util.Unzip = function(barray) {
gpflags = readByte();
if (debug) {
- if ((gpflags & ~(parseInt("1f", 16))))
+ if ((gpflags & ~(parseInt("1f", 16))))
alert("Unknown flags set!");
}
@@ -902,7 +902,7 @@ JXG.Util.Unzip = function(barray) {
readByte();
os = readByte();
- if ((gpflags & 4)) {
+ if ((gpflags & 4)) {
tmp[0] = readByte();
tmp[2] = readByte();
len = tmp[0] + 256 * tmp[1];
@@ -912,7 +912,7 @@ JXG.Util.Unzip = function(barray) {
readByte();
}
- if ((gpflags & 8)) {
+ if ((gpflags & 8)) {
i = 0;
nameBuf = [];
while (c = readByte()) {
@@ -926,13 +926,13 @@ JXG.Util.Unzip = function(barray) {
alert("original file name: " + nameBuf);
}
- if ((gpflags & 16)) {
+ if ((gpflags & 16)) {
while (c = readByte()) {
//FILE COMMENT
}
}
- if ((gpflags & 2)) {
+ if ((gpflags & 2)) {
readByte();
readByte();
}
@@ -980,9 +980,9 @@ JXG.Util.Base64 = {
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
- enc4 = chr3 & 63;
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+ enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
@@ -1017,8 +1017,8 @@ JXG.Util.Base64 = {
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
- chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
- chr3 = ((enc3 & 3) << 6) | enc4;
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
+ chr3 = ((enc3 & 3) << 6) | enc4;
output.push(String.fromCharCode(chr1));
@@ -1050,13 +1050,13 @@ JXG.Util.Base64 = {
if (c < 128) {
utftext += String.fromCharCode(c);
- } else if ((c > 127) && (c < 2048)) {
+ } else if ((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
- utftext += String.fromCharCode((c & 63) | 128);
+ utftext += String.fromCharCode((c & 63) | 128);
} else {
utftext += String.fromCharCode((c >> 12) | 224);
- utftext += String.fromCharCode(((c >> 6) & 63) | 128);
- utftext += String.fromCharCode((c & 63) | 128);
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
+ utftext += String.fromCharCode((c & 63) | 128);
}
}
@@ -1077,14 +1077,14 @@ JXG.Util.Base64 = {
if (c < 128) {
string.push(String.fromCharCode(c));
i++;
- } else if ((c > 191) && (c < 224)) {
+ } else if ((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i + 1);
- string.push(String.fromCharCode(((c & 31) << 6) | (c2 & 63)));
+ string.push(String.fromCharCode(((c & 31) << 6) | (c2 & 63)));
i += 2;
} else {
c2 = utftext.charCodeAt(i + 1);
c3 = utftext.charCodeAt(i + 2);
- string.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
+ string.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
i += 3;
}
}
@@ -1241,14 +1241,14 @@ JXG.Util.utf8Decode = function(utftext) {
if (c < 128) {
string.push(String.fromCharCode(c));
i++;
- } else if ((c > 191) && (c < 224)) {
+ } else if ((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i + 1);
- string.push(String.fromCharCode(((c & 31) << 6) | (c2 & 63)));
+ string.push(String.fromCharCode(((c & 31) << 6) | (c2 & 63)));
i += 2;
} else {
c2 = utftext.charCodeAt(i + 1);
c3 = utftext.charCodeAt(i + 2);
- string.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
+ string.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
i += 3;
}
};
@@ -1281,9 +1281,9 @@ JXG.Util.genUUID = function() {
uuid[i] = '4';
} else {
if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0;
- r = rnd & 0xf;
+ r = rnd & 0xf;
rnd = rnd >> 4;
- uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
+ uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
@@ -1302,13 +1302,13 @@ module.exports = JXG;
diff --git a/doc/key.js.html b/doc/key.js.html
index 5bdae82e..336bafa9 100644
--- a/doc/key.js.html
+++ b/doc/key.js.html
@@ -42,12 +42,18 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module key */
+/**
+ * @requires config
+ * @requires encoding/armor
+ * @requires enums
+ * @requires packet
+ * @module key
+ */
-var packet = require('./packet');
-var enums = require('./enums.js');
-var armor = require('./encoding/armor.js');
-var config = require('./config');
+var packet = require('./packet'),
+ enums = require('./enums.js'),
+ armor = require('./encoding/armor.js'),
+ config = require('./config');
/**
* @class
@@ -317,7 +323,7 @@ Key.prototype.getSigningKeyPacket = function() {
throw new Error('Need private key for signing');
}
var primaryUser = this.getPrimaryUser();
- if (primaryUser &&
+ if (primaryUser &&
isValidSigningKeyPacket(this.primaryKey, primaryUser.selfCertificate)) {
return this.primaryKey;
}
@@ -337,25 +343,25 @@ Key.prototype.getSigningKeyPacket = function() {
*/
Key.prototype.getPreferredHashAlgorithm = function() {
var primaryUser = this.getPrimaryUser();
- if (primaryUser && primaryUser.selfCertificate.preferredHashAlgorithms) {
+ if (primaryUser && primaryUser.selfCertificate.preferredHashAlgorithms) {
return primaryUser.selfCertificate.preferredHashAlgorithms[0];
}
return config.prefer_hash_algorithm;
};
function isValidEncryptionKeyPacket(keyPacket, signature) {
- return keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.dsa) &&
- keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.rsa_sign) &&
- ((signature.keyFlags & enums.keyFlags.encrypt_communication) !== 0 ||
- (signature.keyFlags & enums.keyFlags.encrypt_storage) !== 0 ||
+ return keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.dsa) &&
+ keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.rsa_sign) &&
+ ((signature.keyFlags & enums.keyFlags.encrypt_communication) !== 0 ||
+ (signature.keyFlags & enums.keyFlags.encrypt_storage) !== 0 ||
!signature.keyFlags);
};
function isValidSigningKeyPacket(keyPacket, signature) {
return (keyPacket.algorithm == enums.read(enums.publicKey, enums.publicKey.dsa) ||
keyPacket.algorithm == enums.read(enums.publicKey, enums.publicKey.rsa_sign) ||
- keyPacket.algorithm == enums.read(enums.publicKey, enums.publicKey.rsa_encrypt_sign)) &&
- ((signature.keyFlags & enums.keyFlags.sign_data) !== 0 ||
+ keyPacket.algorithm == enums.read(enums.publicKey, enums.publicKey.rsa_encrypt_sign)) &&
+ ((signature.keyFlags & enums.keyFlags.sign_data) !== 0 ||
!signature.keyFlags);
};
@@ -375,7 +381,7 @@ Key.prototype.getEncryptionKeyPacket = function() {
}
// if no valid subkey for encryption, evaluate primary key
var primaryUser = this.getPrimaryUser();
- if (primaryUser &&
+ if (primaryUser &&
isValidEncryptionKeyPacket(this.primaryKey, primaryUser.selfCertificate)) {
return this.primaryKey;
}
@@ -431,13 +437,13 @@ Key.prototype.decryptKeyPacket = function(keyIds, passphrase) {
*/
Key.prototype.verifyPrimaryKey = function() {
// check revocation signature
- if (this.revocationSignature && !this.revocationSignature.isExpired() &&
+ if (this.revocationSignature && !this.revocationSignature.isExpired() &&
(this.revocationSignature.verified ||
this.revocationSignature.verify(this.primaryKey, {key: this.primaryKey}))) {
return enums.keyStatus.revoked;
}
// check V3 expiration time
- if (this.primaryKey.version == 3 && this.primaryKey.expirationTimeV3 !== 0 &&
+ if (this.primaryKey.version == 3 && this.primaryKey.expirationTimeV3 !== 0 &&
Date.now() > (this.primaryKey.created.getTime() + this.primaryKey.expirationTimeV3*24*3600*1000)) {
return enums.keyStatus.expired;
}
@@ -445,7 +451,7 @@ Key.prototype.verifyPrimaryKey = function() {
// See http://tools.ietf.org/html/rfc4880#section-11.1
var selfSigned = false;
for (var i = 0; i < this.users.length; i++) {
- if (this.users[i].userId && this.users[i].selfCertifications) {
+ if (this.users[i].userId && this.users[i].selfCertifications) {
selfSigned = true;
}
}
@@ -458,7 +464,7 @@ Key.prototype.verifyPrimaryKey = function() {
return enums.keyStatus.invalid;
}
// check V4 expiration time
- if (this.primaryKey.version == 4 && primaryUser.selfCertificate.keyNeverExpires === false &&
+ if (this.primaryKey.version == 4 && primaryUser.selfCertificate.keyNeverExpires === false &&
Date.now() > (primaryUser.selfCertificate.created.getTime() + primaryUser.selfCertificate.keyExpirationTime*1000)) {
return enums.keyStatus.expired;
}
@@ -483,7 +489,7 @@ Key.prototype.getPrimaryUser = function() {
continue;
}
if (!user ||
- !userSelfCert.isPrimaryUserID && selfCert.isPrimaryUserID ||
+ !userSelfCert.isPrimaryUserID && selfCert.isPrimaryUserID ||
userSelfCert.created < selfCert.created) {
user = this.users[i];
userSelfCert = selfCert;
@@ -535,8 +541,8 @@ User.prototype.isRevoked = function(certificate, primaryKey) {
if (this.revocationCertifications) {
var that = this;
return this.revocationCertifications.some(function(revCert) {
- return revCert.issuerKeyId.equals(certificate.issuerKeyId) &&
- !revCert.isExpired() &&
+ return revCert.issuerKeyId.equals(certificate.issuerKeyId) &&
+ !revCert.isExpired() &&
(revCert.verified ||
revCert.verify(primaryKey, {userid: that.userId || that.userAttribute, key: primaryKey}));
});
@@ -559,7 +565,7 @@ User.prototype.getValidSelfCertificate = function(primaryKey) {
if (this.isRevoked(this.selfCertifications[i], primaryKey)) {
continue;
}
- if (!this.selfCertifications[i].isExpired() &&
+ if (!this.selfCertifications[i].isExpired() &&
(this.selfCertifications[i].verified ||
this.selfCertifications[i].verify(primaryKey, {userid: this.userId || this.userAttribute, key: primaryKey}))) {
validCert.push(this.selfCertifications[i]);
@@ -636,7 +642,7 @@ SubKey.prototype.toPacketlist = function() {
* @return {Boolean}
*/
SubKey.prototype.isValidEncryptionKey = function(primaryKey) {
- return this.verify(primaryKey) == enums.keyStatus.valid &&
+ return this.verify(primaryKey) == enums.keyStatus.valid &&
isValidEncryptionKeyPacket(this.subKey, this.bindingSignature);
};
@@ -646,7 +652,7 @@ SubKey.prototype.isValidEncryptionKey = function(primaryKey) {
* @return {Boolean}
*/
SubKey.prototype.isValidSigningKey = function(primaryKey) {
- return this.verify(primaryKey) == enums.keyStatus.valid &&
+ return this.verify(primaryKey) == enums.keyStatus.valid &&
isValidSigningKeyPacket(this.subKey, this.bindingSignature);
};
@@ -657,13 +663,13 @@ SubKey.prototype.isValidSigningKey = function(primaryKey) {
*/
SubKey.prototype.verify = function(primaryKey) {
// check subkey revocation signature
- if (this.revocationSignature && !this.revocationSignature.isExpired() &&
+ if (this.revocationSignature && !this.revocationSignature.isExpired() &&
(this.revocationSignature.verified ||
this.revocationSignature.verify(primaryKey, {key: this.subKey}))) {
return enums.keyStatus.revoked;
}
// check V3 expiration time
- if (this.subKey.version == 3 && this.subKey.expirationTimeV3 !== 0 &&
+ if (this.subKey.version == 3 && this.subKey.expirationTimeV3 !== 0 &&
Date.now() > (this.subKey.created.getTime() + this.subKey.expirationTimeV3*24*3600*1000)) {
return enums.keyStatus.expired;
}
@@ -679,8 +685,8 @@ SubKey.prototype.verify = function(primaryKey) {
return enums.keyStatus.invalid;
}
// check V4 expiration time
- if (this.subKey.version == 4 &&
- this.bindingSignature.keyNeverExpires === false &&
+ if (this.subKey.version == 4 &&
+ this.bindingSignature.keyNeverExpires === false &&
Date.now() > (this.subKey.created.getTime() + this.bindingSignature.keyExpirationTime*1000)) {
return enums.keyStatus.expired;
}
@@ -691,6 +697,7 @@ SubKey.prototype.verify = function(primaryKey) {
* Reads an OpenPGP armored text and returns one or multiple key objects
* @param {String} armoredText text to be parsed
* @return {{keys: Array<module:key~Key>, err: (Array<Error>|null)}} result object with key and error arrays
+ * @static
*/
function readArmored(armoredText) {
var result = {};
@@ -732,6 +739,7 @@ function readArmored(armoredText) {
* @param {String} userId assumes already in form of "User Name <username@email.com>"
* @param {String} passphrase The passphrase used to encrypt the resulting private key
* @return {module:key~Key}
+ * @static
*/
function generate(keyType, numBits, userId, passphrase) {
var packetlist = new packet.list();
@@ -793,13 +801,13 @@ exports.generate = generate;
diff --git a/doc/keyid.html b/doc/keyid.html
index b92ca530..49762552 100644
--- a/doc/keyid.html
+++ b/doc/keyid.html
@@ -36,8 +36,16 @@
+
Implementation of type key id (RFC4880 3.3)
+
+A Key ID is an eight-octet scalar that identifies a key.
+Implementations SHOULD NOT assume that Key IDs are unique. The
+section "Enhanced Key Formats" below describes how Key IDs are
+formed.
- Initialization routine for the keyring. This method reads the
-keyring from HTML5 local storage and initializes this instance.
-This method is called by openpgp.init().
-
+
@@ -1196,13 +2035,13 @@ This method is called by openpgp.init().
diff --git a/doc/keyring.js.html b/doc/keyring.js.html
index bf4019f4..4979f779 100644
--- a/doc/keyring.js.html
+++ b/doc/keyring.js.html
@@ -42,36 +42,55 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module keyring/keyring */
+/**
+ * The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
+ * @requires openpgp
+ * @module keyring/keyring
+ */
var openpgp = require('openpgp');
/**
- * @class
- * @classdesc The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
+ * Callback to check if a key matches the input
+ * @callback module:keyring/keyring.checkCallback
+ * @param {String} input input to search for
+ * @param {module:key~Key} key The key to be checked.
+ * @return {Boolean} True if the input matches the specified key
*/
-module.exports = function() {
- this.keys = [];
+
+/**
+ * Initialization routine for the keyring. This method reads the
+ * keyring from HTML5 local storage and initializes this instance.
+ * @constructor
+ * @param {class} [storeHandler] class implementing load() and store() methods
+ */
+module.exports = function(storeHandler) {
+ if (!storeHandler) {
+ storeHandler = new (require('./localstore.js'))();
+ }
+ this.storeHandler = storeHandler;
+ this.keys = this.storeHandler.load();
/**
- * Initialization routine for the keyring. This method reads the
- * keyring from HTML5 local storage and initializes this instance.
- * This method is called by openpgp.init().
+ * Calls the storeHandler to save the keys
*/
- this.init = function (storeHandler) {
- if (!storeHandler) {
- var localstore = require('./localstore.js');
- storeHandler = new localstore();
- }
- this.storeHandler = storeHandler;
- this.keys = [];
- this.storeHandler.init(this.keys);
- }
-
this.store = function () {
this.storeHandler.store(this.keys);
- }
+ };
+ /**
+ * Clear the keyring - erase all the keys
+ */
+ this.clear = function() {
+ this.keys = [];
+ };
+
+ /**
+ * Checks a key to see if it matches the specified email address
+ * @param {String} email email address to search for
+ * @param {module:key~Key} key The key to be checked.
+ * @return {Boolean} True if the email address is defined in the specified key
+ */
function emailCheck(email, key) {
email = email.toLowerCase();
var keyEmails = key.getUserIds();
@@ -85,6 +104,13 @@ module.exports = function() {
return false;
}
+ /**
+ * Checks a key to see if it matches the specified keyid
+ * @param {String} id hex string keyid to search for
+ * @param {module:key~Key} key the key to be checked.
+ * @return {Boolean} true if the email address is defined in the specified key
+ * @inner
+ */
function idCheck(id, key) {
var keyids = key.getKeyIds();
for (var i = 0; i < keyids.length; i++) {
@@ -95,18 +121,26 @@ module.exports = function() {
return false;
}
+ /**
+ * searches all public keys in the keyring matching the address or address part of the user ids
+ * @param {Array<module:key~Key>} keys array of keys to search
+ * @param {module:keyring/keyring.checkCallback} identityFunction callback function which checks for a match
+ * @param {String} identityInput input to check against
+ * @param {module:enums.packet} keyType packet types of keys to check
+ * @return {Array<module:key~Key>} array of keys which match
+ */
function checkForIdentityAndKeyTypeMatch(keys, identityFunction, identityInput, keyType) {
var results = [];
for (var p = 0; p < keys.length; p++) {
var key = keys[p];
switch (keyType) {
case openpgp.enums.packet.public_key:
- if (key.isPublic() && identityFunction(identityInput, key)) {
+ if (key.isPublic() && identityFunction(identityInput, key)) {
results.push(key);
}
break;
case openpgp.enums.packet.private_key:
- if (key.isPrivate() && identityFunction(identityInput, key)) {
+ if (key.isPrivate() && identityFunction(identityInput, key)) {
results.push(key);
}
break;
@@ -114,7 +148,6 @@ module.exports = function() {
}
return results;
}
- this.checkForIdentityAndKeyTypeMatch = checkForIdentityAndKeyTypeMatch;
/**
* searches all public keys in the keyring matching the address or address part of the user ids
@@ -123,71 +156,64 @@ module.exports = function() {
*/
this.getPublicKeyForAddress = function (email) {
return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.public_key);
- }
+ };
/**
* Searches the keyring for a private key containing the specified email address
* @param {String} email email address to search for
* @return {Array<module:key~Key>} private keys found
*/
- function getPrivateKeyForAddress(email) {
+ this.getPrivateKeyForAddress = function (email) {
return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.secret_key);
- }
- this.getPrivateKeyForAddress = getPrivateKeyForAddress;
+ };
/**
* Searches the keyring for public keys having the specified key id
* @param {String} keyId provided as string of hex number (lowercase)
* @return {Array<module:key~Key>} public keys found
*/
- function getKeysForKeyId(keyId) {
- return this.checkForIdentityAndKeyTypeMatch(this.keys, idCheck, keyId, openpgp.enums.packet.public_key);
- }
- this.getKeysForKeyId = getKeysForKeyId;
+ this.getKeysForKeyId = function (keyId) {
+ return checkForIdentityAndKeyTypeMatch(this.keys, idCheck, keyId, openpgp.enums.packet.public_key);
+ };
/**
* Imports a key from an ascii armored message
* @param {String} armored message to read the keys/key from
*/
- function importKey(armored) {
+ this.importKey = function (armored) {
this.keys = this.keys.concat(openpgp.key.readArmored(armored).keys);
return true;
- }
- this.importKey = importKey;
+ };
/**
* returns the armored message representation of the key at key ring index
* @param {Integer} index the index of the key within the array
* @return {String} armored message representing the key object
*/
- function exportKey(index) {
+ this.exportKey = function (index) {
return this.keys[index].armor();
- }
- this.exportKey = exportKey;
+ };
/**
- * Removes a public key from the public key keyring at the specified index
+ * Removes a public key from the public key keyring at the specified index
* @param {Integer} index the index of the public key within the publicKeys array
* @return {module:key~Key} The public key object which has been removed
*/
- function removeKey(index) {
+ this.removeKey = function (index) {
var removed = this.keys.splice(index, 1);
return removed;
- }
- this.removeKey = removeKey;
+ };
/**
* returns the armored message representation of the public key portion of the key at key ring index
* @param {Integer} index the index of the key within the array
* @return {String} armored message representing the public key object
*/
- function exportPublicKey(index) {
+ this.exportPublicKey = function (index) {
return this.keys[index].toPublic().armor();
- }
- this.exportPublicKey = exportPublicKey;
-
+ };
};
Implementation of the Literal Data Packet (Tag 11)
+
+RFC4880 5.9: A Literal Data packet contains the body of a message; data that
+is not to be further interpreted.
@@ -946,13 +960,13 @@ will be normalized to \r\n and by default text is converted to UTF8
diff --git a/doc/literal.js.html b/doc/literal.js.html
index 545dbf66..8819d053 100644
--- a/doc/literal.js.html
+++ b/doc/literal.js.html
@@ -42,19 +42,23 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/literal */
+/**
+ * Implementation of the Literal Data Packet (Tag 11)<br/>
+ * <br/>
+ * RFC4880 5.9: A Literal Data packet contains the body of a message; data that
+ * is not to be further interpreted.
+ * @requires enums
+ * @requires util
+ * @module packet/literal
+ */
var util = require('../util'),
enums = require('../enums.js');
/**
- * @class
- * @classdesc Implementation of the Literal Data Packet (Tag 11)
- *
- * RFC4880 5.9: A Literal Data packet contains the body of a message; data that
- * is not to be further interpreted.
+ * @constructor
*/
-module.exports = function packet_literal() {
+module.exports = function () {
this.format = 'utf8'; // default format for literal data packets
this.data = ''; // literal data representation as native JavaScript string or bytes
this.date = new Date();
@@ -160,13 +164,13 @@ module.exports = function packet_literal() {
diff --git a/doc/localStorage.html b/doc/localStorage.html
new file mode 100644
index 00000000..5ef99a0c
--- /dev/null
+++ b/doc/localStorage.html
@@ -0,0 +1,332 @@
+
+
+
+
+ JSDoc: Module: config/localStorage
+
+
+
+
+
+
+
+
+
+
+
+
+
Module: config/localStorage
+
+
+
+
+
+
+
+
+
+ config/localStorage
+
+
+
+
+
+
+
+
+
This object storing and retrieving configuration from HTML5 local storage.
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/localStorage.js.html b/doc/localStorage.js.html
new file mode 100644
index 00000000..92239422
--- /dev/null
+++ b/doc/localStorage.js.html
@@ -0,0 +1,81 @@
+
+
+
+
+ JSDoc: Source: config/localStorage.js
+
+
+
+
+
+
+
+
+
+
+
+
+
Source: config/localStorage.js
+
+
+
+
+
+
+
+
/**
+ * This object storing and retrieving configuration from HTML5 local storage.
+ * @module config/localStorage
+ */
+
+/**
+ * @constructor
+ */
+module.exports = function () {
+
+ /**
+ * Reads the config out of the HTML5 local storage
+ * and initializes the object config.
+ * if config is null the default config will be used
+ */
+ this.read = function () {
+ var cf = JSON.parse(window.localStorage.getItem("config"));
+ if (cf === null) {
+ this.config = this.default_config;
+ this.write();
+ } else
+ this.config = cf;
+ }
+
+ /**
+ * Writes the config to HTML5 local storage
+ */
+ this.write = function () {
+ window.localStorage.setItem("config", JSON.stringify(this.config));
+ }
+}
+
- Initialization routine for the keyring. This method reads the
-keyring from HTML5 local storage and initializes this instance.
-This method is called by openpgp.init().
+ Load the keyring from HTML5 local storage and initializes this instance.
@@ -204,7 +145,7 @@ This method is called by openpgp.init().
@@ -315,13 +326,13 @@ The privateKeys array and publicKeys array gets Stringified using JSON
diff --git a/doc/localstore.js.html b/doc/localstore.js.html
index 4317deb6..554dfd54 100644
--- a/doc/localstore.js.html
+++ b/doc/localstore.js.html
@@ -42,36 +42,36 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module keyring/localstore */
+/**
+ * The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
+ * @requires openpgp
+ * @module keyring/localstore
+ */
var openpgp = require('openpgp');
-/**
- * @class
- * @classdesc The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
- */
module.exports = function () {
/**
- * Initialization routine for the keyring. This method reads the
- * keyring from HTML5 local storage and initializes this instance.
- * This method is called by openpgp.init().
+ * Load the keyring from HTML5 local storage and initializes this instance.
+ * @return {Array<module:key~Key>} array of keys retrieved from localstore
*/
- this.init = function (keys) {
+ this.load = function () {
var armoredKeys = JSON.parse(window.localStorage.getItem("armoredKeys"));
- if (armoredKeys !== null && armoredKeys.length === 0) {
+ var keys = [];
+ if (armoredKeys !== null && armoredKeys.length !== 0) {
var key;
for (var i = 0; i < armoredKeys.length; i++) {
key = openpgp.key.readArmored(armoredKeys[i]);
keys.push(key);
}
- } else {
- this.keys = [];
}
+ return keys;
}
/**
* Saves the current state of the keyring to HTML5 local storage.
* The privateKeys array and publicKeys array gets Stringified using JSON
+ * @param {Array<module:key~Key>} keys array of keys to save in localstore
*/
this.store = function (keys) {
var armoredKeys = [];
@@ -91,13 +91,13 @@ module.exports = function () {
diff --git a/doc/marker.html b/doc/marker.html
index af2d684a..3cbb6d14 100644
--- a/doc/marker.html
+++ b/doc/marker.html
@@ -36,8 +36,18 @@
+
Implementation of the strange "Marker packet" (Tag 10)
+
+RFC4880 5.8: An experimental version of PGP used this packet as the Literal
+packet, but no released version of PGP generated Literal packets with this
+tag. With PGP 5.x, this packet has been reassigned and is reserved for use as
+the Marker packet.
+
+Such a packet MUST be ignored when received.
diff --git a/doc/marker.js.html b/doc/marker.js.html
index fc39cffe..2e235959 100644
--- a/doc/marker.js.html
+++ b/doc/marker.js.html
@@ -42,18 +42,21 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/marker */
/**
- * @class
- * @classdesc Implementation of the strange "Marker packet" (Tag 10)
- *
+ * Implementation of the strange "Marker packet" (Tag 10)<br/>
+ * <br/>
* RFC4880 5.8: An experimental version of PGP used this packet as the Literal
* packet, but no released version of PGP generated Literal packets with this
* tag. With PGP 5.x, this packet has been reassigned and is reserved for use as
- * the Marker packet.
- *
+ * the Marker packet.<br/>
+ * <br/>
* Such a packet MUST be ignored when received.
+ * @module packet/marker
+ */
+
+/**
+ * @constructor
*/
module.exports = function () {
/**
@@ -68,8 +71,8 @@ module.exports = function () {
* @return {module:packet/marker} Object representation
*/
this.read = function(bytes) {
- if (bytes.charCodeAt(0) == 0x50 && // P
- bytes.charCodeAt(1) == 0x47 && // G
+ if (bytes.charCodeAt(0) == 0x50 && // P
+ bytes.charCodeAt(1) == 0x47 && // G
bytes.charCodeAt(2) == 0x50) // P
return true;
// marker packet does not contain "PGP"
@@ -86,13 +89,13 @@ module.exports = function () {
diff --git a/doc/md5.html b/doc/md5.html
index b7625cc9..e42c4ad3 100644
--- a/doc/md5.html
+++ b/doc/md5.html
@@ -35,6 +35,124 @@
0x01: Signature of a canonical text document.
+Canonicalyzing the document by converting line endings.
+
+
+
+
+
+
+
standalone
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+
+
0x02: Standalone signature.
+This signature is a signature of only its own subpacket contents.
+It is calculated identically to a signature over a zero-lengh
+binary document. Note that it doesn't make sense to have a V3
+standalone signature.
+
+
+
+
+
+
+
cert_generic
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 16
+
+
+
+
+
0x10: Generic certification of a User ID and Public-Key packet.
+The issuer of this certification does not make any particular
+assertion as to how well the certifier has checked that the owner
+of the key is in fact the person described by the User ID.
+
+
+
+
+
+
+
cert_persona
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 17
+
+
+
+
+
0x11: Persona certification of a User ID and Public-Key packet.
+The issuer of this certification has not done any verification of
+the claim that the owner of this key is the User ID specified.
+
+
+
+
+
+
+
cert_casual
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 18
+
+
+
+
+
0x12: Casual certification of a User ID and Public-Key packet.
+The issuer of this certification has done some casual
+verification of the claim of identity.
+
+
+
+
+
+
+
cert_positive
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 19
+
+
+
+
+
0x13: Positive certification of a User ID and Public-Key packet.
+The issuer of this certification has done substantial
+verification of the claim of identity.
+
+Most OpenPGP implementations make their "key signatures" as 0x10
+certifications. Some implementations can issue 0x11-0x13
+certifications, but few differentiate between the types.
+
+
+
+
+
+
+
cert_revocation
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 48
+
+
+
+
+
0x30: Certification revocation signature
+This signature revokes an earlier User ID certification signature
+(signature class 0x10 through 0x13) or direct-key signature
+(0x1F). It should be issued by the same key that issued the
+revoked signature or an authorized revocation key. The signature
+is computed over the same data as the certificate that it
+revokes, and should have a later creation date than that
+certificate.
+
+
+
+
+
+
+
subkey_binding
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 24
+
+
+
+
+
0x18: Subkey Binding Signature
+This signature is a statement by the top-level signing key that
+indicates that it owns the subkey. This signature is calculated
+directly on the primary key and subkey, and not on any User ID or
+other packets. A signature that binds a signing subkey MUST have
+an Embedded Signature subpacket in this binding signature that
+contains a 0x19 signature made by the signing subkey on the
+primary key and subkey.
+
+
+
+
+
+
+
key_binding
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 25
+
+
+
+
+
0x19: Primary Key Binding Signature
+This signature is a statement by a signing subkey, indicating
+that it is owned by the primary key and subkey. This signature
+is calculated the same way as a 0x18 signature: directly on the
+primary key and subkey, and not on any User ID or other packets.
+
+When a signature is made over a key, the hash data starts with the
+octet 0x99, followed by a two-octet length of the key, and then body
+of the key packet. (Note that this is an old-style packet header for
+a key packet with two-octet length.) A subkey binding signature
+(type 0x18) or primary key binding signature (type 0x19) then hashes
+the subkey using the same format as the main key (also using 0x99 as
+the first octet).
+
+
+
+
+
+
+
key
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 31
+
+
+
+
+
0x1F: Signature directly on a key
+This signature is calculated directly on a key. It binds the
+information in the Signature subpackets to the key, and is
+appropriate to be used for subpackets that provide information
+about the key, such as the Revocation Key subpacket. It is also
+appropriate for statements that non-self certifiers want to make
+about the key itself, rather than the binding between a key and a
+name.
+
+
+
+
+
+
+
key_revocation
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 32
+
+
+
+
+
0x20: Key revocation signature
+The signature is calculated directly on the key being revoked. A
+revoked key is not to be used. Only revocation signatures by the
+key being revoked, or by an authorized revocation key, should be
+considered valid revocation signatures.a
+
+
+
+
+
+
+
subkey_revocation
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 40
+
+
+
+
+
0x28: Subkey revocation signature
+The signature is calculated directly on the subkey being revoked.
+A revoked subkey is not to be used. Only revocation signatures
+by the top-level signature key that is bound to this subkey, or
+by an authorized revocation key, should be considered valid
+revocation signatures.
+
+Key revocation signatures (types 0x20 and 0x28)
+hash only the key being revoked.
+
+
+
+
+
+
+
timestamp
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 64
+
+
+
+
+
0x40: Timestamp signature.
+This signature is only meaningful for the timestamp contained in
+it.
+
+
+
+
+
+
+
third_party
+
+
+
+
+
+Integer
+
+
+
+
+
+
+
+
+
+
+ 80
+
+
+
+
+
0x50: Third-Party Confirmation signature.
+This signature is a signature over some other OpenPGP Signature
+packet(s). It is analogous to a notary seal on the signed data.
+A third-party signature SHOULD include Signature Target
+subpacket(s) to give easy identification. Note that we really do
+mean SHOULD. There are plausible uses for this (such as a blind
+party that only sees the signature, not the key or source
+document) that cannot include a target subpacket.
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/mpi.html b/doc/mpi.html
index 73e12ad5..41e0f435 100644
--- a/doc/mpi.html
+++ b/doc/mpi.html
@@ -36,8 +36,18 @@
+
Implementation of type MPI (RFC4880 3.2)
+
+Multiprecision integers (also called MPIs) are unsigned integers used
+to hold large integers such as the ones used in cryptographic
+calculations.
+An MPI consists of two pieces: a two-octet scalar that is the length
+of the MPI in bits followed by a string of octets that contain the
+actual integer.
diff --git a/doc/mpi.js.html b/doc/mpi.js.html
index 554a983e..05483c27 100644
--- a/doc/mpi.js.html
+++ b/doc/mpi.js.html
@@ -47,20 +47,25 @@
// - MPI size: (a << 8) | b
// - MPI = c | d << 8 | e << ((MPI.length -2)*8) | f ((MPI.length -2)*8)
-/** @module type/mpi */
-
-var BigInteger = require('../crypto/public_key/jsbn.js'),
- util = require('../util');
-
/**
- * @class
- * @classdescImplementation of type MPI (RFC4880 3.2)
+ * Implementation of type MPI (RFC4880 3.2)<br/>
+ * <br/>
* Multiprecision integers (also called MPIs) are unsigned integers used
* to hold large integers such as the ones used in cryptographic
* calculations.
* An MPI consists of two pieces: a two-octet scalar that is the length
* of the MPI in bits followed by a string of octets that contain the
* actual integer.
+ * @requires crypto/public_key/jsbn
+ * @requires util
+ * @module type/mpi
+ */
+
+var BigInteger = require('../crypto/public_key/jsbn.js'),
+ util = require('../util');
+
+/**
+ * @constructor
*/
module.exports = function mpi() {
/** An implementation dependent integer */
@@ -69,11 +74,7 @@ module.exports = function mpi() {
/**
* Parsing function for a mpi (RFC 4880 3.2).
* @param {String} input Payload of mpi data
- * @param {Integer} position Position to start reading from the input
- * string
- * @param {Integer} len Length of the packet or the remaining length of
- * input at position
- * @return {module:type/mpi} Object representation
+ * @return {Integer} Length of data read
*/
this.read = function(bytes) {
var bits = (bytes.charCodeAt(0) << 8) | bytes.charCodeAt(1);
@@ -94,19 +95,19 @@ module.exports = function mpi() {
this.fromBytes(raw);
return 2 + bytelen;
- }
+ };
this.fromBytes = function(bytes) {
this.data = new BigInteger(util.hexstrdump(bytes), 16);
- }
+ };
this.toBytes = function() {
return this.write().substr(2);
- }
+ };
this.byteLength = function() {
return this.toBytes().length;
- }
+ };
/**
* Converts the mpi object to a string as specified in RFC4880 3.2
@@ -114,15 +115,15 @@ module.exports = function mpi() {
*/
this.write = function() {
return this.data.toMPI();
- }
+ };
this.toBigInteger = function() {
return this.data.clone();
- }
+ };
this.fromBigInteger = function(bn) {
this.data = bn.clone();
- }
+ };
}
@@ -134,13 +135,13 @@ module.exports = function mpi() {
diff --git a/doc/one_pass_signature.html b/doc/one_pass_signature.html
index 73556e70..77d877de 100644
--- a/doc/one_pass_signature.html
+++ b/doc/one_pass_signature.html
@@ -36,8 +36,18 @@
+
Implementation of the One-Pass Signature Packets (Tag 4)
+
+RFC4880 5.4:
+The One-Pass Signature packet precedes the signed data and contains
+enough information to allow the receiver to begin calculating any
+hashes needed to verify the signature. It allows the Signature
+packet to be placed at the end of the message, so that the signer
+can compute the entire signed message in one pass.
/**
+ * This class represents a list of openpgp packets.
+ * Take care when iterating over it - the packets themselves
+ * are stored as numerical indices.
+ * @requires enums
+ * @requires packet
+ * @requires packet/packet
+ * @module packet/packetlist
+ */
var packetParser = require('./packet.js'),
packets = require('./all_packets.js'),
enums = require('../enums.js');
/**
- * @class
- * @classdesc This class represents a list of openpgp packets.
- * Take care when iterating over it - the packets themselves
- * are stored as numerical indices.
+ * @constructor
*/
-module.exports = function packetlist() {
+module.exports = packetlist = function () {
/** The number of packets contained within the list.
* @readonly
* @type {Integer} */
@@ -45,7 +50,7 @@ module.exports = function packetlist() {
/**
* Reads a stream of binary data and interprents it as a list of packets.
- * @param {openpgp_byte_array} An array of bytes.
+ * @param {String} A binary string of bytes.
*/
this.read = function(bytes) {
var i = 0;
@@ -66,7 +71,7 @@ module.exports = function packetlist() {
/**
* Creates a binary representation of openpgp objects contained within the
* class instance.
- * @returns {openpgp_byte_array} An array of bytes containing valid openpgp packets.
+ * @returns {String} A binary string of bytes containing valid openpgp packets.
*/
this.write = function() {
var bytes = '';
@@ -207,13 +212,13 @@ module.exports = function packetlist() {
diff --git a/doc/pkcs1.html b/doc/pkcs1.html
index e91f2011..a4887724 100644
--- a/doc/pkcs1.html
+++ b/doc/pkcs1.html
@@ -38,6 +38,8 @@
+
diff --git a/doc/public_key.js.html b/doc/public_key.js.html
index f9952bcd..211bb6f0 100644
--- a/doc/public_key.js.html
+++ b/doc/public_key.js.html
@@ -42,7 +42,20 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/public_key */
+/**
+ * Implementation of the Key Material Packet (Tag 5,6,7,14)<br/>
+ * <br/>
+ * 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 crypto
+ * @requires enums
+ * @requires type/keyid
+ * @requires type/mpi
+ * @requires util
+ * @module packet/public_key
+ */
var util = require('../util'),
type_mpi = require('../type/mpi.js'),
@@ -51,15 +64,9 @@ var util = require('../util'),
crypto = require('../crypto');
/**
- * @class
- * @classdesc Implementation of the Key Material Packet (Tag 5,6,7,14)
- *
- * 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.
+ * @constructor
*/
-module.exports = function packet_public_key() {
+module.exports = function () {
this.version = 4;
/** Key creation date.
* @type {Date} */
@@ -68,7 +75,7 @@ module.exports = function packet_public_key() {
* @type {module:type/mpi} */
this.mpi = [];
/** Public key algorithm
- * @type {openpgp.publickey} */
+ * @type {module:enums.publicKey} */
this.algorithm = 'rsa_sign';
// time in days (V3 only)
this.expirationTimeV3 = 0;
@@ -77,13 +84,11 @@ module.exports = function packet_public_key() {
/**
* Internal Parser for public keys as specified in RFC 4880 section
* 5.5.2 Public-Key Packet Formats
- * called by read_tag<num>
+ * called by read_tag<num>
* @param {String} input Input string to read the packet from
- * @param {Integer} position Start position for the parser
- * @param {Integer} len Length of the packet or remaining length of input
* @return {Object} This object with attributes set by the parser
*/
- this.readPublicKey = this.read = function(bytes) {
+ this.read = function(bytes) {
var pos = 0;
// A one-octet version number (3 or 4).
this.version = bytes.charCodeAt(pos++);
@@ -109,7 +114,7 @@ module.exports = function packet_public_key() {
var bmpi = bytes.substr(pos);
var p = 0;
- for (var i = 0; i < mpicount && p < bmpi.length; i++) {
+ for (var i = 0; i < mpicount && p < bmpi.length; i++) {
this.mpi[i] = new type_mpi();
@@ -124,19 +129,22 @@ module.exports = function packet_public_key() {
} else {
throw new Error('Version ' + version + ' of the key packet is unsupported.');
}
- }
+ };
- /*
+ /**
+ * Alias of read()
+ * @function module:packet/public_key#readPublicKey
+ * @see module:packet/public_key#read
+ */
+ this.readPublicKey = this.read;
+
+ /**
* Same as write_private_key, but has less information because of
* public key.
- * @param {Integer} keyType Follows the OpenPGP algorithm standard,
- * IE 1 corresponds to RSA.
- * @param {RSA.keyObject} key
- * @param timePacket
- * @return {Object} {body: [string]OpenPGP packet body contents,
+ * @return {Object} {body: [string]OpenPGP packet body contents,
* header: [string] OpenPGP packet header, string: [string] header+body}
*/
- this.writePublicKey = this.write = function() {
+ this.write = function() {
// Version
var result = String.fromCharCode(this.version);
result += util.writeDate(this.created);
@@ -152,16 +160,25 @@ module.exports = function packet_public_key() {
}
return result;
- }
+ };
- // Write an old version packet - it's used by some of the internal routines.
+ /**
+ * Alias of write()
+ * @function module:packet/public_key#writePublicKey
+ * @see module:packet/public_key#write
+ */
+ this.writePublicKey = this.write;
+
+ /**
+ * Write an old version packet - it's used by some of the internal routines.
+ */
this.writeOld = function() {
var bytes = this.writePublicKey();
return String.fromCharCode(0x99) +
util.writeNumber(bytes.length, 2) +
bytes;
- }
+ };
/**
* Calculates the key id of the key
@@ -175,7 +192,7 @@ module.exports = function packet_public_key() {
keyid.read(this.mpi[0].write().substr(-8));
}
return keyid;
- }
+ };
/**
* Calculates the fingerprint of the key
@@ -193,9 +210,8 @@ module.exports = function packet_public_key() {
}
return crypto.hash.md5(toHash)
}
- }
-
-}
+ };
+};
@@ -206,13 +222,13 @@ module.exports = function packet_public_key() {
Implementation of the Key Material Packet (Tag 5,6,7,14)
+
+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.
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/public_key_encrypted_session_key.html b/doc/public_key_encrypted_session_key.html
index bed1f62c..229d0198 100644
--- a/doc/public_key_encrypted_session_key.html
+++ b/doc/public_key_encrypted_session_key.html
@@ -36,8 +36,23 @@
+
Public-Key Encrypted Session Key Packets (Tag 1)
+
+RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key
+used to encrypt a message. Zero or more Public-Key Encrypted Session Key
+packets and/or Symmetric-Key Encrypted Session Key packets may precede a
+Symmetrically Encrypted Data Packet, which holds an encrypted message. The
+message is encrypted with the session key, and the session key is itself
+encrypted and stored in the Encrypted Session Key packet(s). The
+Symmetrically Encrypted Data Packet is preceded by one Public-Key Encrypted
+Session Key packet for each OpenPGP key to which the message is encrypted.
+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
+decrypt the message.
+
+
-
new require("packet/public_key_encrypted_session_key")()
+
new (require("packet/public_key_encrypted_session_key"))()
Implementation of the String-to-key specifier (RFC4880 3.7)
+
+String-to-key (S2K) specifiers are used to convert passphrase strings
+into symmetric-key encryption/decryption keys. They are used in two
+places, currently: to encrypt the secret part of private keys in the
+private keyring, and to convert passphrases to encryption keys for
+symmetrically encrypted messages.
diff --git a/doc/s2k.js.html b/doc/s2k.js.html
index b5cffd65..045b5c00 100644
--- a/doc/s2k.js.html
+++ b/doc/s2k.js.html
@@ -42,39 +42,45 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module type/s2k */
+/**
+ * Implementation of the String-to-key specifier (RFC4880 3.7)<br/>
+ * <br/>
+ * String-to-key (S2K) specifiers are used to convert passphrase strings
+ * into symmetric-key encryption/decryption keys. They are used in two
+ * places, currently: to encrypt the secret part of private keys in the
+ * private keyring, and to convert passphrases to encryption keys for
+ * symmetrically encrypted messages.
+ * @requires crypto
+ * @requires enums
+ * @requires util
+ * @module type/s2k
+ */
var enums = require('../enums.js'),
util = require('../util'),
crypto = require('../crypto');
/**
- * @class
- * @classdesc Implementation of the String-to-key specifier (RFC4880 3.7)
- * String-to-key (S2K) specifiers are used to convert passphrase strings
- into symmetric-key encryption/decryption keys. They are used in two
- places, currently: to encrypt the secret part of private keys in the
- private keyring, and to convert passphrases to encryption keys for
- symmetrically encrypted messages.
+ * @constructor
*/
module.exports = function s2k() {
- /** @type {openpgp.hash} */
+ /** @type {module:enums.hash} */
this.algorithm = 'sha256';
- /** @type {module:type/s2k} */
+ /** @type {module:enums.s2k} */
this.type = 'iterated';
this.c = 96;
- /** Eight bytes of salt.
- * @type {openpgp_byte_array}
+ /** Eight bytes of salt in a binary string.
+ * @type {String}
*/
this.salt = crypto.random.getRandomBytes(8);
- // Exponen bias, defined in RFC4880
+ // Exponent bias, defined in RFC4880
var expbias = 6;
this.get_count = function() {
- return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
- }
+ return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
+ };
/**
* Parsing function for a string-to-key specifier (RFC 4880 3.7).
@@ -124,7 +130,7 @@ module.exports = function s2k() {
}
return i;
- }
+ };
/**
@@ -145,10 +151,10 @@ module.exports = function s2k() {
bytes += this.salt;
bytes += String.fromCharCode(this.c);
break;
- };
+ }
return bytes;
- }
+ };
/**
* Produces a key using the specified passphrase and the defined
@@ -185,7 +191,7 @@ module.exports = function s2k() {
isp = isp.substr(0, count);
return crypto.hash.digest(algorithm, prefix + isp);
- };
+ }
}
var result = '',
@@ -197,8 +203,8 @@ module.exports = function s2k() {
}
return result.substr(0, numBytes);
- }
-}
+ };
+};
@@ -209,13 +215,13 @@ module.exports = function s2k() {
diff --git a/doc/scripts/linenumber.js b/doc/scripts/linenumber.js
index 613865d0..a0c570d5 100644
--- a/doc/scripts/linenumber.js
+++ b/doc/scripts/linenumber.js
@@ -9,7 +9,7 @@
numbered = source.innerHTML.split('\n');
numbered = numbered.map(function(item) {
counter++;
- return '' + item;
+ return '' + item;
});
source.innerHTML = numbered.join('\n');
diff --git a/doc/secret_key.html b/doc/secret_key.html
index 3bc9a900..da6797f8 100644
--- a/doc/secret_key.html
+++ b/doc/secret_key.html
@@ -36,8 +36,16 @@
+
Implementation of the Key Material Packet (Tag 5,6,7,14)
+
+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.
Decrypts the private key MPIs which are needed to use the key.
-openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be
-false otherwise
-a call to this function is not needed
diff --git a/doc/secret_key.js.html b/doc/secret_key.js.html
index ba482499..32337674 100644
--- a/doc/secret_key.js.html
+++ b/doc/secret_key.js.html
@@ -42,7 +42,21 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/secret_key */
+/**
+ * Implementation of the Key Material Packet (Tag 5,6,7,14)<br/>
+ * <br/>
+ * 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 crypto
+ * @requires enums
+ * @requires packet/public_key
+ * @requires type/mpi
+ * @requires type/s2k
+ * @requires util
+ * @module packet/secret_key
+ */
var publicKey = require('./public_key.js'),
enums = require('../enums.js'),
@@ -52,14 +66,8 @@ var publicKey = require('./public_key.js'),
type_s2k = require('../type/s2k.js');
/**
- * @class
- * @classdesc Implementation of the Key Material Packet (Tag 5,6,7,14)
+ * @constructor
* @extends module:packet/public_key
- *
- * 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.
*/
module.exports = function () {
publicKey.call(this);
@@ -104,7 +112,7 @@ module.exports = function () {
var j = 0;
var mpi = [];
- for (var i = 0; i < mpis && j < cleartext.length; i++) {
+ for (var i = 0; i < mpis && j < cleartext.length; i++) {
mpi[i] = new type_mpi();
j += mpi[i].read(cleartext.substr(j));
}
@@ -212,9 +220,8 @@ module.exports = function () {
/**
* Decrypts the private key MPIs which are needed to use the key.
- * openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be
- * false otherwise
- * a call to this function is not needed
+ * @link module:packet/secret_key.isDecrypted should be
+ * false otherwise a call to this function is not needed
*
* @param {String} str_passphrase The passphrase for this private key
* as string
@@ -294,13 +301,13 @@ module.exports.prototype = new publicKey();
diff --git a/doc/secret_subkey.html b/doc/secret_subkey.html
index 1d3abde5..d4ca274e 100644
--- a/doc/secret_subkey.html
+++ b/doc/secret_subkey.html
@@ -35,6 +35,72 @@
@@ -565,13 +575,13 @@ integers which is used to sign the data
diff --git a/doc/signature.js.html b/doc/signature.js.html
index 28c1fe17..1feb2ec5 100644
--- a/doc/signature.js.html
+++ b/doc/signature.js.html
@@ -25,7 +25,11 @@
-
/** @module crypto/signature */
+
/**
+ * @requires crypto/hash
+ * @requires crypto/pkcs1
+ * @requires crypto/public_key
+ * @module crypto/signature */
var publicKey = require('./public_key'),
pkcs1 = require('./pkcs1.js'),
@@ -142,13 +146,13 @@ module.exports = {
diff --git a/doc/signature.js_.html b/doc/signature.js_.html
index 578ce06f..7649ed5d 100644
--- a/doc/signature.js_.html
+++ b/doc/signature.js_.html
@@ -42,7 +42,21 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/signature */
+/**
+ * Implementation of the Signature Packet (Tag 2)<br/>
+ * <br/>
+ * RFC4480 5.2:
+ * 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
+ * block of text, and a signature that is a certification of a User ID.
+ * @requires crypto
+ * @requires enums
+ * @requires packet/packet
+ * @requires type/keyid
+ * @requires type/mpi
+ * @requires util
+ * @module packet/signature
+ */
var util = require('../util'),
packet = require('./packet.js'),
@@ -52,15 +66,9 @@ var util = require('../util'),
type_keyid = require('../type/keyid.js');
/**
- * @class
- * @classdesc Implementation of the Signature Packet (Tag 2)
- *
- * RFC4480 5.2:
- * 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
- * block of text, and a signature that is a certification of a User ID.
+ * @constructor
*/
-module.exports = function packet_signature() {
+module.exports = packetSignature = function () {
this.version = 4;
this.signatureType = null;
@@ -121,7 +129,7 @@ module.exports = function packet_signature() {
case 3:
// One-octet length of following hashed material. MUST be 5.
if (bytes.charCodeAt(i++) != 5)
- util.print_debug("openpgp.packet.signature.js\n" +
+ util.print_debug("packet/signature.js\n" +
'invalid One-octet length of following hashed material.' +
'MUST be 5. @:' + (i - 1));
@@ -381,7 +389,7 @@ module.exports = function packet_signature() {
}
// The leftwost bit denotes a "critical" packet, but we ignore it.
- var type = bytes.charCodeAt(mypos++) & 0x7F;
+ var type = bytes.charCodeAt(mypos++) & 0x7F;
// subpacket type
switch (type) {
@@ -518,7 +526,7 @@ module.exports = function packet_signature() {
break;
case 32:
// Embedded Signature
- this.embeddedSignature = new packet_signature();
+ this.embeddedSignature = new packetSignature();
this.embeddedSignature.read(bytes.substr(mypos));
break;
default:
@@ -624,7 +632,7 @@ module.exports = function packet_signature() {
var mpicount = 0;
// Algorithm-Specific Fields for RSA signatures:
// - multiprecision number (MPI) of RSA signature value m**d mod n.
- if (publicKeyAlgorithm > 0 && publicKeyAlgorithm < 4)
+ if (publicKeyAlgorithm > 0 && publicKeyAlgorithm < 4)
mpicount = 1;
// Algorithm-Specific Fields for DSA signatures:
// - MPI of DSA value r.
@@ -667,13 +675,13 @@ module.exports = function packet_signature() {
diff --git a/doc/signature_.html b/doc/signature_.html
index 87ad7583..00466098 100644
--- a/doc/signature_.html
+++ b/doc/signature_.html
@@ -36,8 +36,16 @@
+
Implementation of the Signature Packet (Tag 2)
+
+RFC4480 5.2:
+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
+block of text, and a signature that is a certification of a User ID.
Implementation of the Sym. Encrypted Integrity Protected Data
+Packet (Tag 18)
+
+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.
+
+
-
new require("packet/sym_encrypted_integrity_protected")()
+
new (require("packet/sym_encrypted_integrity_protected"))()
diff --git a/doc/sym_encrypted_integrity_protected.js.html b/doc/sym_encrypted_integrity_protected.js.html
index dd342cff..aac06879 100644
--- a/doc/sym_encrypted_integrity_protected.js.html
+++ b/doc/sym_encrypted_integrity_protected.js.html
@@ -42,24 +42,27 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/sym_encrypted_integrity_protected */
-
-var util = require('../util'),
- crypto = require('../crypto');
-
/**
- * @class
- * @classdesc Implementation of the Sym. Encrypted Integrity Protected Data
- * Packet (Tag 18)
- *
+ * Implementation of the Sym. Encrypted Integrity Protected Data
+ * Packet (Tag 18)<br/>
+ * <br/>
* 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 crypto
+ * @requires util
+ * @module packet/sym_encrypted_integrity_protected
*/
-module.exports = function packet_sym_encrypted_integrity_protected() {
+var util = require('../util'),
+ crypto = require('../crypto');
+
+/**
+ * @constructor
+ */
+module.exports = function () {
/** The encrypted payload. */
this.encrypted = null; // string
/**
@@ -69,12 +72,11 @@ module.exports = function packet_sym_encrypted_integrity_protected() {
* @type {Boolean}
*/
this.modification = false;
- this.packets;
+ this.packets = null;
this.read = function(bytes) {
- // - A one-octet version number. The only currently defined value is
- // 1.
+ // - A one-octet version number. The only currently defined value is 1.
var version = bytes.charCodeAt(0);
if (version != 1) {
@@ -85,13 +87,13 @@ module.exports = function packet_sym_encrypted_integrity_protected() {
// operating in Cipher Feedback mode with shift amount equal to the
// block size of the cipher (CFB-n where n is the block size).
this.encrypted = bytes.substr(1);
- }
+ };
this.write = function() {
return String.fromCharCode(1) // Version
+ this.encrypted;
- }
+ };
this.encrypt = function(sessionKeyAlgorithm, key) {
var bytes = this.packets.write()
@@ -114,7 +116,7 @@ module.exports = function packet_sym_encrypted_integrity_protected() {
this.encrypted = crypto.cfb.encrypt(prefixrandom,
sessionKeyAlgorithm, tohash, key, false).substring(0,
prefix.length + tohash.length);
- }
+ };
/**
* Decrypts the encrypted data contained in this object read_packet must
@@ -142,7 +144,7 @@ module.exports = function packet_sym_encrypted_integrity_protected() {
throw new Error('Modification detected.');
} else
this.packets.read(decrypted.substr(0, decrypted.length - 22));
- }
+ };
};
Public-Key Encrypted Session Key Packets (Tag 1)
+
+RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key
+used to encrypt a message. Zero or more Public-Key Encrypted Session Key
+packets and/or Symmetric-Key Encrypted Session Key packets may precede a
+Symmetrically Encrypted Data Packet, which holds an encrypted message. The
+message is encrypted with the session key, and the session key is itself
+encrypted and stored in the Encrypted Session Key packet(s). The
+Symmetrically Encrypted Data Packet is preceded by one Public-Key Encrypted
+Session Key packet for each OpenPGP key to which the message is encrypted.
+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
+decrypt the message.
+
+
-
new require("packet/sym_encrypted_session_key")()
+
new (require("packet/sym_encrypted_session_key"))()
diff --git a/doc/sym_encrypted_session_key.js.html b/doc/sym_encrypted_session_key.js.html
index fa983e91..e862fe3c 100644
--- a/doc/sym_encrypted_session_key.js.html
+++ b/doc/sym_encrypted_session_key.js.html
@@ -42,16 +42,9 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/sym_encrypted_session_key */
-
-var type_s2k = require('../type/s2k.js'),
- enums = require('../enums.js'),
- crypto = require('../crypto');
-
/**
- * @class
- * @classdesc Public-Key Encrypted Session Key Packets (Tag 1)
- *
+ * Public-Key Encrypted Session Key Packets (Tag 1)<br/>
+ * <br/>
* RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key
* used to encrypt a message. Zero or more Public-Key Encrypted Session Key
* packets and/or Symmetric-Key Encrypted Session Key packets may precede a
@@ -63,8 +56,20 @@ var type_s2k = require('../type/s2k.js'),
* 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
* decrypt the message.
+ * @requires crypto
+ * @requires enums
+ * @requires type/s2k
+ * @module packet/sym_encrypted_session_key
*/
-module.exports = function packet_sym_encrypted_session_key() {
+
+var type_s2k = require('../type/s2k.js'),
+ enums = require('../enums.js'),
+ crypto = require('../crypto');
+
+/**
+ * @constructor
+ */
+module.exports = function () {
this.tag = 3;
this.sessionKeyEncryptionAlgorithm = null;
this.sessionKeyAlgorithm = 'aes256';
@@ -100,7 +105,7 @@ module.exports = function packet_sym_encrypted_session_key() {
this.sessionKeyEncryptionAlgorithm = algo
} else
this.sessionKeyAlgorithm = algo;
- }
+ };
this.write = function() {
var algo = this.encrypted == null ?
@@ -114,7 +119,7 @@ module.exports = function packet_sym_encrypted_session_key() {
if (this.encrypted != null)
bytes += this.encrypted;
return bytes;
- }
+ };
/**
* Decrypts the session key (only for public key encrypted session key
@@ -143,7 +148,7 @@ module.exports = function packet_sym_encrypted_session_key() {
this.sessionKey = decrypted.substr(1);
}
- }
+ };
this.encrypt = function(passphrase) {
var length = crypto.getKeyLength(this.sessionKeyEncryptionAlgorithm);
@@ -158,7 +163,7 @@ module.exports = function packet_sym_encrypted_session_key() {
this.encrypted = crypto.cfb.encrypt(
crypto.getPrefixRandom(this.sessionKeyEncryptionAlgorithm),
this.sessionKeyEncryptionAlgorithm, key, private_key, true);
- }
+ };
};
@@ -170,13 +175,13 @@ module.exports = function packet_sym_encrypted_session_key() {
diff --git a/doc/symmetrically_encrypted.html b/doc/symmetrically_encrypted.html
index 1d0112a8..6dee336e 100644
--- a/doc/symmetrically_encrypted.html
+++ b/doc/symmetrically_encrypted.html
@@ -36,8 +36,17 @@
+
Implementation of the Symmetrically Encrypted Data Packet (Tag 9)
+
+RFC4880 5.7: The Symmetrically Encrypted Data packet contains data encrypted
+with a symmetric-key algorithm. When it has been decrypted, it contains other
+packets (usually a literal data packet or compressed data packet, but in
+theory other Symmetrically Encrypted Data packets or sequences of packets
+that form whole OpenPGP messages).
@@ -105,13 +105,13 @@
diff --git a/doc/twofish.js.html b/doc/twofish.js.html
index d02a9bc7..4dc9ad8d 100644
--- a/doc/twofish.js.html
+++ b/doc/twofish.js.html
@@ -45,7 +45,9 @@
*
*/
-/** @module crypto/cipher/twofish */
+/**
+ * @module crypto/cipher/twofish
+ */
@@ -56,11 +58,11 @@
var MAXINT = 0xFFFFFFFF;
function rotb(b, n) {
- return (b << n | b >>> (8 - n)) & 0xFF;
+ return (b << n | b >>> (8 - n)) & 0xFF;
}
function rotw(w, n) {
- return (w << n | w >>> (32 - n)) & MAXINT;
+ return (w << n | w >>> (32 - n)) & MAXINT;
}
function getW(a, i) {
@@ -68,15 +70,15 @@ function getW(a, i) {
}
function setW(a, i, w) {
- a.splice(i, 4, w & 0xFF, (w >>> 8) & 0xFF, (w >>> 16) & 0xFF, (w >>> 24) & 0xFF);
+ a.splice(i, 4, w & 0xFF, (w >>> 8) & 0xFF, (w >>> 16) & 0xFF, (w >>> 24) & 0xFF);
}
function setWInv(a, i, w) {
- a.splice(i, 4, (w >>> 24) & 0xFF, (w >>> 16) & 0xFF, (w >>> 8) & 0xFF, w & 0xFF);
+ a.splice(i, 4, (w >>> 24) & 0xFF, (w >>> 16) & 0xFF, (w >>> 8) & 0xFF, w & 0xFF);
}
function getB(x, n) {
- return (x >>> (n * 8)) & 0xFF;
+ return (x >>> (n * 8)) & 0xFF;
}
function getNrBits(i) {
@@ -160,26 +162,26 @@ function createTwofish() {
];
function ffm5b(x) {
- return x ^ (x >> 2) ^ [0, 90, 180, 238][x & 3];
+ return x ^ (x >> 2) ^ [0, 90, 180, 238][x & 3];
}
function ffmEf(x) {
- return x ^ (x >> 1) ^ (x >> 2) ^ [0, 238, 180, 90][x & 3];
+ return x ^ (x >> 1) ^ (x >> 2) ^ [0, 238, 180, 90][x & 3];
}
function mdsRem(p, q) {
var i, t, u;
for (i = 0; i < 8; i++) {
t = q >>> 24;
- q = ((q << 8) & MAXINT) | p >>> 24;
- p = (p << 8) & MAXINT;
+ q = ((q << 8) & MAXINT) | p >>> 24;
+ p = (p << 8) & MAXINT;
u = t << 1;
- if (t & 128) {
+ if (t & 128) {
u ^= 333;
}
q ^= t ^ (u << 16);
u ^= t >>> 1;
- if (t & 1) {
+ if (t & 1) {
u ^= 166;
}
q ^= u << 24 | u << 8;
@@ -190,7 +192,7 @@ function createTwofish() {
function qp(n, x) {
var a, b, c, d;
a = x >> 4;
- b = x & 15;
+ b = x & 15;
c = q0[n][a ^ b];
d = q1[n][ror4[b] ^ ashx[a]];
return q3[n][ror4[d] ^ ashx[c]] << 4 | q2[n][c ^ d];
@@ -223,7 +225,7 @@ function createTwofish() {
keyBytes = keyBytes.slice(0, 32);
i = keyBytes.length;
- while (i != 16 && i != 24 && i != 32)
+ while (i != 16 && i != 24 && i != 32)
keyBytes[i++] = 0;
for (i = 0; i < keyBytes.length; i += 4) {
@@ -259,7 +261,7 @@ function createTwofish() {
b = a + 0x1010101;
a = hFun(a, meKey);
b = rotw(hFun(b, moKey), 8);
- tfsKey[i] = (a + b) & MAXINT;
+ tfsKey[i] = (a + b) & MAXINT;
tfsKey[i + 1] = rotw(a + 2 * b, 9);
}
for (i = 0; i < 256; i++) {
@@ -295,23 +297,23 @@ function createTwofish() {
function tfsFrnd(r, blk) {
var a = tfsG0(blk[0]);
var b = tfsG1(blk[1]);
- blk[2] = rotw(blk[2] ^ (a + b + tfsKey[4 * r + 8]) & MAXINT, 31);
- blk[3] = rotw(blk[3], 1) ^ (a + 2 * b + tfsKey[4 * r + 9]) & MAXINT;
+ blk[2] = rotw(blk[2] ^ (a + b + tfsKey[4 * r + 8]) & MAXINT, 31);
+ blk[3] = rotw(blk[3], 1) ^ (a + 2 * b + tfsKey[4 * r + 9]) & MAXINT;
a = tfsG0(blk[2]);
b = tfsG1(blk[3]);
- blk[0] = rotw(blk[0] ^ (a + b + tfsKey[4 * r + 10]) & MAXINT, 31);
- blk[1] = rotw(blk[1], 1) ^ (a + 2 * b + tfsKey[4 * r + 11]) & MAXINT;
+ blk[0] = rotw(blk[0] ^ (a + b + tfsKey[4 * r + 10]) & MAXINT, 31);
+ blk[1] = rotw(blk[1], 1) ^ (a + 2 * b + tfsKey[4 * r + 11]) & MAXINT;
}
function tfsIrnd(i, blk) {
var a = tfsG0(blk[0]);
var b = tfsG1(blk[1]);
- blk[2] = rotw(blk[2], 1) ^ (a + b + tfsKey[4 * i + 10]) & MAXINT;
- blk[3] = rotw(blk[3] ^ (a + 2 * b + tfsKey[4 * i + 11]) & MAXINT, 31);
+ blk[2] = rotw(blk[2], 1) ^ (a + b + tfsKey[4 * i + 10]) & MAXINT;
+ blk[3] = rotw(blk[3] ^ (a + 2 * b + tfsKey[4 * i + 11]) & MAXINT, 31);
a = tfsG0(blk[2]);
b = tfsG1(blk[3]);
- blk[0] = rotw(blk[0], 1) ^ (a + b + tfsKey[4 * i + 8]) & MAXINT;
- blk[1] = rotw(blk[1] ^ (a + 2 * b + tfsKey[4 * i + 9]) & MAXINT, 31);
+ blk[0] = rotw(blk[0], 1) ^ (a + b + tfsKey[4 * i + 8]) & MAXINT;
+ blk[1] = rotw(blk[1] ^ (a + 2 * b + tfsKey[4 * i + 9]) & MAXINT, 31);
}
function tfsClose() {
@@ -415,13 +417,13 @@ module.exports.blockSize = TF.prototype.blockSize = 16;
diff --git a/doc/user_attribute.html b/doc/user_attribute.html
index c099a400..991ada72 100644
--- a/doc/user_attribute.html
+++ b/doc/user_attribute.html
@@ -36,8 +36,26 @@
+
Implementation of the User Attribute Packet (Tag 17)
+
+The User Attribute packet is a variation of the User ID packet. It
+is capable of storing more types of data than the User ID packet,
+which is limited to text. Like the User ID packet, a User Attribute
+packet may be certified by the key owner ("self-signed") or any other
+key owner who cares to certify it. Except as noted, a User Attribute
+packet may be used anywhere that a User ID packet may be used.
+
+While User Attribute packets are not a required part of the OpenPGP
+standard, implementations SHOULD provide at least enough
+compatibility to properly handle a certification signature on 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
+an implementation may use any method desired.
+module packet/user_attribute
diff --git a/doc/user_attribute.js.html b/doc/user_attribute.js.html
index ef800115..96b21b57 100644
--- a/doc/user_attribute.js.html
+++ b/doc/user_attribute.js.html
@@ -42,46 +42,50 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/user_attribute */
-
-/**
- * @class
- * @classdesc Implementation of the User Attribute Packet (Tag 17)
- * The User Attribute packet is a variation of the User ID packet. It
- * is capable of storing more types of data than the User ID packet,
- * which is limited to text. Like the User ID packet, a User Attribute
- * packet may be certified by the key owner ("self-signed") or any other
- * key owner who cares to certify it. Except as noted, a User Attribute
- * packet may be used anywhere that a User ID packet may be used.
- *
- * While User Attribute packets are not a required part of the OpenPGP
- * standard, implementations SHOULD provide at least enough
- * compatibility to properly handle a certification signature on 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
- * an implementation may use any method desired.
+/**
+ * Implementation of the User Attribute Packet (Tag 17)<br/>
+ * <br/>
+ * The User Attribute packet is a variation of the User ID packet. It
+ * is capable of storing more types of data than the User ID packet,
+ * which is limited to text. Like the User ID packet, a User Attribute
+ * packet may be certified by the key owner ("self-signed") or any other
+ * key owner who cares to certify it. Except as noted, a User Attribute
+ * packet may be used anywhere that a User ID packet may be used.
+ * <br/>
+ * While User Attribute packets are not a required part of the OpenPGP
+ * standard, implementations SHOULD provide at least enough
+ * compatibility to properly handle a certification signature on 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
+ * an implementation may use any method desired.
+ * module packet/user_attribute
+ * @module packet/user_attribute
*/
-module.exports = function packet_user_attribute() {
+
+var util = require('../util'),
+ packet = require('./packet.js');
+
+/**
+ * @constructor
+ */
+module.exports = function () {
this.tag = 17;
this.attributes = [];
/**
* parsing function for a user attribute packet (tag 17).
* @param {String} input payload of a tag 17 packet
- * @param {Integer} position position to start reading from the input string
- * @param {Integer} len length of the packet or the remaining length of input at position
- * @return {module:packet/user_attribute} object representation
*/
this.read = function(bytes) {
var i = 0;
while (i < bytes.length) {
- var len = openpgp_packet.read_simple_length(bytes);
-
+ var len = packet.readSimpleLength(bytes.substr(i));
i += len.offset;
+
this.attributes.push(bytes.substr(i, len.len));
i += len.len;
}
- }
+ };
};
@@ -93,13 +97,13 @@ module.exports = function packet_user_attribute() {
diff --git a/doc/userid.html b/doc/userid.html
index dc20c46d..2c44854d 100644
--- a/doc/userid.html
+++ b/doc/userid.html
@@ -36,8 +36,17 @@
+
Implementation of the User ID Packet (Tag 13)
+
+A User ID packet consists of UTF-8 text that is intended to represent
+the name and email address of the key holder. By convention, it
+includes an RFC 2822 [RFC2822] mail name-addr, but there are no
+restrictions on its content. The packet length in the header
+specifies the length of the User ID.
diff --git a/doc/userid.js.html b/doc/userid.js.html
index 92011b23..d2f1f378 100644
--- a/doc/userid.js.html
+++ b/doc/userid.js.html
@@ -42,20 +42,24 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-/** @module packet/userid */
-
-var util = require('../util');
-
/**
- * @class
- * @classdesc Implementation of the User ID Packet (Tag 13)
+ * Implementation of the User ID Packet (Tag 13)<br/>
+ * <br/>
* A User ID packet consists of UTF-8 text that is intended to represent
* the name and email address of the key holder. By convention, it
* includes an RFC 2822 [RFC2822] mail name-addr, but there are no
* 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
+ * @module packet/userid
*/
-module.exports = function packet_userid() {
+
+var util = require('../util');
+
+/**
+ * @constructor
+ */
+module.exports = function () {
/** A string containing the user id. Usually in the form
* John Doe <john@example.com>
* @type {String}
@@ -66,23 +70,18 @@ module.exports = function packet_userid() {
/**
* Parsing function for a user id packet (tag 13).
* @param {String} input payload of a tag 13 packet
- * @param {Integer} position position to start reading from the input string
- * @param {Integer} len length of the packet or the remaining length of input
- * at position
- * @return {module:packet/userid} object representation
*/
- this.read = function(bytes) {
+ this.read = function (bytes) {
this.userid = util.decode_utf8(bytes);
- }
+ };
/**
* Creates a string representation of the user id packet
- * @param {String} user_id the user id as string ("John Doe <john.doe@mail.us")
* @return {String} string representation
*/
- this.write = function() {
+ this.write = function () {
return util.encode_utf8(this.userid);
- }
+ };
}
@@ -94,13 +93,13 @@ module.exports = function packet_userid() {
diff --git a/doc/util-Util.html b/doc/util-Util.html
deleted file mode 100644
index f9c33a54..00000000
--- a/doc/util-Util.html
+++ /dev/null
@@ -1,1878 +0,0 @@
-
-
-
-
- JSDoc: Class: Util
-
-
-
-
-
-
-
-
-
-
-
- Helper function to print a debug message. Debug
-messages are only printed if
-openpgp.config.debug is set to true.
-Different than print_debug because will call hexstrdump iff necessary.
-