From 0c6b345ba88db7b92b23a655adcdb06948e86834 Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Sun, 5 Jan 2014 10:13:25 -0800 Subject: [PATCH 1/3] Refactor classes --- doc/JXG.Util.html | 12 +- doc/aes.html | 4 +- doc/aes.js.html | 10 +- doc/all_packets.js.html | 49 +- doc/armor.html | 4 +- doc/armor.js.html | 22 +- doc/base64.html | 4 +- doc/base64.js.html | 16 +- doc/blowfish.html | 4 +- doc/blowfish.js.html | 8 +- doc/cast5.html | 4 +- doc/cast5.js.html | 26 +- doc/cfb.html | 4 +- doc/cfb.js.html | 49 +- doc/cipher.html | 4 +- doc/cleartext.js.html | 18 +- doc/compressed-Compressed.html | 695 +++++++++ doc/compressed.html | 620 +------- doc/compressed.js.html | 215 ++- doc/config.html | 4 +- doc/config.js.html | 4 +- doc/crypto.html | 12 +- doc/crypto.js.html | 15 +- doc/des.html | 4 +- doc/des.js.html | 14 +- doc/dsa.html | 4 +- doc/dsa.js.html | 106 +- doc/elgamal.html | 4 +- doc/elgamal.js.html | 4 +- doc/enums.js.html | 28 +- doc/hash.html | 4 +- doc/index.html | 19 +- doc/index.js.html | 4 +- doc/index.js_.html | 7 +- doc/index.js__.html | 10 +- doc/index.js___.html | 8 +- doc/index.js____.html | 6 +- doc/jsbn.html | 4 +- doc/jsbn.js.html | 4 +- doc/jxg.js.html | 71 +- doc/key.js.html | 76 +- doc/keyid-Keyid.html | 269 ++++ doc/keyid.html | 206 +-- doc/keyid.js.html | 59 +- doc/keyring-Keyring.html | 1306 +++++++++++++++++ doc/keyring.html | 1235 +--------------- doc/keyring.js.html | 263 ++-- doc/literal-Literal.html | 924 ++++++++++++ doc/literal.html | 861 +---------- doc/literal.js.html | 189 +-- doc/localStorage-LocalStorage.html | 292 ++++ doc/localStorage.html | 229 +-- doc/localStorage.js.html | 50 +- doc/localstore.html | 217 +-- doc/localstore.js.html | 60 +- doc/marker-Marker.html | 338 +++++ doc/marker.html | 275 +--- doc/marker.js.html | 47 +- doc/md5.html | 4 +- doc/md5.js.html | 6 +- doc/message.js.html | 48 +- doc/module-armor.html | 4 +- doc/module-cleartext-CleartextMessage.html | 4 +- doc/module-cleartext.html | 4 +- doc/module-config.html | 4 +- doc/module-crypto.html | 4 +- doc/module-enums.html | 26 +- doc/module-key-Key.html | 40 +- doc/module-key-SubKey.html | 14 +- doc/module-key-User.html | 14 +- doc/module-key.html | 8 +- doc/module-keyid.html | 4 +- doc/module-message-Message.html | 4 +- doc/module-message.html | 4 +- doc/module-mpi.html | 4 +- doc/module-openpgp.html | 4 +- doc/module-packet.html | 36 +- doc/module-s2k.html | 4 +- doc/module-util.html | 4 +- doc/mpi-Mpi.html | 440 ++++++ doc/mpi.html | 365 +---- doc/mpi.js.html | 116 +- doc/one_pass_signature-OnePassSignature.html | 382 +++++ doc/one_pass_signature.html | 319 +--- doc/one_pass_signature.js.html | 90 +- doc/openpgp.js.html | 6 +- doc/packet.html | 12 +- doc/packet.js.html | 24 +- doc/packetlist-Packetlist.html | 1051 +++++++++++++ doc/packetlist.html | 976 +----------- doc/packetlist.js.html | 314 ++-- doc/pkcs1.html | 4 +- doc/pkcs1.js.html | 21 +- doc/public_key-PublicKey.html | 833 +++++++++++ doc/public_key.html | 4 +- doc/public_key.js.html | 243 +-- doc/public_key_.html | 770 +--------- ...sion_key-PublicKeyEncryptedSessionKey.html | 776 ++++++++++ doc/public_key_encrypted_session_key.html | 701 +-------- doc/public_key_encrypted_session_key.js.html | 220 +-- doc/public_subkey-PublicSubkey.html | 320 ++++ doc/public_subkey.html | 956 +----------- doc/public_subkey.js.html | 13 +- doc/random.html | 4 +- doc/random.js.html | 4 +- doc/ripe-md.html | 4 +- doc/ripe-md.js.html | 34 +- doc/rsa.html | 4 +- doc/rsa.js.html | 12 +- doc/s2k-S2k.html | 711 +++++++++ doc/s2k.html | 636 +------- doc/s2k.js.html | 232 +-- doc/secret_key.html | 887 +---------- doc/secret_key.js.html | 435 +++--- doc/secret_subkey-SecretSubkey.html | 320 ++++ doc/secret_subkey.html | 1130 +------------- doc/secret_subkey.js.html | 11 +- doc/sha.html | 4 +- doc/sha.js.html | 18 +- doc/signature-Signature.html | 827 +++++++++++ doc/signature.html | 4 +- doc/signature.js.html | 20 +- doc/signature.js_.html | 1110 +++++++------- doc/signature_.html | 760 +--------- ...tected-SymEncryptedIntegrityProtected.html | 439 ++++++ doc/sym_encrypted_integrity_protected.html | 364 +---- doc/sym_encrypted_integrity_protected.js.html | 129 +- ...ed_session_key-SymEncryptedSessionKey.html | 430 ++++++ doc/sym_encrypted_session_key.html | 367 +---- doc/sym_encrypted_session_key.js.html | 148 +- ...ally_encrypted-SymmetricallyEncrypted.html | 361 +++++ doc/symmetrically_encrypted.html | 286 +--- doc/symmetrically_encrypted.js.html | 58 +- doc/trust-Trust.html | 148 ++ doc/trust.html | 77 +- doc/trust.js.html | 9 +- doc/twofish.html | 4 +- doc/twofish.js.html | 6 +- doc/user_attribute-UserAttribute.html | 269 ++++ doc/user_attribute.html | 206 +-- doc/user_attribute.js.html | 35 +- doc/userid-Userid.html | 429 ++++++ doc/userid.html | 354 +---- doc/userid.js.html | 41 +- doc/util.html | 4 +- doc/util.js.html | 12 +- example/encryption.html | 4 +- src/cleartext.js | 12 +- src/config/localStorage.js | 44 +- src/enums.js | 22 +- src/key.js | 52 +- src/keyring/keyring.js | 299 ++-- src/keyring/localstore.js | 58 +- src/message.js | 34 +- src/packet/all_packets.js | 41 +- src/packet/compressed.js | 225 +-- src/packet/index.js | 2 +- src/packet/literal.js | 183 +-- src/packet/marker.js | 43 +- src/packet/one_pass_signature.js | 92 +- src/packet/packet.js | 1 - src/packet/packetlist.js | 301 ++-- src/packet/public_key.js | 239 +-- .../public_key_encrypted_session_key.js | 228 +-- src/packet/public_subkey.js | 7 +- src/packet/secret_key.js | 377 ++--- src/packet/secret_subkey.js | 9 +- src/packet/signature.js | 1061 ++++++------- .../sym_encrypted_integrity_protected.js | 141 +- src/packet/sym_encrypted_session_key.js | 172 +-- src/packet/symmetrically_encrypted.js | 64 +- src/packet/trust.js | 5 +- src/packet/user_attribute.js | 31 +- src/packet/userid.js | 35 +- src/type/keyid.js | 53 +- src/type/mpi.js | 102 +- src/type/s2k.js | 255 ++-- test/general/key.js | 2 +- test/general/keyring.js | 2 +- test/general/packet.js | 68 +- 180 files changed, 16544 insertions(+), 17263 deletions(-) create mode 100644 doc/compressed-Compressed.html create mode 100644 doc/keyid-Keyid.html create mode 100644 doc/keyring-Keyring.html create mode 100644 doc/literal-Literal.html create mode 100644 doc/localStorage-LocalStorage.html create mode 100644 doc/marker-Marker.html create mode 100644 doc/mpi-Mpi.html create mode 100644 doc/one_pass_signature-OnePassSignature.html create mode 100644 doc/packetlist-Packetlist.html create mode 100644 doc/public_key-PublicKey.html create mode 100644 doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html create mode 100644 doc/public_subkey-PublicSubkey.html create mode 100644 doc/s2k-S2k.html create mode 100644 doc/secret_subkey-SecretSubkey.html create mode 100644 doc/signature-Signature.html create mode 100644 doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html create mode 100644 doc/sym_encrypted_session_key-SymEncryptedSessionKey.html create mode 100644 doc/symmetrically_encrypted-SymmetricallyEncrypted.html create mode 100644 doc/trust-Trust.html create mode 100644 doc/user_attribute-UserAttribute.html create mode 100644 doc/userid-Userid.html diff --git a/doc/JXG.Util.html b/doc/JXG.Util.html index c29632cf..906c6076 100644 --- a/doc/JXG.Util.html +++ b/doc/JXG.Util.html @@ -166,7 +166,7 @@ The code is based on the source code for gunzip.c by Pasi Ojala
Source:
@@ -227,7 +227,7 @@ The code is based on the source code for gunzip.c by Pasi Ojala
Source:
@@ -305,7 +305,7 @@ EXAMPLES:
Source:
@@ -491,7 +491,7 @@ EXAMPLES:
Source:
@@ -554,13 +554,13 @@ EXAMPLES:
diff --git a/doc/aes.html b/doc/aes.html index 90875076..f0e7bad3 100644 --- a/doc/aes.html +++ b/doc/aes.html @@ -111,13 +111,13 @@
diff --git a/doc/aes.js.html b/doc/aes.js.html index 92e89619..c8216446 100644 --- a/doc/aes.js.html +++ b/doc/aes.js.html @@ -520,8 +520,8 @@ function makeClass(length) { this.encrypt = function(block) { return AESencrypt(block, this.key); - } - } + }; + }; c.blockSize = c.prototype.blockSize = 16; c.keySize = c.prototype.keySize = length / 8; @@ -529,7 +529,7 @@ function makeClass(length) { return c; } -module.exports = {} +module.exports = {}; var types = [128, 192, 256]; @@ -546,13 +546,13 @@ for (var i in types) {
diff --git a/doc/all_packets.js.html b/doc/all_packets.js.html index a0e6c3f9..d054963e 100644 --- a/doc/all_packets.js.html +++ b/doc/all_packets.js.html @@ -35,43 +35,50 @@ var enums = require('../enums.js'); module.exports = { /** @see module:packet/compressed */ - compressed: require('./compressed.js'), + Compressed: require('./compressed.js'), /** @see module:packet/sym_encrypted_integrity_protected */ - sym_encrypted_integrity_protected: require('./sym_encrypted_integrity_protected.js'), + SymEncryptedIntegrityProtected: require('./sym_encrypted_integrity_protected.js'), /** @see module:packet/public_key_encrypted_session_key */ - public_key_encrypted_session_key: require('./public_key_encrypted_session_key.js'), + PublicKeyEncryptedSessionKey: require('./public_key_encrypted_session_key.js'), /** @see module:packet/sym_encrypted_session_key */ - sym_encrypted_session_key: require('./sym_encrypted_session_key.js'), + SymEncryptedSessionKey: require('./sym_encrypted_session_key.js'), /** @see module:packet/literal */ - literal: require('./literal.js'), + Literal: require('./literal.js'), /** @see module:packet/public_key */ - public_key: require('./public_key.js'), + PublicKey: require('./public_key.js'), /** @see module:packet/symmetrically_encrypted */ - symmetrically_encrypted: require('./symmetrically_encrypted.js'), + SymmetricallyEncrypted: require('./symmetrically_encrypted.js'), /** @see module:packet/marker */ - marker: require('./marker.js'), + Marker: require('./marker.js'), /** @see module:packet/public_subkey */ - public_subkey: require('./public_subkey.js'), + PublicSubkey: require('./public_subkey.js'), /** @see module:packet/user_attribute */ - user_attribute: require('./user_attribute.js'), + UserAttribute: require('./user_attribute.js'), /** @see module:packet/one_pass_signature */ - one_pass_signature: require('./one_pass_signature.js'), + OnePassSignature: require('./one_pass_signature.js'), /** @see module:packet/secret_key */ - secret_key: require('./secret_key.js'), + SecretKey: require('./secret_key.js'), /** @see module:packet/userid */ - userid: require('./userid.js'), + Userid: require('./userid.js'), /** @see module:packet/secret_subkey */ - secret_subkey: require('./secret_subkey.js'), + SecretSubkey: require('./secret_subkey.js'), /** @see module:packet/signature */ - signature: require('./signature.js'), + Signature: require('./signature.js'), /** @see module:packet/trust */ - trust: require('./trust.js') + Trust: require('./trust.js'), + + newPacketFromTag: function (tag) { + return new this[packetClassFromTag(tag)](); + } +}; + +function packetClassFromTag(tag) { + return tag.substr(0, 1).toUpperCase() + tag.substr(1); } - for (var i in enums.packet) { - var packetClass = module.exports[i]; + var packetClass = module.exports[packetClassFromTag(i)]; - if (packetClass != undefined) + if (packetClass !== undefined) packetClass.prototype.tag = enums.packet[i]; } @@ -84,13 +91,13 @@ for (var i in enums.packet) {
diff --git a/doc/armor.html b/doc/armor.html index 7f68f4be..5b5878f2 100644 --- a/doc/armor.html +++ b/doc/armor.html @@ -1358,13 +1358,13 @@ given base64 encoded checksum
diff --git a/doc/armor.js.html b/doc/armor.js.html index 8b6fc8de..e4437f19 100644 --- a/doc/armor.js.html +++ b/doc/armor.js.html @@ -240,7 +240,7 @@ function splitHeaders(text) { var matchResult = reEmptyLine.exec(text); - if (matchResult != null) { + if (matchResult !== null) { headers = text.slice(0, matchResult.index); body = text.slice(matchResult.index + matchResult[0].length); } @@ -262,7 +262,7 @@ function splitChecksum(text) { var matchResult = reChecksumStart.exec(text); - if (matchResult != null) { + if (matchResult !== null) { body = text.slice(0, matchResult.index); checksum = text.slice(matchResult.index + 1); } @@ -295,14 +295,14 @@ function dearmor(text) { // so we know the index of the data we are interested in. var indexBase = 1; - var result, checksum; + var result, checksum, msg; if (text.search(reSplit) != splittext[0].length) { indexBase = 0; } if (type != 2) { - var msg = splitHeaders(splittext[indexBase]); + msg = splitHeaders(splittext[indexBase]); var msg_sum = splitChecksum(msg.body); result = { @@ -313,7 +313,7 @@ function dearmor(text) { checksum = msg_sum.checksum; } else { // Reverse dash-escaping for msg and remove trailing whitespace at end of line - var msg = splitHeaders(splittext[indexBase].replace(/^- /mg, '').replace(/[\t ]+\n/g, "\n")); + msg = splitHeaders(splittext[indexBase].replace(/^- /mg, '').replace(/[\t ]+\n/g, "\n")); var sig = splitHeaders(splittext[indexBase + 1].replace(/^- /mg, '')); var sig_sum = splitChecksum(sig.body); @@ -327,10 +327,10 @@ function dearmor(text) { } if (!verifyCheckSum(result.data, checksum)) { - throw new Error("Ascii armor integrity check on message failed: '" - + checksum - + "' should be '" - + getCheckSum(result) + "'"); + throw new Error("Ascii armor integrity check on message failed: '" + + checksum + + "' should be '" + + getCheckSum(result) + "'"); } else { return result; } @@ -413,13 +413,13 @@ module.exports = {
diff --git a/doc/base64.html b/doc/base64.html index d2cd492d..5f76ecb4 100644 --- a/doc/base64.html +++ b/doc/base64.html @@ -387,13 +387,13 @@
diff --git a/doc/base64.js.html b/doc/base64.js.html index 0442407f..0d7369c8 100644 --- a/doc/base64.js.html +++ b/doc/base64.js.html @@ -59,7 +59,7 @@ function s2r(t) { for (n = 0; n < tl; n++) { c = t.charCodeAt(n); - if (s == 0) { + if (s === 0) { r += b64s.charAt((c >> 2) & 63); a = (c & 3) << 4; } else if (s == 1) { @@ -68,12 +68,12 @@ function s2r(t) { } else if (s == 2) { r += b64s.charAt(a | ((c >> 6) & 3)); l += 1; - if ((l % 60) == 0) + if ((l % 60) === 0) r += "\n"; r += b64s.charAt(c & 63); } l += 1; - if ((l % 60) == 0) + if ((l % 60) === 0) r += "\n"; s += 1; @@ -83,13 +83,13 @@ function s2r(t) { if (s > 0) { r += b64s.charAt(a); l += 1; - if ((l % 60) == 0) + if ((l % 60) === 0) r += "\n"; r += '='; l += 1; } if (s == 1) { - if ((l % 60) == 0) + if ((l % 60) === 0) r += "\n"; r += '='; } @@ -125,7 +125,7 @@ function r2s(t) { module.exports = { encode: s2r, decode: r2s -} +}; @@ -136,13 +136,13 @@ module.exports = {
diff --git a/doc/blowfish.html b/doc/blowfish.html index b311cbff..49fab594 100644 --- a/doc/blowfish.html +++ b/doc/blowfish.html @@ -105,13 +105,13 @@
diff --git a/doc/blowfish.js.html b/doc/blowfish.js.html index 8fb76d56..f5483eda 100644 --- a/doc/blowfish.js.html +++ b/doc/blowfish.js.html @@ -41,7 +41,7 @@ * The constructor doesn't do much of anything. It's just here * so we can start defining properties and methods and such. */ -function Blowfish() {}; +function Blowfish() {} /* * Declare the block size so that protocols know what size @@ -434,7 +434,7 @@ function BF(key) { this.encrypt = function(block) { return this.bf.encrypt_block(block); - } + }; } @@ -451,13 +451,13 @@ module.exports.blockSize = BF.prototype.blockSize = 16;
diff --git a/doc/cast5.html b/doc/cast5.html index 3089499d..3c1cdff0 100644 --- a/doc/cast5.html +++ b/doc/cast5.html @@ -105,13 +105,13 @@
diff --git a/doc/cast5.js.html b/doc/cast5.js.html index 8651ba82..63f41963 100644 --- a/doc/cast5.js.html +++ b/doc/cast5.js.html @@ -279,19 +279,22 @@ function openpgp_symenc_cast5() { var t = new Array(8); var k = new Array(32); - for (var i = 0; i < 4; i++) { - var j = i * 4; + var i, j; + + for (i = 0; i < 4; i++) { + j = i * 4; t[i] = inn[j] << 24 | inn[j + 1] << 16 | inn[j + 2] << 8 | inn[j + 3]; } var x = [6, 7, 4, 5]; var ki = 0; + var w; for (var half = 0; half < 2; half++) { for (var round = 0; round < 4; round++) { - for (var j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { var a = scheduleA[round][j]; - var w = t[a[1]]; + w = t[a[1]]; w ^= sBox[4][(t[a[2] >>> 2] >>> (24 - 8 * (a[2] & 3))) & 0xff]; w ^= sBox[5][(t[a[3] >>> 2] >>> (24 - 8 * (a[3] & 3))) & 0xff]; @@ -301,9 +304,9 @@ function openpgp_symenc_cast5() { t[a[0]] = w; } - for (var j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { var b = scheduleB[round][j]; - var w = sBox[4][(t[b[0] >>> 2] >>> (24 - 8 * (b[0] & 3))) & 0xff]; + w = sBox[4][(t[b[0] >>> 2] >>> (24 - 8 * (b[0] & 3))) & 0xff]; w ^= sBox[5][(t[b[1] >>> 2] >>> (24 - 8 * (b[1] & 3))) & 0xff]; w ^= sBox[6][(t[b[2] >>> 2] >>> (24 - 8 * (b[2] & 3))) & 0xff]; @@ -315,7 +318,7 @@ function openpgp_symenc_cast5() { } } - for (var i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { this.masking[i] = k[i]; this.rotate[i] = k[16 + i] & 0x1f; } @@ -614,8 +617,7 @@ function openpgp_symenc_cast5() { 0xe97625a5, 0x0614d1b7, 0x0e25244b, 0x0c768347, 0x589e8d82, 0x0d2059d1, 0xa466bb1e, 0xf8da0a82, 0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xeaee6801, 0x8db2a283, 0xea8bf59e); -}; - +} var util = require('../../util'); function cast5(key) { @@ -624,7 +626,7 @@ function cast5(key) { this.encrypt = function(block) { return this.cast5.encrypt(block); - } + }; } module.exports = cast5; @@ -640,13 +642,13 @@ module.exports.keySize = cast5.prototype.keySize = 16;
diff --git a/doc/cfb.html b/doc/cfb.html index c860d141..bfb6c6de 100644 --- a/doc/cfb.html +++ b/doc/cfb.html @@ -762,13 +762,13 @@ This will be passed to the cipherfn
diff --git a/doc/cfb.js.html b/doc/cfb.js.html index 189c1415..b015f56a 100644 --- a/doc/cfb.js.html +++ b/doc/cfb.js.html @@ -79,8 +79,9 @@ module.exports = { prefixrandom = prefixrandom + prefixrandom.charAt(block_size - 2) + prefixrandom.charAt(block_size - 1); util.print_debug("prefixrandom:" + util.hexstrdump(prefixrandom)); var ciphertext = ""; + var i; // 1. The feedback register (FR) is set to the IV, which is all zeros. - for (var i = 0; i < block_size; i++) FR[i] = 0; + for (i = 0; i < block_size; i++) FR[i] = 0; // 2. FR is encrypted to produce FRE (FR Encrypted). This is the // encryption of an all-zero value. @@ -88,13 +89,13 @@ module.exports = { // 3. FRE is xored with the first BS octets of random data prefixed to // the plaintext to produce C[1] through C[BS], the first BS octets // of ciphertext. - for (var i = 0; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ prefixrandom.charCodeAt(i)); + for (i = 0; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ prefixrandom.charCodeAt(i)); // 4. FR is loaded with C[1] through C[BS]. - for (var i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i); + for (i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i); // 5. FR is encrypted to produce FRE, the encryption of the first BS - // octets of ciphertext. + // octets of ciphertext. FRE = cipherfn.encrypt(FR); // 6. The left two octets of FRE get xored with the next two octets of @@ -105,22 +106,22 @@ module.exports = { if (resync) { // 7. (The resync step) FR is loaded with C3-C10. - for (var i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i + 2); + for (i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i + 2); } else { - for (var i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i); + for (i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i); } // 8. FR is encrypted to produce FRE. FRE = cipherfn.encrypt(FR, key); if (resync) { // 9. FRE is xored with the first 8 octets of the given plaintext, now - // that we have finished encrypting the 10 octets of prefixed data. - // This produces C11-C18, the next 8 octets of ciphertext. - for (var i = 0; i < block_size; i++) + // that we have finished encrypting the 10 octets of prefixed data. + // This produces C11-C18, the next 8 octets of ciphertext. + for (i = 0; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(i)); for (n = block_size + 2; n < plaintext.length; n += block_size) { // 10. FR is loaded with C11-C18 - for (var i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(n + i); + for (i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(n + i); // 11. FR is encrypted to produce FRE. FRE = cipherfn.encrypt(FR); @@ -128,20 +129,20 @@ module.exports = { // 12. FRE is xored with the next 8 octets of plaintext, to produce the // next 8 octets of ciphertext. These are loaded into FR and the // process is repeated until the plaintext is used up. - for (var i = 0; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt((n - 2) + + for (i = 0; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt((n - 2) + i)); } } else { plaintext = " " + plaintext; // 9. FRE is xored with the first 8 octets of the given plaintext, now - // that we have finished encrypting the 10 octets of prefixed data. - // This produces C11-C18, the next 8 octets of ciphertext. - for (var i = 2; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(i)); + // that we have finished encrypting the 10 octets of prefixed data. + // This produces C11-C18, the next 8 octets of ciphertext. + for (i = 2; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(i)); var tempCiphertext = ciphertext.substring(0, 2 * block_size).split(''); var tempCiphertextString = ciphertext.substring(block_size); for (n = block_size; n < plaintext.length; n += block_size) { // 10. FR is loaded with C11-C18 - for (var i = 0; i < block_size; i++) FR[i] = tempCiphertextString.charCodeAt(i); + for (i = 0; i < block_size; i++) FR[i] = tempCiphertextString.charCodeAt(i); tempCiphertextString = ''; // 11. FR is encrypted to produce FRE. @@ -150,13 +151,12 @@ module.exports = { // 12. FRE is xored with the next 8 octets of plaintext, to produce the // next 8 octets of ciphertext. These are loaded into FR and the // process is repeated until the plaintext is used up. - for (var i = 0; i < block_size; i++) { + for (i = 0; i < block_size; i++) { tempCiphertext.push(String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(n + i))); tempCiphertextString += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(n + i)); } } ciphertext = tempCiphertext.join(''); - } ciphertext = ciphertext.substring(0, plaintext.length + 2 + block_size); @@ -266,7 +266,7 @@ module.exports = { } } - var n = resync ? 0 : 2; + n = resync ? 0 : 2; text = text.join(''); @@ -308,14 +308,15 @@ module.exports = { var pos = 0; var plaintext = []; var offset = 0; - if (iv == null) - for (var i = 0; i < block_size; i++) blockp += String.fromCharCode(0); + var i; + if (iv === null) + for (i = 0; i < block_size; i++) blockp += String.fromCharCode(0); else blockp = iv.substring(0, block_size); while (ciphertext.length > (block_size * pos)) { var decblock = cipherfn.encrypt(util.str2bin(blockp)); blockp = ciphertext.substring((pos * (block_size)) + offset, (pos * (block_size)) + (block_size) + offset); - for (var i = 0; i < blockp.length; i++) { + for (i = 0; i < blockp.length; i++) { plaintext.push(String.fromCharCode(blockp.charCodeAt(i) ^ decblock[i])); } pos++; @@ -323,7 +324,7 @@ module.exports = { return plaintext.join(''); } -} +}; @@ -334,13 +335,13 @@ module.exports = {
diff --git a/doc/cipher.html b/doc/cipher.html index 2bfea5bf..7a127c6f 100644 --- a/doc/cipher.html +++ b/doc/cipher.html @@ -406,13 +406,13 @@
diff --git a/doc/cleartext.js.html b/doc/cleartext.js.html index 8af1a8ef..c1d7289b 100644 --- a/doc/cleartext.js.html +++ b/doc/cleartext.js.html @@ -70,7 +70,7 @@ function CleartextMessage(text, packetlist) { } // normalize EOL to canonical form <CR><LF> this.text = text.replace(/\r/g, '').replace(/[\t ]+\n/g, "\n").replace(/\n/g,"\r\n"); - this.packets = packetlist || new packet.list(); + this.packets = packetlist || new packet.List(); } /** @@ -91,11 +91,11 @@ CleartextMessage.prototype.getSigningKeyIds = function() { * @param {Array<module:key~Key>} privateKeys private keys with decrypted secret key data for signing */ CleartextMessage.prototype.sign = function(privateKeys) { - var packetlist = new packet.list(); - var literalDataPacket = new packet.literal(); + var packetlist = new packet.List(); + var literalDataPacket = new packet.Literal(); literalDataPacket.setText(this.text); for (var i = 0; i < privateKeys.length; i++) { - var signaturePacket = new packet.signature(); + var signaturePacket = new packet.Signature(); signaturePacket.signatureType = enums.signature.text; signaturePacket.hashAlgorithm = config.prefer_hash_algorithm; var signingKeyPacket = privateKeys[i].getSigningKeyPacket(); @@ -115,7 +115,7 @@ CleartextMessage.prototype.sign = function(privateKeys) { CleartextMessage.prototype.verify = function(publicKeys) { var result = []; var signatureList = this.packets.filterByTag(enums.packet.signature); - var literalDataPacket = new packet.literal(); + var literalDataPacket = new packet.Literal(); // we assume that cleartext signature is generated based on UTF8 cleartext literalDataPacket.setText(this.text); publicKeys.forEach(function(pubKey) { @@ -151,7 +151,7 @@ CleartextMessage.prototype.armor = function() { hash: enums.read(enums.hash, config.prefer_hash_algorithm).toUpperCase(), text: this.text, data: this.packets.write() - } + }; return armor.encode(enums.armor.signed, body); }; @@ -167,7 +167,7 @@ function readArmored(armoredText) { if (input.type !== enums.armor.signed) { throw new Error('No cleartext signed message.'); } - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.read(input.data); var newMessage = new CleartextMessage(input.text, packetlist); return newMessage; @@ -185,13 +185,13 @@ exports.readArmored = readArmored;
diff --git a/doc/compressed-Compressed.html b/doc/compressed-Compressed.html new file mode 100644 index 00000000..3034d7d3 --- /dev/null +++ b/doc/compressed-Compressed.html @@ -0,0 +1,695 @@ + + + + + JSDoc: Class: Compressed + + + + + + + + + + +
+ +

Class: Compressed

+ + + + + +
+ +
+

+ packet/compressed~ + + Compressed +

+ +
+ +
+
+ + + + +
+

new Compressed()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

algorithm :compression

+ + +
+
+ +
+ Compression algorithm +
+ + + +
Type:
+
    +
  • + +compression + + +
  • +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ + + +
+

compressed :String

+ + +
+
+ +
+ Compressed packet data +
+ + + +
Type:
+
    +
  • + +String + + +
  • +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ + + +
+

packets :module:packet/packetlist

+ + +
+
+ +
+ List of packets +
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

compress()

+ + +
+
+ + +
+ Compress the packet data (member decompressedData) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

decompress()

+ + +
+
+ + +
+ Decompression method for decompressing the compressed data +read by read_packet +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

read(bytes)

+ + +
+
+ + +
+ Parsing function for the packet. +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
bytes + + +String + + + + Payload of a tag 8 packet
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

write() → {String}

+ + +
+
+ + +
+ Return the compressed packet. +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ binary compressed packet +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/compressed.html b/doc/compressed.html index 9f58e225..c3001e3f 100644 --- a/doc/compressed.html +++ b/doc/compressed.html @@ -35,6 +35,8 @@
+ +
Implementation of the Compressed Data Packet (Tag 8)

@@ -43,74 +45,6 @@ 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.
-
-

new (require("packet/compressed"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -167,559 +101,19 @@ a Signature or One-Pass Signature packet, and contains a literal data packet.Members +

Classes

- -
-

algorithm :compression

- - -
-
- -
- Compression algorithm -
- - - -
Type:
-
    -
  • - -compression - - -
  • -
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

compressed :String

- - -
-
- -
- Compressed packet data -
- - - -
Type:
-
    -
  • - -String - - -
  • -
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

packets :module:packet/packetlist

- - -
-
- -
- List of packets -
- - - -
Type:
- - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
Compressed
+
-

Methods

- -
- -
-

compress()

-
-
-
- Compress the packet data (member decompressedData) -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

decompress()

- - -
-
- - -
- Decompression method for decompressing the compressed data -read by read_packet -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

read(bytes)

- - -
-
- - -
- Parsing function for the packet. -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
bytes - - -String - - - - Payload of a tag 8 packet
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

write() → {String}

- - -
-
- - -
- Return the compressed packet. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- binary compressed packet -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- -
- @@ -734,13 +128,13 @@ read by read_packet

- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:43 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST)
diff --git a/doc/compressed.js.html b/doc/compressed.js.html index b60c43ca..3937d5b7 100644 --- a/doc/compressed.js.html +++ b/doc/compressed.js.html @@ -54,6 +54,8 @@ * @module packet/compressed */ +module.exports = Compressed; + var enums = require('../enums.js'), JXG = require('../compression/jxg.js'), base64 = require('../encoding/base64.js'); @@ -61,7 +63,7 @@ var enums = require('../enums.js'), /** * @constructor */ -module.exports = function compressed() { +function Compressed() { /** * List of packets * @type {module:packet/packetlist} @@ -78,125 +80,118 @@ module.exports = function compressed() { * @type {String} */ this.compressed = null; +} + +/** + * Parsing function for the packet. + * @param {String} bytes Payload of a tag 8 packet + */ +Compressed.prototype.read = function (bytes) { + // One octet that gives the algorithm used to compress the packet. + this.algorithm = enums.read(enums.compression, bytes.charCodeAt(0)); + + // Compressed data, which makes up the remainder of the packet. + this.compressed = bytes.substr(1); + + this.decompress(); +}; - /** - * Parsing function for the packet. - * @param {String} bytes Payload of a tag 8 packet - */ - this.read = function(bytes) { - // One octet that gives the algorithm used to compress the packet. - this.algorithm = enums.read(enums.compression, bytes.charCodeAt(0)); - // Compressed data, which makes up the remainder of the packet. - this.compressed = bytes.substr(1); +/** + * Return the compressed packet. + * @return {String} binary compressed packet + */ +Compressed.prototype.write = function () { + if (this.compressed === null) + this.compress(); - this.decompress(); + return String.fromCharCode(enums.write(enums.compression, this.algorithm)) + this.compressed; +}; + + +/** + * Decompression method for decompressing the compressed data + * read by read_packet + */ +Compressed.prototype.decompress = function () { + var decompressed, compdata, radix; + + switch (this.algorithm) { + case 'uncompressed': + decompressed = this.compressed; + break; + + case 'zip': + compData = this.compressed; + + radix = base64.encode(compData).replace(/\n/g, ""); + // no header in this case, directly call deflate + var jxg_obj = new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(radix)); + + decompressed = unescape(jxg_obj.deflate()[0][0]); + break; + + case 'zlib': + //RFC 1950. Bits 0-3 Compression Method + var compressionMethod = this.compressed.charCodeAt(0) % 0x10; + + //Bits 4-7 RFC 1950 are LZ77 Window. Generally this value is 7 == 32k window size. + // 2nd Byte in RFC 1950 is for "FLAGs" Allows for a Dictionary + // (how is this defined). Basic checksum, and compression level. + + if (compressionMethod == 8) { //CM 8 is for DEFLATE, RFC 1951 + // remove 4 bytes ADLER32 checksum from the end + compData = this.compressed.substring(0, this.compressed.length - 4); + radix = base64.encode(compData).replace(/\n/g, ""); + //TODO check ADLER32 checksum + decompressed = JXG.decompress(radix); + break; + + } else { + throw new Error("Compression algorithm ZLIB only supports " + + "DEFLATE compression method."); + } + break; + + case 'bzip2': + // TODO: need to implement this + throw new Error('Compression algorithm BZip2 [BZ2] is not implemented.'); + + default: + throw new Error("Compression algorithm unknown :" + this.alogrithm); } + this.packets.read(decompressed); +}; +/** + * Compress the packet data (member decompressedData) + */ +Compressed.prototype.compress = function () { + switch (this.algorithm) { - /** - * Return the compressed packet. - * @return {String} binary compressed packet - */ - this.write = function() { - if (this.compressed == null) - this.compress(); + case 'uncompressed': + // - Uncompressed + this.compressed = this.packets.write(); + break; - return String.fromCharCode(enums.write(enums.compression, this.algorithm)) + this.compressed; - } + case 'zip': + // - ZIP [RFC1951] + throw new Error("Compression algorithm ZIP [RFC1951] is not implemented."); + case 'zlib': + // - ZLIB [RFC1950] + // TODO: need to implement this + throw new Error("Compression algorithm ZLIB [RFC1950] is not implemented."); - /** - * Decompression method for decompressing the compressed data - * read by read_packet - */ - this.decompress = function() { - var decompressed; + case 'bzip2': + // - BZip2 [BZ2] + // TODO: need to implement this + throw new Error("Compression algorithm BZip2 [BZ2] is not implemented."); - switch (this.algorithm) { - case 'uncompressed': - decompressed = this.compressed; - break; - - case 'zip': - var compData = this.compressed; - - var radix = base64.encode(compData).replace(/\n/g, ""); - // no header in this case, directly call deflate - var jxg_obj = new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(radix)); - - decompressed = unescape(jxg_obj.deflate()[0][0]); - break; - - case 'zlib': - //RFC 1950. Bits 0-3 Compression Method - var compressionMethod = this.compressed.charCodeAt(0) % 0x10; - - //Bits 4-7 RFC 1950 are LZ77 Window. Generally this value is 7 == 32k window size. - // 2nd Byte in RFC 1950 is for "FLAGs" Allows for a Dictionary - // (how is this defined). Basic checksum, and compression level. - - if (compressionMethod == 8) { //CM 8 is for DEFLATE, RFC 1951 - // remove 4 bytes ADLER32 checksum from the end - var compData = this.compressed.substring(0, this.compressed.length - 4); - var radix = base64.encode(compData).replace(/\n/g, ""); - //TODO check ADLER32 checksum - decompressed = JXG.decompress(radix); - break; - - } else { - throw new Error("Compression algorithm ZLIB only supports " + - "DEFLATE compression method."); - } - break; - - case 'bzip2': - // TODO: need to implement this - throw new Error('Compression algorithm BZip2 [BZ2] is not implemented.'); - break; - - default: - throw new Error("Compression algorithm unknown :" + this.alogrithm); - break; - } - - this.packets.read(decompressed); - } - - /** - * Compress the packet data (member decompressedData) - */ - this.compress = function() { - switch (this.algorithm) { - - case 'uncompressed': - // - Uncompressed - this.compressed = this.packets.write(); - break; - - case 'zip': - // - ZIP [RFC1951] - throw new Error("Compression algorithm ZIP [RFC1951] is not implemented."); - break; - - case 'zlib': - // - ZLIB [RFC1950] - // TODO: need to implement this - throw new Error("Compression algorithm ZLIB [RFC1950] is not implemented."); - break; - - case 'bzip2': - // - BZip2 [BZ2] - // TODO: need to implement this - throw new Error("Compression algorithm BZip2 [BZ2] is not implemented."); - break; - - default: - throw new Error("Compression algorithm unknown :" + this.type); - break; - } + default: + throw new Error("Compression algorithm unknown :" + this.type); } }; @@ -209,13 +204,13 @@ module.exports = function compressed() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/config.html b/doc/config.html index 7469c56d..fc43ecf1 100644 --- a/doc/config.html +++ b/doc/config.html @@ -325,13 +325,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:40 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/config.js.html b/doc/config.js.html index b7499701..f23d5772 100644 --- a/doc/config.js.html +++ b/doc/config.js.html @@ -82,13 +82,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/crypto.html b/doc/crypto.html index 16d37a92..0dd34c94 100644 --- a/doc/crypto.html +++ b/doc/crypto.html @@ -197,7 +197,7 @@
Source:
@@ -336,7 +336,7 @@
Source:
@@ -476,7 +476,7 @@ size of the cipher
Source:
@@ -687,7 +687,7 @@ of the private key used
Source:
@@ -937,13 +937,13 @@ if elgamal encryption an array of two module:type/mpi is returned; otherwise nul
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:40 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST)
diff --git a/doc/crypto.js.html b/doc/crypto.js.html index 14d2a0d0..8f39f1f5 100644 --- a/doc/crypto.js.html +++ b/doc/crypto.js.html @@ -69,13 +69,14 @@ module.exports = { */ publicKeyEncrypt: function(algo, publicMPIs, data) { var result = (function() { + var m; switch (algo) { case 'rsa_encrypt': case 'rsa_encrypt_sign': var rsa = new publicKey.rsa(); var n = publicMPIs[0].toBigInteger(); var e = publicMPIs[1].toBigInteger(); - var m = data.toBigInteger(); + m = data.toBigInteger(); return [rsa.encrypt(m, e, n)]; case 'elgamal': @@ -83,7 +84,7 @@ module.exports = { var p = publicMPIs[0].toBigInteger(); var g = publicMPIs[1].toBigInteger(); var y = publicMPIs[2].toBigInteger(); - var m = data.toBigInteger(); + m = data.toBigInteger(); return elgamal.encrypt(m, g, p, y); default: @@ -111,6 +112,8 @@ module.exports = { */ publicKeyDecrypt: function(algo, keyIntegers, dataIntegers) { + var p; + var bn = (function() { switch (algo) { case 'rsa_encrypt_sign': @@ -118,7 +121,7 @@ module.exports = { var rsa = new publicKey.rsa(); // 0 and 1 are the public key. var d = keyIntegers[2].toBigInteger(); - var p = keyIntegers[3].toBigInteger(); + p = keyIntegers[3].toBigInteger(); var q = keyIntegers[4].toBigInteger(); var u = keyIntegers[5].toBigInteger(); var m = dataIntegers[0].toBigInteger(); @@ -128,7 +131,7 @@ module.exports = { var x = keyIntegers[3].toBigInteger(); var c1 = dataIntegers[0].toBigInteger(); var c2 = dataIntegers[1].toBigInteger(); - var p = keyIntegers[0].toBigInteger(); + p = keyIntegers[0].toBigInteger(); return elgamal.decrypt(c1, c2, p, x); default: return null; @@ -258,13 +261,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/des.html b/doc/des.html index 0d832eaf..a8dc29a7 100644 --- a/doc/des.html +++ b/doc/des.html @@ -209,13 +209,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:40 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST)
diff --git a/doc/des.js.html b/doc/des.js.html index 3ace6958..92b0d2a0 100644 --- a/doc/des.js.html +++ b/doc/des.js.html @@ -108,7 +108,7 @@ function des(keys, message, encrypt, mode, iv, padding) { //create the 16 or 48 subkeys we will need var m = 0, i, j, temp, temp2, right1, right2, left, right, looping; - var cbcleft, cbcleft2, cbcright, cbcright2 + var cbcleft, cbcleft2, cbcright, cbcright2; var endloop, loopinc; var len = message.length; var chunk = 0; @@ -405,7 +405,7 @@ function Des(key) { des(des_createKeys(this.key[0]), util.bin2str(block), true, 0, null, null), false, 0, null, null), true, 0, null, null)); - } + }; } Des.keySize = Des.prototype.keySize = 24; @@ -420,12 +420,12 @@ function OriginalDes(key) { this.encrypt = function(block, padding) { var keys = des_createKeys(this.key); return util.str2bin(des(keys, util.bin2str(block), true, 0, null, padding)); - } + }; this.decrypt = function(block, padding) { var keys = des_createKeys(this.key); return util.str2bin(des(keys, util.bin2str(block), false, 0, null, padding)); - } + }; } module.exports = { @@ -433,7 +433,7 @@ module.exports = { des: Des, /** @static */ originalDes: OriginalDes -} +};
@@ -444,13 +444,13 @@ module.exports = {
diff --git a/doc/dsa.html b/doc/dsa.html index 80815f6e..864d5d86 100644 --- a/doc/dsa.html +++ b/doc/dsa.html @@ -117,13 +117,13 @@
diff --git a/doc/dsa.js.html b/doc/dsa.js.html index b0f0fab1..f86d494e 100644 --- a/doc/dsa.js.html +++ b/doc/dsa.js.html @@ -72,7 +72,7 @@ function DSA() { var k = random.getRandomBigIntegerInRange(BigInteger.ONE.add(BigInteger.ONE), q.subtract(BigInteger.ONE)); var s1 = (g.modPow(k, p)).mod(q); var s2 = (k.modInverse(q).multiply(hash.add(x.multiply(s1)))).mod(q); - var result = new Array(); + var result = []; result[0] = s1.toMPI(); result[1] = s2.toMPI(); return result; @@ -135,61 +135,61 @@ function DSA() { * unused code. This can be used as a start to write a key generator * function. - function generateKey(bitcount) { - var qi = new BigInteger(bitcount, primeCenterie); - var pi = generateP(q, 512); - var gi = generateG(p, q, bitcount); - var xi; - do { - xi = new BigInteger(q.bitCount(), rand); - } while (x.compareTo(BigInteger.ZERO) != 1 && x.compareTo(q) != -1); - var yi = g.modPow(x, p); - return {x: xi, q: qi, p: pi, g: gi, y: yi}; - } + function generateKey(bitcount) { + var qi = new BigInteger(bitcount, primeCenterie); + var pi = generateP(q, 512); + var gi = generateG(p, q, bitcount); + var xi; + do { + xi = new BigInteger(q.bitCount(), rand); + } while (x.compareTo(BigInteger.ZERO) != 1 && x.compareTo(q) != -1); + var yi = g.modPow(x, p); + return {x: xi, q: qi, p: pi, g: gi, y: yi}; + } - function generateP(q, bitlength, randomfn) { - if (bitlength % 64 != 0) { - return false; - } - var pTemp; - var pTemp2; - do { - pTemp = randomfn(bitcount, true); - pTemp2 = pTemp.subtract(BigInteger.ONE); - pTemp = pTemp.subtract(pTemp2.remainder(q)); - } while (!pTemp.isProbablePrime(primeCenterie) || pTemp.bitLength() != l); - return pTemp; - } + function generateP(q, bitlength, randomfn) { + if (bitlength % 64 != 0) { + return false; + } + var pTemp; + var pTemp2; + do { + pTemp = randomfn(bitcount, true); + pTemp2 = pTemp.subtract(BigInteger.ONE); + pTemp = pTemp.subtract(pTemp2.remainder(q)); + } while (!pTemp.isProbablePrime(primeCenterie) || pTemp.bitLength() != l); + return pTemp; + } - function generateG(p, q, bitlength, randomfn) { - var aux = p.subtract(BigInteger.ONE); - var pow = aux.divide(q); - var gTemp; - do { - gTemp = randomfn(bitlength); - } while (gTemp.compareTo(aux) != -1 && gTemp.compareTo(BigInteger.ONE) != 1); - return gTemp.modPow(pow, p); - } + function generateG(p, q, bitlength, randomfn) { + var aux = p.subtract(BigInteger.ONE); + var pow = aux.divide(q); + var gTemp; + do { + gTemp = randomfn(bitlength); + } while (gTemp.compareTo(aux) != -1 && gTemp.compareTo(BigInteger.ONE) != 1); + return gTemp.modPow(pow, p); + } - function generateK(q, bitlength, randomfn) { - var tempK; - do { - tempK = randomfn(bitlength, false); - } while (tempK.compareTo(q) != -1 && tempK.compareTo(BigInteger.ZERO) != 1); - return tempK; - } + function generateK(q, bitlength, randomfn) { + var tempK; + do { + tempK = randomfn(bitlength, false); + } while (tempK.compareTo(q) != -1 && tempK.compareTo(BigInteger.ZERO) != 1); + return tempK; + } - function generateR(q,p) { - k = generateK(q); - var r = g.modPow(k, p).mod(q); - return r; - } + function generateR(q,p) { + k = generateK(q); + var r = g.modPow(k, p).mod(q); + return r; + } - function generateS(hashfn,k,r,m,q,x) { - var hash = hashfn(m); - s = (k.modInverse(q).multiply(hash.add(x.multiply(r)))).mod(q); - return s; - } */ + function generateS(hashfn,k,r,m,q,x) { + var hash = hashfn(m); + s = (k.modInverse(q).multiply(hash.add(x.multiply(r)))).mod(q); + return s; + } */ this.sign = sign; this.verify = verify; // this.generate = generateKey; @@ -206,13 +206,13 @@ module.exports = DSA;
diff --git a/doc/elgamal.html b/doc/elgamal.html index 4a80def7..205c25a3 100644 --- a/doc/elgamal.html +++ b/doc/elgamal.html @@ -115,13 +115,13 @@
diff --git a/doc/elgamal.js.html b/doc/elgamal.js.html index bad86554..17564971 100644 --- a/doc/elgamal.js.html +++ b/doc/elgamal.js.html @@ -95,13 +95,13 @@ module.exports = Elgamal;
diff --git a/doc/enums.js.html b/doc/enums.js.html index e6bd811b..85bcaea4 100644 --- a/doc/enums.js.html +++ b/doc/enums.js.html @@ -103,23 +103,23 @@ module.exports = { * @readonly */ packet: { - public_key_encrypted_session_key: 1, + publicKeyEncryptedSessionKey: 1, signature: 2, - sym_encrypted_session_key: 3, - one_pass_signature: 4, - secret_key: 5, - public_key: 6, - secret_subkey: 7, + symEncryptedSessionKey: 3, + onePassSignature: 4, + secretKey: 5, + publicKey: 6, + secretSubkey: 7, compressed: 8, - symmetrically_encrypted: 9, + symmetricallyEncrypted: 9, marker: 10, literal: 11, trust: 12, userid: 13, - public_subkey: 14, - user_attribute: 17, - sym_encrypted_integrity_protected: 18, - modification_detection_code: 19 + publicSubkey: 14, + userAttribute: 17, + symEncryptedIntegrityProtected: 18, + modificationDetectionCode: 19 }, /** Data types in the literal packet @@ -341,7 +341,7 @@ module.exports = { throw new Error('Invalid enum value.'); } -} +}; @@ -352,13 +352,13 @@ module.exports = {
diff --git a/doc/hash.html b/doc/hash.html index da528cab..43db4644 100644 --- a/doc/hash.html +++ b/doc/hash.html @@ -819,13 +819,13 @@
diff --git a/doc/index.html b/doc/index.html index 35a9596f..d4bad455 100644 --- a/doc/index.html +++ b/doc/index.html @@ -41,15 +41,19 @@
-

[Build Status

- -

What is OpenPGP.js?

+

OpenPGP.js [![Build Status](https://secure.travis-ci.org/openpgpjs/openpgpjs.png?branch=master,v0.1.x)](http://travis-ci.org/openpgpjs/openpgpjs)

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.

+

To build the library, checkout the HEAD of the master branch or download a stable (old) tagged version from releases.

+ +

Then build the library:

+ +
npm install && grunt
+ +

Then take the use the minified file from resources/openpgp.min.js and use it in your project.

I need some help

@@ -63,7 +67,8 @@

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.

+

You want to help, great! Go ahead and fork our repo, make your changes +and make a pull request.

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.

@@ -175,13 +180,13 @@ for extending and developing on top of the base library.
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/index.js.html b/doc/index.js.html index 902d6691..707293a9 100644 --- a/doc/index.js.html +++ b/doc/index.js.html @@ -74,13 +74,13 @@ module.exports.crypto = require('./crypto');
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/index.js_.html b/doc/index.js_.html index 55766af2..46f490ff 100644 --- a/doc/index.js_.html +++ b/doc/index.js_.html @@ -44,8 +44,7 @@ module.exports = { random: require('./random.js'), /** @see module:crypto/pkcs1 */ pkcs1: require('./pkcs1.js') - -} +}; var crypto = require('./crypto.js'); @@ -61,13 +60,13 @@ for (var i in crypto)
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/index.js__.html b/doc/index.js__.html index c302f9d9..0eca47b5 100644 --- a/doc/index.js__.html +++ b/doc/index.js__.html @@ -37,16 +37,16 @@ var desModule = require('./des.js'); module.exports = { /** @see module:crypto/cipher/des.des */ - des: desModule['des'], + des: desModule.des, /** @see module:crypto/cipher/des.originalDes */ - originalDes: desModule['originalDes'], + originalDes: desModule.originalDes, /** @see module:crypto/cipher/cast5 */ cast5: require('./cast5.js'), /** @see module:crypto/cipher/twofish */ twofish: require('./twofish.js'), /** @see module:crypto/cipher/blowfish */ blowfish: require('./blowfish.js') -} +}; var aes = require('./aes.js'); @@ -63,13 +63,13 @@ for (var i in aes) {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/index.js___.html b/doc/index.js___.html index f622a880..628ec272 100644 --- a/doc/index.js___.html +++ b/doc/index.js___.html @@ -101,7 +101,7 @@ module.exports = { return 32; case 9: // - SHA384 [FIPS180] - return 48 + return 48; case 10: // - SHA512 [FIPS180] return 64; @@ -112,7 +112,7 @@ module.exports = { throw new Error('Invalid hash algorithm.'); } } -} +};
@@ -123,13 +123,13 @@ module.exports = {
diff --git a/doc/index.js____.html b/doc/index.js____.html index 05e4110b..8127b5a5 100644 --- a/doc/index.js____.html +++ b/doc/index.js____.html @@ -38,7 +38,7 @@ module.exports = { elgamal: require('./elgamal.js'), /** @see module:crypto/public_key/dsa */ dsa: require('./dsa.js') -} +}; @@ -49,13 +49,13 @@ module.exports = {
diff --git a/doc/jsbn.html b/doc/jsbn.html index b38910fa..ddd108a3 100644 --- a/doc/jsbn.html +++ b/doc/jsbn.html @@ -111,13 +111,13 @@
diff --git a/doc/jsbn.js.html b/doc/jsbn.js.html index 01fd1900..ac948d90 100644 --- a/doc/jsbn.js.html +++ b/doc/jsbn.js.html @@ -1745,13 +1745,13 @@ BigInteger.prototype.square = bnSquare;
diff --git a/doc/jxg.js.html b/doc/jxg.js.html index 54b8047b..506b0840 100644 --- a/doc/jxg.js.html +++ b/doc/jxg.js.html @@ -29,7 +29,7 @@ exists: (function(undefined) { return function(v) { return !(v === undefined || v === null); - } + }; })() }; JXG.decompress = function(str) { @@ -169,24 +169,24 @@ JXG.Util.Unzip = function(barray) { return bA[bytepos++]; } else return -1; - }; + } function byteAlign() { bb = 1; - }; + } function readBit() { var carry; bits++; carry = (bb & 1); bb >>= 1; - if (bb == 0) { + if (bb === 0) { bb = readByte(); carry = (bb & 1); bb = (bb >> 1) | 0x80; } return carry; - }; + } function readBits(a) { var res = 0, @@ -199,12 +199,12 @@ JXG.Util.Unzip = function(barray) { res = bitReverse[res] >> (8 - a); } return res; - }; + } function flushBuffer() { //document.write('FLUSHBUFFER:'+buf32k); bIdx = 0; - }; + } function addBuffer(a) { SIZE++; @@ -216,14 +216,14 @@ JXG.Util.Unzip = function(barray) { //document.write('ADDBUFFER:'+buf32k); bIdx = 0; } - }; + } function HufNode() { this.b0 = 0; this.b1 = 0; this.jump = null; this.jumppos = -1; - }; + } var LITERALS = 288; @@ -250,7 +250,7 @@ JXG.Util.Unzip = function(barray) { return fpos[len]++; fpos[len]++; } - }; + } function Rec() { var curplace = Places[treepos]; @@ -296,7 +296,7 @@ JXG.Util.Unzip = function(barray) { } len--; return 0; - }; + } function CreateTree(currentTree, numval, lengths, show) { var i; @@ -341,7 +341,7 @@ JXG.Util.Unzip = function(barray) { } }*/ return 0; - }; + } function DecodeValue(currentTree) { var len, i, @@ -380,10 +380,10 @@ JXG.Util.Unzip = function(barray) { X = currentTree[xtreepos]; } } - }; + } function DeflateLoop() { - var last, c, type, i, len; + var last, c, type, i, j, len, dist; do { /*if((last = readBit())){ @@ -416,7 +416,7 @@ JXG.Util.Unzip = function(barray) { break; } - if (type == 0) { + if (type === 0) { var blockLen, cSum; // Stored @@ -435,8 +435,6 @@ JXG.Util.Unzip = function(barray) { addBuffer(c); } } else if (type == 1) { - var j; - /* Fixed Huffman tables -- fixed decode routine */ while (1) { /* @@ -481,8 +479,6 @@ JXG.Util.Unzip = function(barray) { /* EOF */ break; } else { - var len, dist; - j -= 256 + 1; /* bytes + EOF */ len = readBits(cplext[j]) + cplens[j]; @@ -497,13 +493,13 @@ 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]; + c = buf32k[(bIdx - dist) & 0x7fff]; addBuffer(c); } } } // while } else if (type == 2) { - var j, n, literalCodes, distCodes, lenCodes; + var n, literalCodes, distCodes, lenCodes; var ll = new Array(288 + 32); // "static" just to preserve stack // Dynamic Huffman tables @@ -538,8 +534,8 @@ JXG.Util.Unzip = function(barray) { document.write("<br>" + distanceTree[a].b0 + " " + distanceTree[a].b1 + " " + distanceTree[a].jump + " " + distanceTree[a].jumppos); /*if (distanceTree[a].jumppos!=-1) - document.write(" "+distanceTree[a].jump.b0+" "+distanceTree[a].jump.b1); - */ + document.write(" "+distanceTree[a].jump.b0+" "+distanceTree[a].jump.b1); + */ } } //document.write('<BR>tree created'); @@ -600,7 +596,7 @@ JXG.Util.Unzip = function(barray) { len = literalTree.length; for (i = 0; i < len; i++) distanceTree[i] = new HufNode(); - var ll2 = new Array(); + var ll2 = []; for (i = literalCodes; i < ll.length; i++) { ll2[i - literalCodes] = ll[i]; } @@ -613,9 +609,8 @@ JXG.Util.Unzip = function(barray) { outer: while (1) { j = DecodeValue(literalTree); if (j >= 256) { // In C64: if carry set - var len, dist; j -= 256; - if (j == 0) { + if (j === 0) { // EOF break; } @@ -634,7 +629,7 @@ JXG.Util.Unzip = function(barray) { if (bIdx - dist < 0) { break outer; } - var c = buf32k[(bIdx - dist) & 0x7fff]; + c = buf32k[(bIdx - dist) & 0x7fff]; addBuffer(c); } } else { @@ -647,7 +642,7 @@ JXG.Util.Unzip = function(barray) { byteAlign(); return 0; - }; + } JXG.Util.Unzip.prototype.unzipFile = function(name) { var i; @@ -658,7 +653,6 @@ JXG.Util.Unzip = function(barray) { return unzipped[i][0]; } } - }; JXG.Util.Unzip.prototype.deflate = function() { @@ -673,7 +667,7 @@ JXG.Util.Unzip = function(barray) { unzipped[files][1] = "DEFLATE"; files++; return unzipped; - } + }; JXG.Util.Unzip.prototype.unzip = function() { //convertToByteArray(input); @@ -798,8 +792,9 @@ JXG.Util.Unzip = function(barray) { alert("filelen " + filelen); i = 0; nameBuf = []; + var c; while (filelen--) { - var c = readByte(); + c = readByte(); if (c == "/" | c == ":") { i = 0; } else if (i < NAMEMAX - 1) @@ -821,7 +816,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"); @@ -839,7 +834,7 @@ JXG.Util.Unzip = function(barray) { skipdir(); } } - }; + } function skipdir() { var crc, @@ -952,7 +947,7 @@ JXG.Util.Unzip = function(barray) { if (modeZIP) nextFile(); - }; + } }; @@ -1096,7 +1091,7 @@ JXG.Util.Base64 = { lineno, i, destripped = []; - if (wrap == null) + if (wrap === null) wrap = 76; stripped.replace(/ /g, ""); @@ -1251,7 +1246,7 @@ JXG.Util.utf8Decode = function(utftext) { string.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63))); i += 3; } - }; + } return string.join(''); }; @@ -1302,13 +1297,13 @@ module.exports = JXG;
diff --git a/doc/key.js.html b/doc/key.js.html index 300d7691..7c458875 100644 --- a/doc/key.js.html +++ b/doc/key.js.html @@ -86,19 +86,19 @@ Key.prototype.packetlist2structure = function(packetlist) { var user, primaryKeyId, subKey; for (var i = 0; i < packetlist.length; i++) { switch (packetlist[i].tag) { - case enums.packet.public_key: - case enums.packet.secret_key: + case enums.packet.publicKey: + case enums.packet.secretKey: this.primaryKey = packetlist[i]; primaryKeyId = this.primaryKey.getKeyId(); break; case enums.packet.userid: - case enums.packet.user_attribute: + case enums.packet.userAttribute: user = new User(packetlist[i]); if (!this.users) this.users = []; this.users.push(user); break; - case enums.packet.public_subkey: - case enums.packet.secret_subkey: + case enums.packet.publicSubkey: + case enums.packet.secretSubkey: user = null; if (!this.subKeys) this.subKeys = []; subKey = new SubKey(packetlist[i]); @@ -151,15 +151,16 @@ Key.prototype.packetlist2structure = function(packetlist) { * @return {module:packet/packetlist} The packets that form a key */ Key.prototype.toPacketlist = function() { - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.push(this.primaryKey); packetlist.push(this.revocationSignature); packetlist.concat(this.directSignatures); - for (var i = 0; i < this.users.length; i++) { + var i; + for (i = 0; i < this.users.length; i++) { packetlist.concat(this.users[i].toPacketlist()); } if (this.subKeys) { - for (var i = 0; i < this.subKeys.length; i++) { + for (i = 0; i < this.subKeys.length; i++) { packetlist.concat(this.subKeys[i].toPacketlist()); } } @@ -227,7 +228,7 @@ function findKey(keys, keyIds) { * @return {(module:packet/public_subkey|module:packet/public_key|null)} */ Key.prototype.getPublicKeyPacket = function(keyIds) { - if (this.primaryKey.tag == enums.packet.public_key) { + if (this.primaryKey.tag == enums.packet.publicKey) { return findKey(this.getAllKeyPackets(), keyIds); } else { return null; @@ -240,7 +241,7 @@ Key.prototype.getPublicKeyPacket = function(keyIds) { * @return {(module:packet/secret_subkey|module:packet/secret_key|null)} */ Key.prototype.getPrivateKeyPacket = function(keyIds) { - if (this.primaryKey.tag == enums.packet.secret_key) { + if (this.primaryKey.tag == enums.packet.secretKey) { return findKey(this.getAllKeyPackets(), keyIds); } else { return null; @@ -266,7 +267,7 @@ Key.prototype.getUserIds = function() { * @return {Boolean} */ Key.prototype.isPublic = function() { - return this.primaryKey.tag == enums.packet.public_key; + return this.primaryKey.tag == enums.packet.publicKey; }; /** @@ -274,7 +275,7 @@ Key.prototype.isPublic = function() { * @return {Boolean} */ Key.prototype.isPrivate = function() { - return this.primaryKey.tag == enums.packet.secret_key; + return this.primaryKey.tag == enums.packet.secretKey; }; /** @@ -282,19 +283,20 @@ Key.prototype.isPrivate = function() { * @return {module:key~Key} new public Key */ Key.prototype.toPublic = function() { - var packetlist = new packet.list(); + var packetlist = new packet.List(); var keyPackets = this.toPacketlist(); + var bytes; for (var i = 0; i < keyPackets.length; i++) { switch (keyPackets[i].tag) { - case enums.packet.secret_key: - var bytes = keyPackets[i].writePublicKey(); - var pubKeyPacket = new packet.public_key(); + case enums.packet.secretKey: + bytes = keyPackets[i].writePublicKey(); + var pubKeyPacket = new packet.PublicKey(); pubKeyPacket.read(bytes); packetlist.push(pubKeyPacket); break; - case enums.packet.secret_subkey: - var bytes = keyPackets[i].writePublicKey(); - var pubSubkeyPacket = new packet.public_subkey(); + case enums.packet.secretSubkey: + bytes = keyPackets[i].writePublicKey(); + var pubSubkeyPacket = new packet.PublicSubkey(); pubSubkeyPacket.read(bytes); packetlist.push(pubSubkeyPacket); break; @@ -355,7 +357,7 @@ function isValidEncryptionKeyPacket(keyPacket, signature) { ((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) || @@ -363,7 +365,7 @@ function isValidSigningKeyPacket(keyPacket, signature) { keyPacket.algorithm == enums.read(enums.publicKey, enums.publicKey.rsa_encrypt_sign)) && ((signature.keyFlags & enums.keyFlags.sign_data) !== 0 || !signature.keyFlags); -}; +} /** * Returns the first valid encryption key packet for this key @@ -496,7 +498,7 @@ Key.prototype.getPrimaryUser = function() { } } return user ? {user: user, selfCertificate: userSelfCert} : null; -} +}; // TODO Key.prototype.revoke = function() { @@ -512,7 +514,7 @@ function User(userPacket) { return new User(userPacket); } this.userId = userPacket.tag == enums.packet.userid ? userPacket : null; - this.userAttribute = userPacket.tag == enums.packet.user_attribute ? userPacket : null + this.userAttribute = userPacket.tag == enums.packet.userAttribute ? userPacket : null; this.selfCertifications = null; this.otherCertifications = null; this.revocationCertifications = null; @@ -523,7 +525,7 @@ function User(userPacket) { * @return {module:packet/packetlist} */ User.prototype.toPacketlist = function() { - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.push(this.userId || this.userAttribute); packetlist.concat(this.revocationCertifications); packetlist.concat(this.selfCertifications); @@ -629,7 +631,7 @@ function SubKey(subKeyPacket) { * @return {module:packet/packetlist} */ SubKey.prototype.toPacketlist = function() { - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.push(this.subKey); packetlist.push(this.revocationSignature); packetlist.push(this.bindingSignature); @@ -707,11 +709,11 @@ function readArmored(armoredText) { if (!(input.type == enums.armor.public_key || input.type == enums.armor.private_key)) { throw new Error('Armored text not of type key'); } - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.read(input.data); - var keyIndex = packetlist.indexOfTag(enums.packet.public_key, enums.packet.secret_key); - if (keyIndex.length == 0) { - throw new Error('No key packet found in armored text') + var keyIndex = packetlist.indexOfTag(enums.packet.publicKey, enums.packet.secretKey); + if (keyIndex.length === 0) { + throw new Error('No key packet found in armored text'); } for (var i = 0; i < keyIndex.length; i++) { var oneKeyList = packetlist.slice(keyIndex[i], keyIndex[i + 1]); @@ -742,20 +744,20 @@ function readArmored(armoredText) { * @static */ function generate(keyType, numBits, userId, passphrase) { - var packetlist = new packet.list(); + var packetlist = new packet.List(); - var secretKeyPacket = new packet.secret_key(); + var secretKeyPacket = new packet.SecretKey(); secretKeyPacket.algorithm = enums.read(enums.publicKey, keyType); secretKeyPacket.generate(numBits); secretKeyPacket.encrypt(passphrase); - var userIdPacket = new packet.userid(); + var userIdPacket = new packet.Userid(); userIdPacket.read(userId); var dataToSign = {}; dataToSign.userid = userIdPacket; dataToSign.key = secretKeyPacket; - var signaturePacket = new packet.signature(); + var signaturePacket = new packet.Signature(); signaturePacket.signatureType = enums.signature.cert_generic; signaturePacket.publicKeyAlgorithm = keyType; //TODO we should load preferred hash from config, or as input to this function @@ -763,7 +765,7 @@ function generate(keyType, numBits, userId, passphrase) { signaturePacket.keyFlags = [enums.keyFlags.certify_keys | enums.keyFlags.sign_data]; signaturePacket.sign(secretKeyPacket, dataToSign); - var secretSubkeyPacket = new packet.secret_subkey(); + var secretSubkeyPacket = new packet.SecretSubkey(); secretSubkeyPacket.algorithm = enums.read(enums.publicKey, keyType); secretSubkeyPacket.generate(numBits); secretSubkeyPacket.encrypt(passphrase); @@ -771,7 +773,7 @@ function generate(keyType, numBits, userId, passphrase) { dataToSign = {}; dataToSign.key = secretKeyPacket; dataToSign.bind = secretSubkeyPacket; - var subkeySignaturePacket = new packet.signature(); + var subkeySignaturePacket = new packet.Signature(); subkeySignaturePacket.signatureType = enums.signature.subkey_binding; subkeySignaturePacket.publicKeyAlgorithm = keyType; //TODO we should load preferred hash from config, or as input to this function @@ -801,13 +803,13 @@ exports.generate = generate;
diff --git a/doc/keyid-Keyid.html b/doc/keyid-Keyid.html new file mode 100644 index 00000000..807fb94c --- /dev/null +++ b/doc/keyid-Keyid.html @@ -0,0 +1,269 @@ + + + + + JSDoc: Class: Keyid + + + + + + + + + + +
+ +

Class: Keyid

+ + + + + +
+ +
+

+ type/keyid~ + + Keyid +

+ +
+ +
+
+ + + + +
+

new Keyid()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

read(input)

+ + +
+
+ + +
+ Parsing method for a key id +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Input to read the key id from
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/keyid.html b/doc/keyid.html index 4f6d1b15..7f979f8a 100644 --- a/doc/keyid.html +++ b/doc/keyid.html @@ -35,6 +35,8 @@
+ +
Implementation of type key id (RFC4880 3.3)

@@ -44,74 +46,6 @@ section "Enhanced Key Formats" below describes how Key IDs are formed.
-
-

new (require("type/keyid"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -164,137 +98,23 @@ formed.
- - - - - - -

Methods

+

Classes

- -
-

read(input)

- - -
-
- - -
- Parsing method for a key id -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Input to read the key id from
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- +
Keyid
+
+ + + + + +
@@ -305,13 +125,13 @@ formed.
diff --git a/doc/keyid.js.html b/doc/keyid.js.html index 8cf723c1..713e2d17 100644 --- a/doc/keyid.js.html +++ b/doc/keyid.js.html @@ -53,44 +53,45 @@ * @module type/keyid */ +module.exports = Keyid; + var util = require('../util'); /** * @constructor */ -module.exports = function keyid() { +function Keyid() { this.bytes = ''; +} - - /** - * Parsing method for a key id - * @param {String} input Input to read the key id from - */ - this.read = function(bytes) { - this.bytes = bytes.substr(0, 8); - }; - - this.write = function() { - return this.bytes; - }; - - this.toHex = function() { - return util.hexstrdump(this.bytes); - }; - - this.equals = function(keyid) { - return this.bytes == keyid.bytes; - }; - - this.isNull = function() { - return this.bytes === ''; - }; +/** + * Parsing method for a key id + * @param {String} input Input to read the key id from + */ +Keyid.prototype.read = function(bytes) { + this.bytes = bytes.substr(0, 8); }; -module.exports.mapToHex = function(keyId) { +Keyid.prototype.write = function() { + return this.bytes; +}; + +Keyid.prototype.toHex = function() { + return util.hexstrdump(this.bytes); +}; + +Keyid.prototype.equals = function(keyid) { + return this.bytes == keyid.bytes; +}; + +Keyid.prototype.isNull = function() { + return this.bytes === ''; +}; + +module.exports.mapToHex = function (keyId) { return keyId.toHex(); -} +}; @@ -101,13 +102,13 @@ module.exports.mapToHex = function(keyId) {
diff --git a/doc/keyring-Keyring.html b/doc/keyring-Keyring.html new file mode 100644 index 00000000..2e54ebf2 --- /dev/null +++ b/doc/keyring-Keyring.html @@ -0,0 +1,1306 @@ + + + + + JSDoc: Class: Keyring + + + + + + + + + + +
+ +

Class: Keyring

+ + + + + +
+ +
+

+ keyring/keyring~ + + Keyring +

+ +
+ +
+
+ + + + +
+

new Keyring(storeHandler)

+ + +
+
+ + +
+ Initialization routine for the keyring. This method reads the +keyring from HTML5 local storage and initializes this instance. +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDescription
storeHandler + + +class + + + + + + <optional>
+ + + + + +
class implementing load() and store() methods
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

clear()

+ + +
+
+ + +
+ Clear the keyring - erase all the keys +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

exportKey(index) → {String}

+ + +
+
+ + +
+ returns the armored message representation of the key at key ring index +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
index + + +Integer + + + + the index of the key within the array
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ armored message representing the key object +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

exportPublicKey(index) → {String}

+ + +
+
+ + +
+ returns the armored message representation of the public key portion of the key at key ring index +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
index + + +Integer + + + + the index of the key within the array
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ armored message representing the public key object +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

getKeysForKeyId(keyId) → {Array.<module:key~Key>}

+ + +
+
+ + +
+ Searches the keyring for public keys having the specified key id +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
keyId + + +String + + + + provided as string of hex number (lowercase)
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ public keys found +
+ + + +
+
+ Type +
+
+ +Array.<module:key~Key> + + +
+
+ + + + +
+ + + +
+

getPrivateKeyForAddress(email) → {Array.<module:key~Key>}

+ + +
+
+ + +
+ Searches the keyring for a private key containing the specified email address +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +String + + + + email address to search for
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ private keys found +
+ + + +
+
+ Type +
+
+ +Array.<module:key~Key> + + +
+
+ + + + +
+ + + +
+

getPublicKeyForAddress(email) → {Array.<module:key~Key>}

+ + +
+
+ + +
+ searches all public keys in the keyring matching the address or address part of the user ids +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +String + + + + email address to search for
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ The public keys associated with provided email address. +
+ + + +
+
+ Type +
+
+ +Array.<module:key~Key> + + +
+
+ + + + +
+ + + +
+

importKey(armored)

+ + +
+
+ + +
+ Imports a key from an ascii armored message +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
armored + + +String + + + + message to read the keys/key from
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

removeKey(index) → {module:key~Key}

+ + +
+
+ + +
+ Removes a public key from the public key keyring at the specified index +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
index + + +Integer + + + + the index of the public key within the publicKeys array
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ The public key object which has been removed +
+ + + +
+
+ Type +
+
+ +module:key~Key + + +
+
+ + + + +
+ + + +
+

store()

+ + +
+
+ + +
+ Calls the storeHandler to save the keys +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/keyring.html b/doc/keyring.html index 561bada9..064036f6 100644 --- a/doc/keyring.html +++ b/doc/keyring.html @@ -35,143 +35,12 @@
+ +
The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
-
-

new (require("keyring/keyring"))(storeHandler)

- - -
-
- - -
- Initialization routine for the keyring. This method reads the -keyring from HTML5 local storage and initializes this instance. -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
storeHandler - - -class - - - - - - <optional>
- - - - - -
class implementing load() and store() methods
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -224,6 +93,13 @@ keyring from HTML5 local storage and initializes this instance. +

Classes

+ +
+
Keyring
+
+
+ @@ -234,1095 +110,6 @@ keyring from HTML5 local storage and initializes this instance.
-
-

clear()

- - -
-
- - -
- Clear the keyring - erase all the keys -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

exportKey(index) → {String}

- - -
-
- - -
- returns the armored message representation of the key at key ring index -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
index - - -Integer - - - - the index of the key within the array
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- armored message representing the key object -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

exportPublicKey(index) → {String}

- - -
-
- - -
- returns the armored message representation of the public key portion of the key at key ring index -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
index - - -Integer - - - - the index of the key within the array
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- armored message representing the public key object -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

getKeysForKeyId(keyId) → {Array.<module:key~Key>}

- - -
-
- - -
- Searches the keyring for public keys having the specified key id -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
keyId - - -String - - - - provided as string of hex number (lowercase)
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- public keys found -
- - - -
-
- Type -
-
- -Array.<module:key~Key> - - -
-
- - - - -
- - - -
-

getPrivateKeyForAddress(email) → {Array.<module:key~Key>}

- - -
-
- - -
- Searches the keyring for a private key containing the specified email address -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
email - - -String - - - - email address to search for
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- private keys found -
- - - -
-
- Type -
-
- -Array.<module:key~Key> - - -
-
- - - - -
- - - -
-

getPublicKeyForAddress(email) → {Array.<module:key~Key>}

- - -
-
- - -
- searches all public keys in the keyring matching the address or address part of the user ids -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
email - - -String - - - - email address to search for
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- The public keys associated with provided email address. -
- - - -
-
- Type -
-
- -Array.<module:key~Key> - - -
-
- - - - -
- - - -
-

importKey(armored)

- - -
-
- - -
- Imports a key from an ascii armored message -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
armored - - -String - - - - message to read the keys/key from
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

removeKey(index) → {module:key~Key}

- - -
-
- - -
- Removes a public key from the public key keyring at the specified index -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
index - - -Integer - - - - the index of the public key within the publicKeys array
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- The public key object which has been removed -
- - - -
-
- Type -
-
- -module:key~Key - - -
-
- - - - -
- - - -
-

store()

- - -
-
- - -
- Calls the storeHandler to save the keys -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - -

<inner> checkForIdentityAndKeyTypeMatch(keys, identityFunction, identityInput, keyType) → {Array.<module:key~Key>}

@@ -2035,13 +822,13 @@ keyring from HTML5 local storage and initializes this instance.

- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:42 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST)
diff --git a/doc/keyring.js.html b/doc/keyring.js.html index a80c80ef..0658d26c 100644 --- a/doc/keyring.js.html +++ b/doc/keyring.js.html @@ -58,162 +58,161 @@ var openpgp = require('openpgp'); * @return {Boolean} True if the input matches the specified key */ -/** +module.exports = Keyring; + + /** * 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; +function Keyring(storeHandler) { + this.storeHandler = storeHandler || new (require('./localstore.js'))(); this.keys = this.storeHandler.load(); +}; - /** - * Calls the storeHandler to save the keys - */ - this.store = function () { - this.storeHandler.store(this.keys); - }; +/** + * Calls the storeHandler to save the keys + */ +Keyring.prototype.store = function () { + this.storeHandler.store(this.keys); +}; - /** - * Clear the keyring - erase all the keys - */ - this.clear = function() { - this.keys = []; - }; +/** + * Clear the keyring - erase all the keys + */ +Keyring.prototype.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(); - for (var i; i < keyEmails.length; i++) { - //we need to get just the email from the userid key - keyEmail = keyEmails[i].split('<')[1].split('>')[0].trim().toLowerCase(); - if (keyEmail == email) { - return true; - } +/** + * 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(); + for (var i; i < keyEmails.length; i++) { + //we need to get just the email from the userid key + keyEmail = keyEmails[i].split('<')[1].split('>')[0].trim().toLowerCase(); + if (keyEmail == email) { + return true; } - return false; } + 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++) { - if (openpgp.util.hexstrdump(keyids[i].write()) == id) { - return true; - } +/** + * 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++) { + if (openpgp.util.hexstrdump(keyids[i].write()) == id) { + return true; } - return false; } + 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)) { - results.push(key); - } - break; - case openpgp.enums.packet.private_key: - if (key.isPrivate() && identityFunction(identityInput, key)) { - results.push(key); - } - break; - } +/** + * 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.publicKey: + if (key.isPublic() && identityFunction(identityInput, key)) { + results.push(key); + } + break; + case openpgp.enums.packet.private_key: + if (key.isPrivate() && identityFunction(identityInput, key)) { + results.push(key); + } + break; } - return results; } + return results; +} - /** - * searches all public keys in the keyring matching the address or address part of the user ids - * @param {String} email email address to search for - * @return {Array<module:key~Key>} The public keys associated with provided email address. - */ - this.getPublicKeyForAddress = function (email) { - return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.public_key); - }; +/** + * searches all public keys in the keyring matching the address or address part of the user ids + * @param {String} email email address to search for + * @return {Array<module:key~Key>} The public keys associated with provided email address. + */ +Keyring.prototype.getPublicKeyForAddress = function (email) { + return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.publicKey); +}; - /** - * 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 - */ - this.getPrivateKeyForAddress = function (email) { - return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.secret_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 + */ +Keyring.prototype.getPrivateKeyForAddress = function (email) { + return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.secretKey); +}; - /** - * 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 - */ - this.getKeysForKeyId = function (keyId) { - return checkForIdentityAndKeyTypeMatch(this.keys, idCheck, keyId, openpgp.enums.packet.public_key); - }; +/** + * 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 + */ +Keyring.prototype.getKeysForKeyId = function (keyId) { + return checkForIdentityAndKeyTypeMatch(this.keys, idCheck, keyId, openpgp.enums.packet.publicKey); +}; - /** - * Imports a key from an ascii armored message - * @param {String} armored message to read the keys/key from - */ - this.importKey = function (armored) { - this.keys = this.keys.concat(openpgp.key.readArmored(armored).keys); +/** + * Imports a key from an ascii armored message + * @param {String} armored message to read the keys/key from + */ +Keyring.prototype.importKey = function (armored) { + this.keys = this.keys.concat(openpgp.key.readArmored(armored).keys); - return true; - }; + return true; +}; - /** - * 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 - */ - this.exportKey = function (index) { - return this.keys[index].armor(); - }; +/** + * 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 + */ +Keyring.prototype.exportKey = function (index) { + return this.keys[index].armor(); +}; - /** - * 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 - */ - this.removeKey = function (index) { - var removed = this.keys.splice(index, 1); +/** + * 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 + */ +Keyring.prototype.removeKey = function (index) { + var removed = this.keys.splice(index, 1); - return removed; - }; + return removed; +}; - /** - * 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 - */ - this.exportPublicKey = function (index) { - return this.keys[index].toPublic().armor(); - }; +/** + * 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 + */ +Keyring.prototype.exportPublicKey = function (index) { + return this.keys[index].toPublic().armor(); };
@@ -225,13 +224,13 @@ module.exports = function(storeHandler) {
diff --git a/doc/literal-Literal.html b/doc/literal-Literal.html new file mode 100644 index 00000000..6ad79fbf --- /dev/null +++ b/doc/literal-Literal.html @@ -0,0 +1,924 @@ + + + + + JSDoc: Class: Literal + + + + + + + + + + +
+ +

Class: Literal

+ + + + + +
+ +
+

+ packet/literal~ + + Literal +

+ +
+ +
+
+ + + + +
+

new Literal()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

getBytes() → {String}

+ + +
+
+ + +
+ Get the byte sequence representing the literal packet data +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ A sequence of bytes +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

getText() → {String}

+ + +
+
+ + +
+ Returns literal data packets as native JavaScript string +with normalized end of line to \n +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ literal data as text +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

read(input, position, len) → {module:packet/literal}

+ + +
+
+ + +
+ Parsing function for a literal data packet (tag 11). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Payload of a tag 11 packet
position + + +Integer + + + + Position to start reading from the input string
len + + +Integer + + + + Length of the packet or the remaining length of + input at position
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ object representation +
+ + + +
+
+ Type +
+
+ +module:packet/literal + + +
+
+ + + + +
+ + + +
+

setBytes(bytes, format)

+ + +
+
+ + +
+ Set the packet data to value represented by the provided string of bytes. +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
bytes + + +String + + + + The string of bytes
format + + +utf8 +| + +binary +| + +text + + + + The format of the string of bytes
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

setText(text)

+ + +
+
+ + +
+ Set the packet data to a javascript native string, end of line +will be normalized to \r\n and by default text is converted to UTF8 +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
text + + +String + + + + Any native javascript string
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

write(data) → {String}

+ + +
+
+ + +
+ Creates a string representation of the packet +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
data + + +String + + + + The data to be inserted as body
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ string-representation of the packet +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/literal.html b/doc/literal.html index 70fe457c..a934494e 100644 --- a/doc/literal.html +++ b/doc/literal.html @@ -35,6 +35,8 @@
+ +
Implementation of the Literal Data Packet (Tag 11)

@@ -42,74 +44,6 @@ RFC4880 5.9: A Literal Data packet contains the body of a message; data that is not to be further interpreted.
-
-

new (require("packet/literal"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -164,792 +98,23 @@ is not to be further interpreted.
- - - - - - -

Methods

+

Classes

- -
-

getBytes() → {String}

- - -
-
- - -
- Get the byte sequence representing the literal packet data -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A sequence of bytes -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

getText() → {String}

- - -
-
- - -
- Returns literal data packets as native JavaScript string -with normalized end of line to \n -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- literal data as text -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

read(input, position, len) → {module:packet/literal}

- - -
-
- - -
- Parsing function for a literal data packet (tag 11). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Payload of a tag 11 packet
position - - -Integer - - - - Position to start reading from the input string
len - - -Integer - - - - Length of the packet or the remaining length of - input at position
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- object representation -
- - - -
-
- Type -
-
- -module:packet/literal - - -
-
- - - - -
- - - -
-

setBytes(bytes, format)

- - -
-
- - -
- Set the packet data to value represented by the provided string of bytes. -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
bytes - - -String - - - - The string of bytes
format - - -utf8 -| - -binary -| - -text - - - - The format of the string of bytes
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

setText(text)

- - -
-
- - -
- Set the packet data to a javascript native string, end of line -will be normalized to \r\n and by default text is converted to UTF8 -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
text - - -String - - - - Any native javascript string
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

write(data) → {String}

- - -
-
- - -
- Creates a string representation of the packet -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -String - - - - The data to be inserted as body
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- string-representation of the packet -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- +
Literal
+
+ + + + + +
@@ -960,13 +125,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 9fd3c59a..27807408 100644 --- a/doc/literal.js.html +++ b/doc/literal.js.html @@ -52,108 +52,109 @@ * @module packet/literal */ +module.exports = Literal; + var util = require('../util'), enums = require('../enums.js'); /** * @constructor */ -module.exports = function literal() { +function Literal() { this.format = 'utf8'; // default format for literal data packets this.data = ''; // literal data representation as native JavaScript string or bytes this.date = new Date(); - - - /** - * Set the packet data to a javascript native string, end of line - * will be normalized to \r\n and by default text is converted to UTF8 - * @param {String} text Any native javascript string - */ - this.setText = function (text) { - // normalize EOL to \r\n - text = text.replace(/\r/g, '').replace(/\n/g, '\r\n'); - // encode UTF8 - this.data = this.format == 'utf8' ? util.encode_utf8(text) : text; - } - - /** - * Returns literal data packets as native JavaScript string - * with normalized end of line to \n - * @return {String} literal data as text - */ - this.getText = function () { - // decode UTF8 - var text = util.decode_utf8(this.data); - // normalize EOL to \n - return text.replace(/\r\n/g, '\n'); - } - - /** - * Set the packet data to value represented by the provided string of bytes. - * @param {String} bytes The string of bytes - * @param {utf8|binary|text} format The format of the string of bytes - */ - this.setBytes = function (bytes, format) { - this.format = format; - this.data = bytes; - } - - - /** - * Get the byte sequence representing the literal packet data - * @returns {String} A sequence of bytes - */ - this.getBytes = function () { - return this.data; - } - - - /** - * Parsing function for a literal data packet (tag 11). - * - * @param {String} input Payload of a tag 11 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/literal} object representation - */ - this.read = function (bytes) { - // - A one-octet field that describes how the data is formatted. - - var format = enums.read(enums.literal, bytes.charCodeAt(0)); - - var filename_len = bytes.charCodeAt(1); - this.filename = util.decode_utf8(bytes.substr(2, filename_len)); - - this.date = util.readDate(bytes.substr(2 + filename_len, 4)); - - var data = bytes.substring(6 + filename_len); - - this.setBytes(data, format); - } - - /** - * Creates a string representation of the packet - * - * @param {String} data The data to be inserted as body - * @return {String} string-representation of the packet - */ - this.write = function () { - var filename = util.encode_utf8("msg.txt"); - - var data = this.getBytes(); - - var result = ''; - result += String.fromCharCode(enums.write(enums.literal, this.format)); - result += String.fromCharCode(filename.length); - result += filename; - result += util.writeDate(this.date); - result += data; - return result; - } } + +/** + * Set the packet data to a javascript native string, end of line + * will be normalized to \r\n and by default text is converted to UTF8 + * @param {String} text Any native javascript string + */ +Literal.prototype.setText = function (text) { + // normalize EOL to \r\n + text = text.replace(/\r/g, '').replace(/\n/g, '\r\n'); + // encode UTF8 + this.data = this.format == 'utf8' ? util.encode_utf8(text) : text; +}; + +/** + * Returns literal data packets as native JavaScript string + * with normalized end of line to \n + * @return {String} literal data as text + */ +Literal.prototype.getText = function () { + // decode UTF8 + var text = util.decode_utf8(this.data); + // normalize EOL to \n + return text.replace(/\r\n/g, '\n'); +}; + +/** + * Set the packet data to value represented by the provided string of bytes. + * @param {String} bytes The string of bytes + * @param {utf8|binary|text} format The format of the string of bytes + */ +Literal.prototype.setBytes = function (bytes, format) { + this.format = format; + this.data = bytes; +}; + + +/** + * Get the byte sequence representing the literal packet data + * @returns {String} A sequence of bytes + */ +Literal.prototype.getBytes = function () { + return this.data; +}; + + +/** + * Parsing function for a literal data packet (tag 11). + * + * @param {String} input Payload of a tag 11 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/literal} object representation + */ +Literal.prototype.read = function (bytes) { + // - A one-octet field that describes how the data is formatted. + + var format = enums.read(enums.literal, bytes.charCodeAt(0)); + + var filename_len = bytes.charCodeAt(1); + this.filename = util.decode_utf8(bytes.substr(2, filename_len)); + + this.date = util.readDate(bytes.substr(2 + filename_len, 4)); + + var data = bytes.substring(6 + filename_len); + + this.setBytes(data, format); +}; + +/** + * Creates a string representation of the packet + * + * @param {String} data The data to be inserted as body + * @return {String} string-representation of the packet + */ +Literal.prototype.write = function () { + var filename = util.encode_utf8("msg.txt"); + + var data = this.getBytes(); + + var result = ''; + result += String.fromCharCode(enums.write(enums.literal, this.format)); + result += String.fromCharCode(filename.length); + result += filename; + result += util.writeDate(this.date); + result += data; + return result; +}; @@ -164,13 +165,13 @@ module.exports = function literal() {
diff --git a/doc/localStorage-LocalStorage.html b/doc/localStorage-LocalStorage.html new file mode 100644 index 00000000..65ad7272 --- /dev/null +++ b/doc/localStorage-LocalStorage.html @@ -0,0 +1,292 @@ + + + + + JSDoc: Class: LocalStorage + + + + + + + + + + +
+ +

Class: LocalStorage

+ + + + + +
+ +
+

+ config/localStorage~ + + LocalStorage +

+ +
+ +
+
+ + + + +
+

new LocalStorage()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

read()

+ + +
+
+ + +
+ Reads the config out of the HTML5 local storage +and initializes the object config. +if config is null the default config will be used +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

write()

+ + +
+
+ + +
+ Writes the config to HTML5 local storage +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/localStorage.html b/doc/localStorage.html index a66d2ac9..f7ff9c56 100644 --- a/doc/localStorage.html +++ b/doc/localStorage.html @@ -35,78 +35,12 @@
+ +
This object storing and retrieving configuration from HTML5 local storage.
-
-

new (require("config/localStorage"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -153,160 +87,23 @@ - - - - - - -

Methods

+

Classes

- -
-

read()

- - -
-
- - -
- Reads the config out of the HTML5 local storage -and initializes the object config. -if config is null the default config will be used -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

write()

- - -
-
- - -
- Writes the config to HTML5 local storage -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- +
LocalStorage
+
+ + + + + +
@@ -317,13 +114,13 @@ if config is null the default config will be used
diff --git a/doc/localStorage.js.html b/doc/localStorage.js.html index b5df0561..9d6be675 100644 --- a/doc/localStorage.js.html +++ b/doc/localStorage.js.html @@ -30,32 +30,34 @@ * @module config/localStorage */ +module.exports = LocalStorage; + /** * @constructor */ -module.exports = function localStorage() { - - /** - * 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)); - } +function LocalStorage() { } + +/** + * Reads the config out of the HTML5 local storage + * and initializes the object config. + * if config is null the default config will be used + */ +LocalStorage.prototype.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 + */ +LocalStorage.prototype.write = function () { + window.localStorage.setItem("config", JSON.stringify(this.config)); +}; @@ -66,13 +68,13 @@ module.exports = function localStorage() {
diff --git a/doc/localstore.html b/doc/localstore.html index c41a639e..2d55529e 100644 --- a/doc/localstore.html +++ b/doc/localstore.html @@ -99,219 +99,6 @@ -

Methods

- -
- -
-

<static> load() → {Array.<module:key~Key>}

- - -
-
- - -
- Load the keyring from HTML5 local storage and initializes this instance. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- array of keys retrieved from localstore -
- - - -
-
- Type -
-
- -Array.<module:key~Key> - - -
-
- - - - -
- - - -
-

<static> store(keys)

- - -
-
- - -
- Saves the current state of the keyring to HTML5 local storage. -The privateKeys array and publicKeys array gets Stringified using JSON -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
keys - - -Array.<module:key~Key> - - - - array of keys to save in localstore
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- -
- @@ -326,13 +113,13 @@ The privateKeys array and publicKeys array gets Stringified using JSON
diff --git a/doc/localstore.js.html b/doc/localstore.js.html index e2f1a9be..18c9e837 100644 --- a/doc/localstore.js.html +++ b/doc/localstore.js.html @@ -47,39 +47,41 @@ * @requires openpgp * @module keyring/localstore */ +module.exports = LocalStore; var openpgp = require('openpgp'); -module.exports = function () { - /** - * Load the keyring from HTML5 local storage and initializes this instance. - * @return {Array<module:key~Key>} array of keys retrieved from localstore - */ - this.load = function () { - var armoredKeys = JSON.parse(window.localStorage.getItem("armoredKeys")); - 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); - } - } - return keys; - } +function LocalStore() { +} - /** - * 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 = []; - for (var i = 0; i < keys.length; i++) { - armoredKeys.push(keys[i].armor()); +/** + * Load the keyring from HTML5 local storage and initializes this instance. + * @return {Array<module:key~Key>} array of keys retrieved from localstore + */ +LocalStore.prototype.load = function () { + var armoredKeys = JSON.parse(window.localStorage.getItem("armoredKeys")); + 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); } - window.localStorage.setItem("armoredKeys", JSON.stringify(armoredKeys)); } + 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 + */ +LocalStore.prototype.store = function (keys) { + var armoredKeys = []; + for (var i = 0; i < keys.length; i++) { + armoredKeys.push(keys[i].armor()); + } + window.localStorage.setItem("armoredKeys", JSON.stringify(armoredKeys)); }; @@ -91,13 +93,13 @@ module.exports = function () {
diff --git a/doc/marker-Marker.html b/doc/marker-Marker.html new file mode 100644 index 00000000..77a3138b --- /dev/null +++ b/doc/marker-Marker.html @@ -0,0 +1,338 @@ + + + + + JSDoc: Class: Marker + + + + + + + + + + +
+ +

Class: Marker

+ + + + + +
+ +
+

+ packet/marker~ + + Marker +

+ +
+ +
+
+ + + + +
+

new Marker()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

read(input, position, len) → {module:packet/marker}

+ + +
+
+ + +
+ Parsing function for a literal data packet (tag 10). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Payload of a tag 10 packet
position + + +Integer + + + + Position to start reading from the input string
len + + +Integer + + + + Length of the packet or the remaining length of + input at position
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ Object representation +
+ + + +
+
+ Type +
+
+ +module:packet/marker + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/marker.html b/doc/marker.html index de21e0d9..2208f53b 100644 --- a/doc/marker.html +++ b/doc/marker.html @@ -35,6 +35,8 @@
+ +
Implementation of the strange "Marker packet" (Tag 10)

@@ -46,74 +48,6 @@ the Marker packet.
Such a packet MUST be ignored when received.
-
-

new (require("packet/marker"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -160,206 +94,23 @@ Such a packet MUST be ignored when received.
- - - - - - -

Methods

+

Classes

- -
-

read(input, position, len) → {module:packet/marker}

- - -
-
- - -
- Parsing function for a literal data packet (tag 10). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Payload of a tag 10 packet
position - - -Integer - - - - Position to start reading from the input string
len - - -Integer - - - - Length of the packet or the remaining length of - input at position
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- Object representation -
- - - -
-
- Type -
-
- -module:packet/marker - - -
-
- - - - -
- +
Marker
+
+ + + + + +
@@ -370,13 +121,13 @@ Such a packet MUST be ignored when received.
diff --git a/doc/marker.js.html b/doc/marker.js.html index 0d7d8d83..89d67669 100644 --- a/doc/marker.js.html +++ b/doc/marker.js.html @@ -55,30 +55,33 @@ * @module packet/marker */ +module.exports = Marker; + /** * @constructor */ -module.exports = function marker() { - /** - * Parsing function for a literal data packet (tag 10). - * - * @param {String} input Payload of a tag 10 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/marker} Object representation - */ - this.read = function (bytes) { - if (bytes.charCodeAt(0) == 0x50 && // P - bytes.charCodeAt(1) == 0x47 && // G - bytes.charCodeAt(2) == 0x50) // P - return true; - // marker packet does not contain "PGP" - return false; - } +function Marker() { } + +/** + * Parsing function for a literal data packet (tag 10). + * + * @param {String} input Payload of a tag 10 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/marker} Object representation + */ +Marker.prototype.read = function (bytes) { + if (bytes.charCodeAt(0) == 0x50 && // P + bytes.charCodeAt(1) == 0x47 && // G + bytes.charCodeAt(2) == 0x50) // P + return true; + // marker packet does not contain "PGP" + return false; +}; @@ -89,13 +92,13 @@ module.exports = function marker() {
diff --git a/doc/md5.html b/doc/md5.html index 8c77e0ef..80aa0b38 100644 --- a/doc/md5.html +++ b/doc/md5.html @@ -229,13 +229,13 @@
diff --git a/doc/md5.js.html b/doc/md5.js.html index 596d8779..2fef87d0 100644 --- a/doc/md5.js.html +++ b/doc/md5.js.html @@ -54,7 +54,7 @@ module.exports = function (entree) { var hex = md5(entree); var bin = util.hex2bin(hex); return bin; -} +}; function md5cycle(x, k) { var a = x[0], @@ -252,13 +252,13 @@ if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
diff --git a/doc/message.js.html b/doc/message.js.html index 8dd189e3..d79160d7 100644 --- a/doc/message.js.html +++ b/doc/message.js.html @@ -69,7 +69,7 @@ function Message(packetlist) { if (!(this instanceof Message)) { return new Message(packetlist); } - this.packets = packetlist || new packet.list(); + this.packets = packetlist || new packet.List(); } /** @@ -78,7 +78,7 @@ function Message(packetlist) { */ Message.prototype.getEncryptionKeyIds = function() { var keyIds = []; - var pkESKeyPacketlist = this.packets.filterByTag(enums.packet.public_key_encrypted_session_key); + var pkESKeyPacketlist = this.packets.filterByTag(enums.packet.publicKeyEncryptedSessionKey); pkESKeyPacketlist.forEach(function(packet) { keyIds.push(packet.publicKeyId); }); @@ -93,7 +93,7 @@ Message.prototype.getSigningKeyIds = function() { var keyIds = []; var msg = this.unwrapCompressed(); // search for one pass signatures - var onePassSigList = msg.packets.filterByTag(enums.packet.one_pass_signature); + var onePassSigList = msg.packets.filterByTag(enums.packet.onePassSignature); onePassSigList.forEach(function(packet) { keyIds.push(packet.signingKeyId); }); @@ -120,7 +120,7 @@ Message.prototype.decrypt = function(privateKey) { } var privateKeyPacket = privateKey.getPrivateKeyPacket(encryptionKeyIds); if (!privateKeyPacket.isDecrypted) throw new Error('Private key is not decrypted.'); - var pkESKeyPacketlist = this.packets.filterByTag(enums.packet.public_key_encrypted_session_key); + var pkESKeyPacketlist = this.packets.filterByTag(enums.packet.publicKeyEncryptedSessionKey); var pkESKeyPacket; for (var i = 0; i < pkESKeyPacketlist.length; i++) { if (pkESKeyPacketlist[i].publicKeyId.equals(privateKeyPacket.getKeyId())) { @@ -130,7 +130,7 @@ Message.prototype.decrypt = function(privateKey) { } } if (pkESKeyPacket) { - var symEncryptedPacketlist = this.packets.filterByTag(enums.packet.symmetrically_encrypted, enums.packet.sym_encrypted_integrity_protected); + var symEncryptedPacketlist = this.packets.filterByTag(enums.packet.symmetricallyEncrypted, enums.packet.symEncryptedIntegrityProtected); if (symEncryptedPacketlist.length !== 0) { var symEncryptedPacket = symEncryptedPacketlist[0]; symEncryptedPacket.decrypt(pkESKeyPacket.sessionKeyAlgorithm, pkESKeyPacket.sessionKey); @@ -167,13 +167,13 @@ Message.prototype.getText = function() { * @return {Array<module:message~Message>} new message with encrypted content */ Message.prototype.encrypt = function(keys) { - var packetlist = new packet.list(); + var packetlist = new packet.List(); //TODO get preferred algo from signature var sessionKey = crypto.generateSessionKey(enums.read(enums.symmetric, config.encryption_cipher)); keys.forEach(function(key) { var encryptionKeyPacket = key.getEncryptionKeyPacket(); if (encryptionKeyPacket) { - var pkESKeyPacket = new packet.public_key_encrypted_session_key(); + var pkESKeyPacket = new packet.PublicKeyEncryptedSessionKey(); pkESKeyPacket.publicKeyId = encryptionKeyPacket.getKeyId(); pkESKeyPacket.publicKeyAlgorithm = encryptionKeyPacket.algorithm; pkESKeyPacket.sessionKey = sessionKey; @@ -187,9 +187,9 @@ Message.prototype.encrypt = function(keys) { }); var symEncryptedPacket; if (config.integrity_protect) { - symEncryptedPacket = new packet.sym_encrypted_integrity_protected(); + symEncryptedPacket = new packet.SymEncryptedIntegrityProtected(); } else { - symEncryptedPacket = new packet.symmetrically_encrypted(); + symEncryptedPacket = new packet.SymmetricallyEncrypted(); } symEncryptedPacket.packets = this.packets; //TODO get preferred algo from signature @@ -205,17 +205,17 @@ Message.prototype.encrypt = function(keys) { */ Message.prototype.sign = function(privateKeys) { - var packetlist = new packet.list(); + var packetlist = new packet.List(); var literalDataPacket = this.packets.findPacket(enums.packet.literal); if (!literalDataPacket) throw new Error('No literal data packet to sign.'); var literalFormat = enums.write(enums.literal, literalDataPacket.format); - var signatureType = literalFormat == enums.literal.binary - ? enums.signature.binary : enums.signature.text; - - for (var i = 0; i < privateKeys.length; i++) { - var onePassSig = new packet.one_pass_signature(); + var signatureType = literalFormat == enums.literal.binary ? + enums.signature.binary : enums.signature.text; + var i; + for (i = 0; i < privateKeys.length; i++) { + var onePassSig = new packet.OnePassSignature(); onePassSig.type = signatureType; //TODO get preferred hashg algo from key signature onePassSig.hashAlgorithm = config.prefer_hash_algorithm; @@ -230,8 +230,8 @@ Message.prototype.sign = function(privateKeys) { packetlist.push(literalDataPacket); - for (var i = privateKeys.length - 1; i >= 0; i--) { - var signaturePacket = new packet.signature(); + for (i = privateKeys.length - 1; i >= 0; i--) { + var signaturePacket = new packet.Signature(); signaturePacket.signatureType = signatureType; signaturePacket.hashAlgorithm = config.prefer_hash_algorithm; signaturePacket.publicKeyAlgorithm = signingKeyPacket.algorithm; @@ -300,7 +300,7 @@ function readArmored(armoredText) { //TODO how do we want to handle bad text? Exception throwing //TODO don't accept non-message armored texts var input = armor.decode(armoredText).data; - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.read(input); var newMessage = new Message(packetlist); return newMessage; @@ -313,10 +313,10 @@ function readArmored(armoredText) { * @static */ function fromText(text) { - var literalDataPacket = new packet.literal(); + var literalDataPacket = new packet.Literal(); // text will be converted to UTF8 literalDataPacket.setText(text); - var literalDataPacketlist = new packet.list(); + var literalDataPacketlist = new packet.List(); literalDataPacketlist.push(literalDataPacket); var newMessage = new Message(literalDataPacketlist); return newMessage; @@ -329,9 +329,9 @@ function fromText(text) { * @static */ function fromBinary(bytes) { - var literalDataPacket = new packet.literal(); + var literalDataPacket = new packet.Literal(); literalDataPacket.setBytes(bytes, enums.read(enums.literal, enums.literal.binary)); - var literalDataPacketlist = new packet.list(); + var literalDataPacketlist = new packet.List(); literalDataPacketlist.push(literalDataPacket); var newMessage = new Message(literalDataPacketlist); return newMessage; @@ -351,13 +351,13 @@ exports.fromBinary = fromBinary;
diff --git a/doc/module-armor.html b/doc/module-armor.html index d5816512..8dedb041 100644 --- a/doc/module-armor.html +++ b/doc/module-armor.html @@ -112,13 +112,13 @@
diff --git a/doc/module-cleartext-CleartextMessage.html b/doc/module-cleartext-CleartextMessage.html index 700e6030..04795f31 100644 --- a/doc/module-cleartext-CleartextMessage.html +++ b/doc/module-cleartext-CleartextMessage.html @@ -741,13 +741,13 @@ See http://tools.ietf.org/html/rfc4880#section-7
diff --git a/doc/module-cleartext.html b/doc/module-cleartext.html index 8f66e4f8..8186a3fd 100644 --- a/doc/module-cleartext.html +++ b/doc/module-cleartext.html @@ -267,13 +267,13 @@
diff --git a/doc/module-config.html b/doc/module-config.html index c2381b1b..0fd7f548 100644 --- a/doc/module-config.html +++ b/doc/module-config.html @@ -112,13 +112,13 @@
diff --git a/doc/module-crypto.html b/doc/module-crypto.html index 39c1b5bf..fae66fe9 100644 --- a/doc/module-crypto.html +++ b/doc/module-crypto.html @@ -515,13 +515,13 @@
diff --git a/doc/module-enums.html b/doc/module-enums.html index 6d847f60..a141cdce 100644 --- a/doc/module-enums.html +++ b/doc/module-enums.html @@ -1643,7 +1643,7 @@ - public_key_encrypted_session_key + publicKeyEncryptedSessionKey @@ -1701,7 +1701,7 @@ - sym_encrypted_session_key + symEncryptedSessionKey @@ -1730,7 +1730,7 @@ - one_pass_signature + onePassSignature @@ -1759,7 +1759,7 @@ - secret_key + secretKey @@ -1788,7 +1788,7 @@ - public_key + publicKey @@ -1817,7 +1817,7 @@ - secret_subkey + secretSubkey @@ -1875,7 +1875,7 @@ - symmetrically_encrypted + symmetricallyEncrypted @@ -2020,7 +2020,7 @@ - public_subkey + publicSubkey @@ -2049,7 +2049,7 @@ - user_attribute + userAttribute @@ -2078,7 +2078,7 @@ - sym_encrypted_integrity_protected + symEncryptedIntegrityProtected @@ -2107,7 +2107,7 @@ - modification_detection_code + modificationDetectionCode @@ -4527,13 +4527,13 @@ document) that cannot include a target subpacket.
diff --git a/doc/module-key-Key.html b/doc/module-key-Key.html index 2a4ec89c..4c49f135 100644 --- a/doc/module-key-Key.html +++ b/doc/module-key-Key.html @@ -216,7 +216,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -355,7 +355,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -517,7 +517,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -608,7 +608,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -695,7 +695,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -798,7 +798,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -885,7 +885,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -978,7 +978,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -1067,7 +1067,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -1206,7 +1206,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -1347,7 +1347,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -1440,7 +1440,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -1537,7 +1537,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -1624,7 +1624,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -1715,7 +1715,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -1802,7 +1802,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -2097,7 +2097,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -2189,7 +2189,7 @@ and valid self signature
Source:
@@ -2252,13 +2252,13 @@ and valid self signature
diff --git a/doc/module-key-SubKey.html b/doc/module-key-SubKey.html index ca977352..891957a6 100644 --- a/doc/module-key-SubKey.html +++ b/doc/module-key-SubKey.html @@ -80,7 +80,7 @@
Source:
@@ -218,7 +218,7 @@
Source:
@@ -356,7 +356,7 @@
Source:
@@ -443,7 +443,7 @@
Source:
@@ -531,7 +531,7 @@ and valid binding signature
Source:
@@ -594,13 +594,13 @@ and valid binding signature
diff --git a/doc/module-key-User.html b/doc/module-key-User.html index cb0d7724..9727a170 100644 --- a/doc/module-key-User.html +++ b/doc/module-key-User.html @@ -80,7 +80,7 @@
Source:
@@ -218,7 +218,7 @@
Source:
@@ -383,7 +383,7 @@
Source:
@@ -474,7 +474,7 @@
Source:
@@ -613,7 +613,7 @@ and validity of self signature
Source:
@@ -676,13 +676,13 @@ and validity of self signature
diff --git a/doc/module-key.html b/doc/module-key.html index fde13d78..c0b816ba 100644 --- a/doc/module-key.html +++ b/doc/module-key.html @@ -281,7 +281,7 @@ Primary and subkey will be of same type.
Source:
@@ -416,7 +416,7 @@ Primary and subkey will be of same type.
Source:
@@ -479,13 +479,13 @@ Primary and subkey will be of same type.
diff --git a/doc/module-keyid.html b/doc/module-keyid.html index b9021d4d..01d1baba 100644 --- a/doc/module-keyid.html +++ b/doc/module-keyid.html @@ -112,13 +112,13 @@
diff --git a/doc/module-message-Message.html b/doc/module-message-Message.html index 8dcfb4f7..99367b60 100644 --- a/doc/module-message-Message.html +++ b/doc/module-message-Message.html @@ -1297,13 +1297,13 @@ See http://tools.ietf.org/html/rfc4880#section-11.3
diff --git a/doc/module-message.html b/doc/module-message.html index e44795a4..a8a360cd 100644 --- a/doc/module-message.html +++ b/doc/module-message.html @@ -547,13 +547,13 @@
diff --git a/doc/module-mpi.html b/doc/module-mpi.html index 42165914..f055805d 100644 --- a/doc/module-mpi.html +++ b/doc/module-mpi.html @@ -112,13 +112,13 @@
diff --git a/doc/module-openpgp.html b/doc/module-openpgp.html index 6323cef8..f0ba52c7 100644 --- a/doc/module-openpgp.html +++ b/doc/module-openpgp.html @@ -1358,13 +1358,13 @@ Primary and subkey will be of same type.
diff --git a/doc/module-packet.html b/doc/module-packet.html index 951c331e..a4097997 100644 --- a/doc/module-packet.html +++ b/doc/module-packet.html @@ -100,7 +100,7 @@
-

<static> compressed

+

<static> Compressed

@@ -157,7 +157,7 @@
-

<static> literal

+

<static> Literal

@@ -214,7 +214,7 @@
-

<static> marker

+

<static> Marker

@@ -271,7 +271,7 @@
-

<static> one_pass_signature

+

<static> OnePassSignature

@@ -328,7 +328,7 @@
-

<static> public_key

+

<static> PublicKey

@@ -385,7 +385,7 @@
-

<static> public_key_encrypted_session_key

+

<static> PublicKeyEncryptedSessionKey

@@ -442,7 +442,7 @@
-

<static> public_subkey

+

<static> PublicSubkey

@@ -499,7 +499,7 @@
-

<static> secret_key

+

<static> SecretKey

@@ -556,7 +556,7 @@
-

<static> secret_subkey

+

<static> SecretSubkey

@@ -613,7 +613,7 @@
-

<static> signature

+

<static> Signature

@@ -670,7 +670,7 @@
-

<static> sym_encrypted_integrity_protected

+

<static> SymEncryptedIntegrityProtected

@@ -727,7 +727,7 @@
-

<static> sym_encrypted_session_key

+

<static> SymEncryptedSessionKey

@@ -784,7 +784,7 @@
-

<static> symmetrically_encrypted

+

<static> SymmetricallyEncrypted

@@ -841,7 +841,7 @@
-

<static> trust

+

<static> Trust

@@ -898,7 +898,7 @@
-

<static> user_attribute

+

<static> UserAttribute

@@ -955,7 +955,7 @@
-

<static> userid

+

<static> Userid

@@ -1027,13 +1027,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:43 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST)
diff --git a/doc/module-s2k.html b/doc/module-s2k.html index bc6723c3..e5c44c09 100644 --- a/doc/module-s2k.html +++ b/doc/module-s2k.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/module-util.html b/doc/module-util.html index 4b434820..e017d883 100644 --- a/doc/module-util.html +++ b/doc/module-util.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:45 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:13 GMT-0800 (PST)
diff --git a/doc/mpi-Mpi.html b/doc/mpi-Mpi.html new file mode 100644 index 00000000..4f0c4be1 --- /dev/null +++ b/doc/mpi-Mpi.html @@ -0,0 +1,440 @@ + + + + + JSDoc: Class: Mpi + + + + + + + + + + +
+ +

Class: Mpi

+ + + + + +
+ +
+

+ type/mpi~ + + Mpi +

+ +
+ +
+
+ + + + +
+

new Mpi()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

data

+ + +
+
+ +
+ An implementation dependent integer +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

read(input) → {Integer}

+ + +
+
+ + +
+ Parsing function for a mpi (RFC 4880 3.2). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Payload of mpi data
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ Length of data read +
+ + + +
+
+ Type +
+
+ +Integer + + +
+
+ + + + +
+ + + +
+

write() → {String}

+ + +
+
+ + +
+ Converts the mpi object to a string as specified in RFC4880 3.2 +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ mpi Byte representation +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/mpi.html b/doc/mpi.html index 87d75ab4..055b1ba5 100644 --- a/doc/mpi.html +++ b/doc/mpi.html @@ -35,6 +35,8 @@
+ +
Implementation of type MPI (RFC4880 3.2)

@@ -46,74 +48,6 @@ of the MPI in bits followed by a string of octets that contain the actual integer.
-
-

new (require("type/mpi"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -168,304 +102,19 @@ actual integer.
- - - - -

Members

+

Classes

- -
-

data

- - -
-
- -
- An implementation dependent integer -
- - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
Mpi
+
-

Methods

- -
- -
-

read(input) → {Integer}

-
-
-
- Parsing function for a mpi (RFC 4880 3.2). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Payload of mpi data
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- Length of data read -
- - - -
-
- Type -
-
- -Integer - - -
-
- - - - -
- - - -
-

write() → {String}

- - -
-
- - -
- Converts the mpi object to a string as specified in RFC4880 3.2 -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- mpi Byte representation -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- -
- @@ -480,13 +129,13 @@ actual integer.
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:45 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/mpi.js.html b/doc/mpi.js.html index 757a7fe3..7fee6825 100644 --- a/doc/mpi.js.html +++ b/doc/mpi.js.html @@ -61,70 +61,72 @@ * @module type/mpi */ +module.exports = Mpi; + var BigInteger = require('../crypto/public_key/jsbn.js'), util = require('../util'); /** * @constructor */ -module.exports = function mpi() { +function Mpi() { /** An implementation dependent integer */ this.data = null; - - /** - * Parsing function for a mpi (RFC 4880 3.2). - * @param {String} input Payload of mpi data - * @return {Integer} Length of data read - */ - this.read = function (bytes) { - var bits = (bytes.charCodeAt(0) << 8) | bytes.charCodeAt(1); - - // Additional rules: - // - // The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. - // - // The length field of an MPI describes the length starting from its - // most significant non-zero bit. Thus, the MPI [00 02 01] is not - // formed correctly. It should be [00 01 01]. - - // TODO: Verification of this size method! This size calculation as - // specified above is not applicable in JavaScript - var bytelen = Math.ceil(bits / 8); - - var raw = bytes.substr(2, bytelen); - 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 - * @return {String} mpi Byte representation - */ - this.write = function () { - return this.data.toMPI(); - }; - - this.toBigInteger = function () { - return this.data.clone(); - }; - - this.fromBigInteger = function (bn) { - this.data = bn.clone(); - }; } + +/** + * Parsing function for a mpi (RFC 4880 3.2). + * @param {String} input Payload of mpi data + * @return {Integer} Length of data read + */ +Mpi.prototype.read = function (bytes) { + var bits = (bytes.charCodeAt(0) << 8) | bytes.charCodeAt(1); + + // Additional rules: + // + // The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. + // + // The length field of an MPI describes the length starting from its + // most significant non-zero bit. Thus, the MPI [00 02 01] is not + // formed correctly. It should be [00 01 01]. + + // TODO: Verification of this size method! This size calculation as + // specified above is not applicable in JavaScript + var bytelen = Math.ceil(bits / 8); + + var raw = bytes.substr(2, bytelen); + this.fromBytes(raw); + + return 2 + bytelen; +}; + +Mpi.prototype.fromBytes = function (bytes) { + this.data = new BigInteger(util.hexstrdump(bytes), 16); +}; + +Mpi.prototype.toBytes = function () { + return this.write().substr(2); +}; + +Mpi.prototype.byteLength = function () { + return this.toBytes().length; +}; + +/** + * Converts the mpi object to a string as specified in RFC4880 3.2 + * @return {String} mpi Byte representation + */ +Mpi.prototype.write = function () { + return this.data.toMPI(); +}; + +Mpi.prototype.toBigInteger = function () { + return this.data.clone(); +}; + +Mpi.prototype.fromBigInteger = function (bn) { + this.data = bn.clone(); +};
@@ -135,13 +137,13 @@ module.exports = function mpi() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/one_pass_signature-OnePassSignature.html b/doc/one_pass_signature-OnePassSignature.html new file mode 100644 index 00000000..b9f6b4ab --- /dev/null +++ b/doc/one_pass_signature-OnePassSignature.html @@ -0,0 +1,382 @@ + + + + + JSDoc: Class: OnePassSignature + + + + + + + + + + +
+ +

Class: OnePassSignature

+ + + + + +
+ +
+

+ packet/one_pass_signature~ + + OnePassSignature +

+ +
+ +
+
+ + + + +
+

new OnePassSignature()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

read(bytes) → {module:packet/one_pass_signature}

+ + +
+
+ + +
+ parsing function for a one-pass signature packet (tag 4). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
bytes + + +String + + + + payload of a tag 4 packet
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ object representation +
+ + + +
+
+ Type +
+
+ +module:packet/one_pass_signature + + +
+
+ + + + +
+ + + +
+

write() → {String}

+ + +
+
+ + +
+ creates a string representation of a one-pass signature packet +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ a string representation of a one-pass signature packet +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/one_pass_signature.html b/doc/one_pass_signature.html index 8171b98b..894eb651 100644 --- a/doc/one_pass_signature.html +++ b/doc/one_pass_signature.html @@ -35,6 +35,8 @@
+ +
Implementation of the One-Pass Signature Packets (Tag 4)

@@ -46,74 +48,6 @@ packet to be placed at the end of the message, so that the signer can compute the entire signed message in one pass.
-
-

new (require("packet/one_pass_signature"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -168,250 +102,23 @@ can compute the entire signed message in one pass.
- - - - - - -

Methods

+

Classes

- -
-

read(bytes) → {module:packet/one_pass_signature}

- - -
-
- - -
- parsing function for a one-pass signature packet (tag 4). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
bytes - - -String - - - - payload of a tag 4 packet
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- object representation -
- - - -
-
- Type -
-
- -module:packet/one_pass_signature - - -
-
- - - - -
- - - -
-

write() → {String}

- - -
-
- - -
- creates a string representation of a one-pass signature packet -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- a string representation of a one-pass signature packet -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- +
OnePassSignature
+
+ + + + + +
@@ -422,13 +129,13 @@ can compute the entire signed message in one pass.
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:43 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST)
diff --git a/doc/one_pass_signature.js.html b/doc/one_pass_signature.js.html index df75b80d..cd60f882 100644 --- a/doc/one_pass_signature.js.html +++ b/doc/one_pass_signature.js.html @@ -56,69 +56,71 @@ * @module packet/one_pass_signature */ +module.exports = OnePassSignature; + var enums = require('../enums.js'), type_keyid = require('../type/keyid.js'); /** * @constructor */ -module.exports = function one_pass_signature() { +function OnePassSignature() { this.version = null; // A one-octet version number. The current version is 3. this.type = null; // A one-octet signature type. Signature types are described in RFC4880 Section 5.2.1. this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See RFC4880 9.4) this.publicKeyAlgorithm = null; // A one-octet number describing the public-key algorithm used. (See RFC4880 9.1) this.signingKeyId = null; // An eight-octet number holding the Key ID of the signing key. this.flags = null; // A one-octet number holding a flag showing whether the signature is nested. A zero value indicates that the next packet is another One-Pass Signature packet that describes another signature to be applied to the same message data. +} - /** - * parsing function for a one-pass signature packet (tag 4). - * @param {String} bytes payload of a tag 4 packet - * @return {module:packet/one_pass_signature} object representation - */ - this.read = function (bytes) { - var mypos = 0; - // A one-octet version number. The current version is 3. - this.version = bytes.charCodeAt(mypos++); +/** + * parsing function for a one-pass signature packet (tag 4). + * @param {String} bytes payload of a tag 4 packet + * @return {module:packet/one_pass_signature} object representation + */ +OnePassSignature.prototype.read = function (bytes) { + var mypos = 0; + // A one-octet version number. The current version is 3. + this.version = bytes.charCodeAt(mypos++); - // A one-octet signature type. Signature types are described in - // Section 5.2.1. - this.type = enums.read(enums.signature, bytes.charCodeAt(mypos++)); + // A one-octet signature type. Signature types are described in + // Section 5.2.1. + this.type = enums.read(enums.signature, bytes.charCodeAt(mypos++)); - // A one-octet number describing the hash algorithm used. - this.hashAlgorithm = enums.read(enums.hash, bytes.charCodeAt(mypos++)); + // A one-octet number describing the hash algorithm used. + this.hashAlgorithm = enums.read(enums.hash, bytes.charCodeAt(mypos++)); - // A one-octet number describing the public-key algorithm used. - this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(mypos++)); + // A one-octet number describing the public-key algorithm used. + this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(mypos++)); - // An eight-octet number holding the Key ID of the signing key. - this.signingKeyId = new type_keyid(); - this.signingKeyId.read(bytes.substr(mypos)); - mypos += 8; + // An eight-octet number holding the Key ID of the signing key. + this.signingKeyId = new type_keyid(); + this.signingKeyId.read(bytes.substr(mypos)); + mypos += 8; - // A one-octet number holding a flag showing whether the signature - // is nested. A zero value indicates that the next packet is - // another One-Pass Signature packet that describes another - // signature to be applied to the same message data. - this.flags = bytes.charCodeAt(mypos++); - return this; - } + // A one-octet number holding a flag showing whether the signature + // is nested. A zero value indicates that the next packet is + // another One-Pass Signature packet that describes another + // signature to be applied to the same message data. + this.flags = bytes.charCodeAt(mypos++); + return this; +}; - /** - * creates a string representation of a one-pass signature packet - * @return {String} a string representation of a one-pass signature packet - */ - this.write = function () { - var result = ""; +/** + * creates a string representation of a one-pass signature packet + * @return {String} a string representation of a one-pass signature packet + */ +OnePassSignature.prototype.write = function () { + var result = ""; - result += String.fromCharCode(3); - result += String.fromCharCode(enums.write(enums.signature, this.type)); - result += String.fromCharCode(enums.write(enums.hash, this.hashAlgorithm)); - result += String.fromCharCode(enums.write(enums.publicKey, this.publicKeyAlgorithm)); - result += this.signingKeyId.write(); - result += String.fromCharCode(this.flags); + result += String.fromCharCode(3); + result += String.fromCharCode(enums.write(enums.signature, this.type)); + result += String.fromCharCode(enums.write(enums.hash, this.hashAlgorithm)); + result += String.fromCharCode(enums.write(enums.publicKey, this.publicKeyAlgorithm)); + result += this.signingKeyId.write(); + result += String.fromCharCode(this.flags); - return result; - } + return result; }; @@ -130,13 +132,13 @@ module.exports = function one_pass_signature() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/openpgp.js.html b/doc/openpgp.js.html index 6a6462af..f2449430 100644 --- a/doc/openpgp.js.html +++ b/doc/openpgp.js.html @@ -185,7 +185,7 @@ function generateKeyPair(keyType, numBits, userId, passphrase) { exports.encryptMessage = encryptMessage; exports.signAndEncryptMessage = signAndEncryptMessage; exports.decryptMessage = decryptMessage; -exports.decryptAndVerifyMessage = decryptAndVerifyMessage +exports.decryptAndVerifyMessage = decryptAndVerifyMessage; exports.signClearMessage = signClearMessage; exports.verifyClearSignedMessage = verifyClearSignedMessage; exports.generateKeyPair = generateKeyPair; @@ -199,13 +199,13 @@ exports.generateKeyPair = generateKeyPair;
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/packet.html b/doc/packet.html index 63fc7f2f..646a90c2 100644 --- a/doc/packet.html +++ b/doc/packet.html @@ -239,7 +239,7 @@
Source:
@@ -402,7 +402,7 @@ string
Source:
@@ -565,7 +565,7 @@ string
Source:
@@ -705,7 +705,7 @@ string
Source:
@@ -768,13 +768,13 @@ string
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:43 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST)
diff --git a/doc/packet.js.html b/doc/packet.js.html index fbce2eff..6cef4c28 100644 --- a/doc/packet.js.html +++ b/doc/packet.js.html @@ -51,7 +51,6 @@ var enums = require('../enums.js'), util = require('../util'); - module.exports = { readSimpleLength: function(bytes) { var len = 0, @@ -150,8 +149,8 @@ module.exports = { */ read: function(input, position, len) { // some sanity checks - if (input == null || input.length <= position || input.substring(position).length < 2 || (input.charCodeAt(position) & - 0x80) == 0) { + if (input === null || input.length <= position || input.substring(position).length < 2 || (input.charCodeAt(position) & + 0x80) === 0) { throw new Error("Error during parsing. This message / key is probably not containing a valid OpenPGP format."); } var mypos = position; @@ -160,7 +159,7 @@ module.exports = { var packet_length; format = 0; // 0 = old format; 1 = new format - if ((input.charCodeAt(mypos) & 0x40) != 0) { + if ((input.charCodeAt(mypos) & 0x40) !== 0) { format = 1; } @@ -234,27 +233,28 @@ module.exports = { // EEEK, we're reading the full data here... var mypos2 = mypos + packet_length; bodydata = input.substring(mypos, mypos + packet_length); + var tmplen; while (true) { if (input.charCodeAt(mypos2) < 192) { - var tmplen = input.charCodeAt(mypos2++); + tmplen = input.charCodeAt(mypos2++); packet_length += tmplen; bodydata += input.substring(mypos2, mypos2 + tmplen); mypos2 += tmplen; break; } else if (input.charCodeAt(mypos2) >= 192 && input.charCodeAt(mypos2) < 224) { - var tmplen = ((input.charCodeAt(mypos2++) - 192) << 8) + (input.charCodeAt(mypos2++)) + 192; + tmplen = ((input.charCodeAt(mypos2++) - 192) << 8) + (input.charCodeAt(mypos2++)) + 192; packet_length += tmplen; bodydata += input.substring(mypos2, mypos2 + tmplen); mypos2 += tmplen; break; } else if (input.charCodeAt(mypos2) > 223 && input.charCodeAt(mypos2) < 255) { - var tmplen = 1 << (input.charCodeAt(mypos2++) & 0x1F); + tmplen = 1 << (input.charCodeAt(mypos2++) & 0x1F); packet_length += tmplen; bodydata += input.substring(mypos2, mypos2 + tmplen); mypos2 += tmplen; } else { mypos2++; - var tmplen = (input.charCodeAt(mypos2++) << 24) | (input.charCodeAt(mypos2++) << 16) | (input[mypos2++] + tmplen = (input.charCodeAt(mypos2++) << 24) | (input.charCodeAt(mypos2++) << 16) | (input[mypos2++] .charCodeAt() << 8) | input.charCodeAt(mypos2++); bodydata += input.substring(mypos2, mypos2 + tmplen); packet_length += tmplen; @@ -277,7 +277,7 @@ module.exports = { real_packet_length = packet_length; } - if (bodydata == null) { + if (bodydata === null) { bodydata = input.substring(mypos, mypos + real_packet_length); } @@ -287,7 +287,7 @@ module.exports = { offset: mypos + real_packet_length }; } -} +}; @@ -298,13 +298,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/packetlist-Packetlist.html b/doc/packetlist-Packetlist.html new file mode 100644 index 00000000..66ba0666 --- /dev/null +++ b/doc/packetlist-Packetlist.html @@ -0,0 +1,1051 @@ + + + + + JSDoc: Class: Packetlist + + + + + + + + + + +
+ +

Class: Packetlist

+ + + + + +
+ +
+

+ packet/packetlist~ + + Packetlist +

+ +
+ +
+
+ + + + +
+

new Packetlist()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

<readonly> length :Integer

+ + +
+
+ +
+ The number of packets contained within the list. +
+ + + +
Type:
+
    +
  • + +Integer + + +
  • +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

concat()

+ + +
+
+ + +
+ Concatenates packetlist or array of packets +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

filter()

+ + +
+
+ + +
+ Creates a new PacketList with all packets that pass the test implemented by the provided function. +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

filterByTag()

+ + +
+
+ + +
+ Creates a new PacketList with all packets from the given types +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

findPacket(type) → {module:packet/packet|null}

+ + +
+
+ + +
+ Traverses packet tree and returns first matching packet +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +module:enums.packet + + + + The packet type
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +module:packet/packet +| + +null + + +
+
+ + + + +
+ + + +
+

forEach()

+ + +
+
+ + +
+ Executes the provided callback once for each element +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

indexOfTag()

+ + +
+
+ + +
+ Returns array of found indices by tag +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

push()

+ + +
+
+ + +
+ Adds a packet to the list. This is the only supported method of doing so; +writing to packetlist[i] directly will result in an error. +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

read(A)

+ + +
+
+ + +
+ Reads a stream of binary data and interprents it as a list of packets. +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
A + + +String + + + + binary string of bytes.
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

slice()

+ + +
+
+ + +
+ Returns slice of packetlist +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

write() → {String}

+ + +
+
+ + +
+ Creates a binary representation of openpgp objects contained within the +class instance. +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ A binary string of bytes containing valid openpgp packets. +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/packetlist.html b/doc/packetlist.html index 6ba2a3fb..bda441ba 100644 --- a/doc/packetlist.html +++ b/doc/packetlist.html @@ -35,80 +35,14 @@
+ +
This class represents a list of openpgp packets. Take care when iterating over it - the packets themselves are stored as numerical indices.
-
-

new (require("packet/packetlist"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -165,915 +99,19 @@ are stored as numerical indices.
- - - - -

Members

+

Classes

- -
-

<readonly> length :Integer

- - -
-
- -
- The number of packets contained within the list. -
- - - -
Type:
-
    -
  • - -Integer - - -
  • -
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
Packetlist
+
-

Methods

- -
- -
-

concat()

-
-
-
- Concatenates packetlist or array of packets -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

filter()

- - -
-
- - -
- Creates a new packetList with all packets that pass the test implemented by the provided function. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

filterByTag()

- - -
-
- - -
- Creates a new packetList with all packets from the given types -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

findPacket(type) → {module:packet/packet|null}

- - -
-
- - -
- Traverses packet tree and returns first matching packet -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
type - - -module:enums.packet - - - - The packet type
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -module:packet/packet -| - -null - - -
-
- - - - -
- - - -
-

forEach()

- - -
-
- - -
- Executes the provided callback once for each element -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

indexOfTag()

- - -
-
- - -
- Returns array of found indices by tag -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

push()

- - -
-
- - -
- Adds a packet to the list. This is the only supported method of doing so; -writing to packetlist[i] directly will result in an error. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

read(A)

- - -
-
- - -
- Reads a stream of binary data and interprents it as a list of packets. -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
A - - -String - - - - binary string of bytes.
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

slice()

- - -
-
- - -
- Returns slice of packetlist -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

write() → {String}

- - -
-
- - -
- Creates a binary representation of openpgp objects contained within the -class instance. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A binary string of bytes containing valid openpgp packets. -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- -
- @@ -1088,13 +126,13 @@ class instance.
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:43 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST)
diff --git a/doc/packetlist.js.html b/doc/packetlist.js.html index 55c8aaa0..b2a0c965 100644 --- a/doc/packetlist.js.html +++ b/doc/packetlist.js.html @@ -35,6 +35,8 @@ * @module packet/packetlist */ +module.exports = Packetlist; + var packetParser = require('./packet.js'), packets = require('./all_packets.js'), enums = require('../enums.js'); @@ -42,166 +44,164 @@ var packetParser = require('./packet.js'), /** * @constructor */ -module.exports = function packetlist() { +function Packetlist() { /** The number of packets contained within the list. * @readonly * @type {Integer} */ this.length = 0; - - /** - * Reads a stream of binary data and interprents it as a list of packets. - * @param {String} A binary string of bytes. - */ - this.read = function (bytes) { - var i = 0; - - while (i < bytes.length) { - var parsed = packetParser.read(bytes, i, bytes.length - i); - i = parsed.offset; - - var tag = enums.read(enums.packet, parsed.tag); - var packet = new packets[tag](); - - this.push(packet); - - packet.read(parsed.packet); - } - } - - /** - * Creates a binary representation of openpgp objects contained within the - * class instance. - * @returns {String} A binary string of bytes containing valid openpgp packets. - */ - this.write = function () { - var bytes = ''; - - for (var i = 0; i < this.length; i++) { - var packetbytes = this[i].write(); - bytes += packetParser.writeHeader(this[i].tag, packetbytes.length); - bytes += packetbytes; - } - - return bytes; - } - - /** - * Adds a packet to the list. This is the only supported method of doing so; - * writing to packetlist[i] directly will result in an error. - */ - this.push = function (packet) { - if (!packet) return; - - packet.packets = packet.packets || new packetlist(); - - this[this.length] = packet; - this.length++; - } - - /** - * Creates a new packetList with all packets that pass the test implemented by the provided function. - */ - this.filter = function (callback) { - - var filtered = new packetlist(); - - for (var i = 0; i < this.length; i++) { - if (callback(this[i], i, this)) { - filtered.push(this[i]); - } - } - - return filtered; - } - - /** - * Creates a new packetList with all packets from the given types - */ - this.filterByTag = function () { - var args = Array.prototype.slice.call(arguments); - var filtered = new packetlist(); - var that = this; - - for (var i = 0; i < this.length; i++) { - if (args.some(function(packetType) {return that[i].tag == packetType})) { - filtered.push(this[i]); - } - } - - return filtered; - } - - /** - * Executes the provided callback once for each element - */ - this.forEach = function (callback) { - for (var i = 0; i < this.length; i++) { - callback(this[i]); - } - } - - /** - * Traverses packet tree and returns first matching packet - * @param {module:enums.packet} type The packet type - * @return {module:packet/packet|null} - */ - this.findPacket = function (type) { - var packetlist = this.filterByTag(type); - if (packetlist.length) { - return packetlist[0]; - } else { - var found = null; - for (var i = 0; i < this.length; i++) { - if (this[i].packets.length) { - found = this[i].packets.findPacket(type); - if (found) return found; - } - } - } - return null; - } - - /** - * Returns array of found indices by tag - */ - this.indexOfTag = function () { - var args = Array.prototype.slice.call(arguments); - var tagIndex = []; - var that = this; - for (var i = 0; i < this.length; i++) { - if (args.some(function(packetType) {return that[i].tag == packetType})) { - tagIndex.push(i); - } - } - return tagIndex; - } - - /** - * Returns slice of packetlist - */ - this.slice = function (begin, end) { - if (!end) { - end = this.length - } - var part = new packetlist(); - for (var i = begin; i < end; i++) { - part.push(this[i]); - } - return part; - } - - /** - * Concatenates packetlist or array of packets - */ - this.concat = function (packetlist) { - if (packetlist) { - for (var i = 0; i < packetlist.length; i++) { - this.push(packetlist[i]); - } - } - } - } +/** + * Reads a stream of binary data and interprents it as a list of packets. + * @param {String} A binary string of bytes. + */ +Packetlist.prototype.read = function (bytes) { + var i = 0; + + while (i < bytes.length) { + var parsed = packetParser.read(bytes, i, bytes.length - i); + i = parsed.offset; + + var tag = enums.read(enums.packet, parsed.tag); + var packet = packets.newPacketFromTag(tag); + + this.push(packet); + + packet.read(parsed.packet); + } +}; + +/** + * Creates a binary representation of openpgp objects contained within the + * class instance. + * @returns {String} A binary string of bytes containing valid openpgp packets. + */ +Packetlist.prototype.write = function () { + var bytes = ''; + + for (var i = 0; i < this.length; i++) { + var packetbytes = this[i].write(); + bytes += packetParser.writeHeader(this[i].tag, packetbytes.length); + bytes += packetbytes; + } + + return bytes; +}; + +/** + * Adds a packet to the list. This is the only supported method of doing so; + * writing to packetlist[i] directly will result in an error. + */ +Packetlist.prototype.push = function (packet) { + if (!packet) return; + + packet.packets = packet.packets || new Packetlist(); + + this[this.length] = packet; + this.length++; +}; + +/** +* Creates a new PacketList with all packets that pass the test implemented by the provided function. +*/ +Packetlist.prototype.filter = function (callback) { + + var filtered = new Packetlist(); + + for (var i = 0; i < this.length; i++) { + if (callback(this[i], i, this)) { + filtered.push(this[i]); + } + } + + return filtered; +}; + +/** +* Creates a new PacketList with all packets from the given types +*/ +Packetlist.prototype.filterByTag = function () { + var args = Array.prototype.slice.call(arguments); + var filtered = new Packetlist(); + var that = this; + + for (var i = 0; i < this.length; i++) { + if (args.some(function(packetType) {return that[i].tag == packetType;})) { + filtered.push(this[i]); + } + } + + return filtered; +}; + +/** +* Executes the provided callback once for each element +*/ +Packetlist.prototype.forEach = function (callback) { + for (var i = 0; i < this.length; i++) { + callback(this[i]); + } +}; + +/** + * Traverses packet tree and returns first matching packet + * @param {module:enums.packet} type The packet type + * @return {module:packet/packet|null} + */ +Packetlist.prototype.findPacket = function (type) { + var packetlist = this.filterByTag(type); + if (packetlist.length) { + return packetlist[0]; + } else { + var found = null; + for (var i = 0; i < this.length; i++) { + if (this[i].packets.length) { + found = this[i].packets.findPacket(type); + if (found) return found; + } + } + } + return null; +}; + +/** + * Returns array of found indices by tag + */ +Packetlist.prototype.indexOfTag = function () { + var args = Array.prototype.slice.call(arguments); + var tagIndex = []; + var that = this; + for (var i = 0; i < this.length; i++) { + if (args.some(function(packetType) {return that[i].tag == packetType;})) { + tagIndex.push(i); + } + } + return tagIndex; +}; + +/** + * Returns slice of packetlist + */ +Packetlist.prototype.slice = function (begin, end) { + if (!end) { + end = this.length; + } + var part = new Packetlist(); + for (var i = begin; i < end; i++) { + part.push(this[i]); + } + return part; +}; + +/** + * Concatenates packetlist or array of packets + */ +Packetlist.prototype.concat = function (packetlist) { + if (packetlist) { + for (var i = 0; i < packetlist.length; i++) { + this.push(packetlist[i]); + } + } +};
@@ -212,13 +212,13 @@ module.exports = function packetlist() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/pkcs1.html b/doc/pkcs1.html index 6b427486..289807a4 100644 --- a/doc/pkcs1.html +++ b/doc/pkcs1.html @@ -179,13 +179,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:41 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST)
diff --git a/doc/pkcs1.js.html b/doc/pkcs1.js.html index 8a7734d2..5b35af67 100644 --- a/doc/pkcs1.js.html +++ b/doc/pkcs1.js.html @@ -55,7 +55,7 @@ /** * ASN1 object identifiers for hashes (See RFC4880 5.2.2) */ -hash_headers = new Array(); +hash_headers = []; hash_headers[1] = [0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 ]; @@ -110,10 +110,10 @@ module.exports = { decode: function(message, len) { if (message.length < len) message = String.fromCharCode(0) + message; - if (message.length < 12 || message.charCodeAt(0) != 0 || message.charCodeAt(1) != 2) + if (message.length < 12 || message.charCodeAt(0) !== 0 || message.charCodeAt(1) != 2) return -1; var i = 2; - while (message.charCodeAt(i) != 0 && message.length > i) + while (message.charCodeAt(i) !== 0 && message.length > i) i++; return message.substring(i + 1, message.length); } @@ -132,14 +132,15 @@ module.exports = { var data2 = ""; data2 += String.fromCharCode(0x00); data2 += String.fromCharCode(0x01); - for (var i = 0; i < (keylength - hash_headers[algo].length - 3 - + var i; + for (i = 0; i < (keylength - hash_headers[algo].length - 3 - hash.getHashByteLength(algo)); i++) data2 += String.fromCharCode(0xff); data2 += String.fromCharCode(0x00); - for (var i = 0; i < hash_headers[algo].length; i++) + for (i = 0; i < hash_headers[algo].length; i++) data2 += String.fromCharCode(hash_headers[algo][i]); data2 += hash.digest(algo, data); @@ -153,12 +154,12 @@ module.exports = { */ decode: function(algo, data) { var i = 0; - if (data.charCodeAt(0) == 0) i++; + if (data.charCodeAt(0) === 0) i++; else if (data.charCodeAt(0) != 1) return -1; else i++; while (data.charCodeAt(i) == 0xFF) i++; - if (data.charCodeAt(i++) != 0) return -1; + if (data.charCodeAt(i++) !== 0) return -1; var j = 0; for (j = 0; j < hash_headers[algo].length && j + i < data.length; j++) { if (data.charCodeAt(j + i) != hash_headers[algo][j]) return -1; @@ -168,7 +169,7 @@ module.exports = { return data.substring(i); } } -} +}; @@ -179,13 +180,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/public_key-PublicKey.html b/doc/public_key-PublicKey.html new file mode 100644 index 00000000..45b26c2d --- /dev/null +++ b/doc/public_key-PublicKey.html @@ -0,0 +1,833 @@ + + + + + JSDoc: Class: PublicKey + + + + + + + + + + +
+ +

Class: PublicKey

+ + + + + +
+ +
+

+ packet/public_key~ + + PublicKey +

+ +
+ +
+
+ + + + +
+

new PublicKey()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

algorithm :module:enums.publicKey

+ + +
+
+ +
+ Public key algorithm +
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ + + +
+

created :Date

+ + +
+
+ +
+ Key creation date. +
+ + + +
Type:
+
    +
  • + +Date + + +
  • +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ + + +
+

mpi :module:type/mpi

+ + +
+
+ +
+ A list of multiprecision integers +
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

getFingerprint() → {String}

+ + +
+
+ + +
+ Calculates the fingerprint of the key +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ A string containing the fingerprint +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

getKeyId() → {String}

+ + +
+
+ + +
+ Calculates the key id of the key +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ A 8 byte key id +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

read(input) → {Object}

+ + +
+
+ + +
+ Internal Parser for public keys as specified in RFC 4880 section +5.5.2 Public-Key Packet Formats +called by read_tag<num> +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Input string to read the packet from
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ This object with attributes set by the parser +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + +
+ + + +
+

write() → {Object}

+ + +
+
+ + +
+ Same as write_private_key, but has less information because of +public key. +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ {body: [string]OpenPGP packet body contents, +header: [string] OpenPGP packet header, string: [string] header+body} +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + +
+ + + +
+

writeOld()

+ + +
+
+ + +
+ Write an old version packet - it's used by some of the internal routines. +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/public_key.html b/doc/public_key.html index 3a2d20cd..0082fb3d 100644 --- a/doc/public_key.html +++ b/doc/public_key.html @@ -290,13 +290,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:41 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST)
diff --git a/doc/public_key.js.html b/doc/public_key.js.html index 7c71f987..e318a777 100644 --- a/doc/public_key.js.html +++ b/doc/public_key.js.html @@ -57,6 +57,8 @@ * @module packet/public_key */ +module.exports = PublicKey; + var util = require('../util'), type_mpi = require('../type/mpi.js'), type_keyid = require('../type/keyid.js'), @@ -66,7 +68,7 @@ var util = require('../util'), /** * @constructor */ -module.exports = function public_key() { +function PublicKey() { this.version = 4; /** Key creation date. * @type {Date} */ @@ -79,138 +81,137 @@ module.exports = function public_key() { this.algorithm = 'rsa_sign'; // time in days (V3 only) this.expirationTimeV3 = 0; +} +/** + * Internal Parser for public keys as specified in RFC 4880 section + * 5.5.2 Public-Key Packet Formats + * called by read_tag<num> + * @param {String} input Input string to read the packet from + * @return {Object} This object with attributes set by the parser + */ +PublicKey.prototype.read = function (bytes) { + var pos = 0; + // A one-octet version number (3 or 4). + this.version = bytes.charCodeAt(pos++); - /** - * Internal Parser for public keys as specified in RFC 4880 section - * 5.5.2 Public-Key Packet Formats - * called by read_tag<num> - * @param {String} input Input string to read the packet from - * @return {Object} This object with attributes set by the parser - */ - this.read = function (bytes) { - var pos = 0; - // A one-octet version number (3 or 4). - this.version = bytes.charCodeAt(pos++); + if (this.version == 3 || this.version == 4) { + // - A four-octet number denoting the time that the key was created. + this.created = util.readDate(bytes.substr(pos, 4)); + pos += 4; - if (this.version == 3 || this.version == 4) { - // - A four-octet number denoting the time that the key was created. - this.created = util.readDate(bytes.substr(pos, 4)); - pos += 4; - - if (this.version == 3) { - // - A two-octet number denoting the time in days that this key is - // valid. If this number is zero, then it does not expire. - this.expirationTimeV3 = util.readNumber(bytes.substr(pos, 2)); - pos += 2; - } - - // - A one-octet number denoting the public-key algorithm of this key. - this.algorithm = enums.read(enums.publicKey, bytes.charCodeAt(pos++)); - - var mpicount = crypto.getPublicMpiCount(this.algorithm); - this.mpi = []; - - var bmpi = bytes.substr(pos); - var p = 0; - - for (var i = 0; i < mpicount && p < bmpi.length; i++) { - - this.mpi[i] = new type_mpi(); - - p += this.mpi[i].read(bmpi.substr(p)) - - if (p > bmpi.length) { - throw new Error('Error reading MPI @:' + p); - } - } - - return p + 6; - } 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. - * @return {Object} {body: [string]OpenPGP packet body contents, - * header: [string] OpenPGP packet header, string: [string] header+body} - */ - this.write = function () { - // Version - var result = String.fromCharCode(this.version); - result += util.writeDate(this.created); if (this.version == 3) { - result += util.writeNumber(this.expirationTimeV3, 2); + // - A two-octet number denoting the time in days that this key is + // valid. If this number is zero, then it does not expire. + this.expirationTimeV3 = util.readNumber(bytes.substr(pos, 2)); + pos += 2; } - result += String.fromCharCode(enums.write(enums.publicKey, this.algorithm)); + + // - A one-octet number denoting the public-key algorithm of this key. + this.algorithm = enums.read(enums.publicKey, bytes.charCodeAt(pos++)); var mpicount = crypto.getPublicMpiCount(this.algorithm); + this.mpi = []; - for (var i = 0; i < mpicount; i++) { - result += this.mpi[i].write(); - } + var bmpi = bytes.substr(pos); + var p = 0; - return result; - }; + for (var i = 0; i < mpicount && p < bmpi.length; i++) { - /** - * Alias of write() - * @function module:packet/public_key#writePublicKey - * @see module:packet/public_key#write - */ - this.writePublicKey = this.write; + this.mpi[i] = new type_mpi(); - /** - * Write an old version packet - it's used by some of the internal routines. - */ - this.writeOld = function () { - var bytes = this.writePublicKey(); + p += this.mpi[i].read(bmpi.substr(p)); - return String.fromCharCode(0x99) + - util.writeNumber(bytes.length, 2) + - bytes; - }; - - /** - * Calculates the key id of the key - * @return {String} A 8 byte key id - */ - this.getKeyId = function () { - var keyid = new type_keyid(); - if (this.version == 4) { - keyid.read(this.getFingerprint().substr(12, 8)); - } else if (this.version == 3) { - keyid.read(this.mpi[0].write().substr(-8)); - } - return keyid; - }; - - /** - * Calculates the fingerprint of the key - * @return {String} A string containing the fingerprint - */ - this.getFingerprint = function () { - var toHash = ''; - if (this.version == 4) { - toHash = this.writeOld(); - return crypto.hash.sha1(toHash); - } else if (this.version == 3) { - var mpicount = crypto.getPublicMpiCount(this.algorithm); - for (var i = 0; i < mpicount; i++) { - toHash += this.mpi[i].toBytes(); + if (p > bmpi.length) { + throw new Error('Error reading MPI @:' + p); } - return crypto.hash.md5(toHash) } - }; + + return p + 6; + } 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 + */ +PublicKey.prototype.readPublicKey = PublicKey.prototype.read; + +/** + * Same as write_private_key, but has less information because of + * public key. + * @return {Object} {body: [string]OpenPGP packet body contents, + * header: [string] OpenPGP packet header, string: [string] header+body} + */ +PublicKey.prototype.write = function () { + // Version + var result = String.fromCharCode(this.version); + result += util.writeDate(this.created); + if (this.version == 3) { + result += util.writeNumber(this.expirationTimeV3, 2); + } + result += String.fromCharCode(enums.write(enums.publicKey, this.algorithm)); + + var mpicount = crypto.getPublicMpiCount(this.algorithm); + + for (var i = 0; i < mpicount; i++) { + result += this.mpi[i].write(); + } + + return result; +}; + +/** + * Alias of write() + * @function module:packet/public_key#writePublicKey + * @see module:packet/public_key#write + */ +PublicKey.prototype.writePublicKey = PublicKey.prototype.write; + +/** + * Write an old version packet - it's used by some of the internal routines. + */ +PublicKey.prototype.writeOld = function () { + var bytes = this.writePublicKey(); + + return String.fromCharCode(0x99) + + util.writeNumber(bytes.length, 2) + + bytes; +}; + +/** + * Calculates the key id of the key + * @return {String} A 8 byte key id + */ +PublicKey.prototype.getKeyId = function () { + var keyid = new type_keyid(); + if (this.version == 4) { + keyid.read(this.getFingerprint().substr(12, 8)); + } else if (this.version == 3) { + keyid.read(this.mpi[0].write().substr(-8)); + } + return keyid; +}; + +/** + * Calculates the fingerprint of the key + * @return {String} A string containing the fingerprint + */ +PublicKey.prototype.getFingerprint = function () { + var toHash = ''; + if (this.version == 4) { + toHash = this.writeOld(); + return crypto.hash.sha1(toHash); + } else if (this.version == 3) { + var mpicount = crypto.getPublicMpiCount(this.algorithm); + for (var i = 0; i < mpicount; i++) { + toHash += this.mpi[i].toBytes(); + } + return crypto.hash.md5(toHash); + } }; @@ -222,13 +223,13 @@ module.exports = function public_key() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/public_key_.html b/doc/public_key_.html index dd604703..c5b7eaa1 100644 --- a/doc/public_key_.html +++ b/doc/public_key_.html @@ -35,6 +35,8 @@
+ +
Implementation of the Key Material Packet (Tag 5,6,7,14)

@@ -44,74 +46,6 @@ private key. There are four variants of this packet type, and two major versions. Consequently, this section is complex.
-
-

new (require("packet/public_key"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -172,535 +106,23 @@ major versions. Consequently, this section is complex.
- - - - -

Members

+

Classes

- -
-

algorithm :module:enums.publicKey

- - -
-
- -
- Public key algorithm -
- - - -
Type:
- - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

created :Date

- - -
-
- -
- Key creation date. -
- - - -
Type:
-
    -
  • - -Date - - -
  • -
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

mpi :module:type/mpi

- - -
-
- -
- A list of multiprecision integers -
- - - -
Type:
- - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
PublicKey
+
+ + + +

Methods

-
-

getFingerprint() → {String}

- - -
-
- - -
- Calculates the fingerprint of the key -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A string containing the fingerprint -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

getKeyId() → {String}

- - -
-
- - -
- Calculates the key id of the key -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A 8 byte key id -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

read(input) → {Object}

- - -
-
- - -
- Internal Parser for public keys as specified in RFC 4880 section -5.5.2 Public-Key Packet Formats -called by read_tag<num> -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Input string to read the packet from
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- This object with attributes set by the parser -
- - - -
-
- Type -
-
- -Object - - -
-
- - - - -
- - -

readPublicKey()

@@ -743,7 +165,7 @@ called by read_tag<num>
Source:
@@ -753,7 +175,7 @@ called by read_tag<num>
See:
@@ -773,168 +195,6 @@ called by read_tag<num> - - - - -
-

write() → {Object}

- - -
-
- - -
- Same as write_private_key, but has less information because of -public key. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- {body: [string]OpenPGP packet body contents, -header: [string] OpenPGP packet header, string: [string] header+body} -
- - - -
-
- Type -
-
- -Object - - -
-
- - - - -
- - - -
-

writeOld()

- - -
-
- - -
- Write an old version packet - it's used by some of the internal routines. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - -
@@ -981,7 +241,7 @@ header: [string] OpenPGP packet header, string: [string] header+body}
Source:
@@ -991,7 +251,7 @@ header: [string] OpenPGP packet header, string: [string] header+body}
See:
@@ -1029,13 +289,13 @@ header: [string] OpenPGP packet header, string: [string] header+body}
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST)
diff --git a/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html b/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html new file mode 100644 index 00000000..b8143456 --- /dev/null +++ b/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html @@ -0,0 +1,776 @@ + + + + + JSDoc: Class: PublicKeyEncryptedSessionKey + + + + + + + + + + +
+ +

Class: PublicKeyEncryptedSessionKey

+ + + + + +
+ +
+

+ packet/public_key_encrypted_session_key~ + + PublicKeyEncryptedSessionKey +

+ +
+ +
+
+ + + + +
+

new PublicKeyEncryptedSessionKey()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

encrypted :Array.<module:type/mpi>

+ + +
+
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

decrypt(key) → {String}

+ + +
+
+ + +
+ Decrypts the session key (only for public key encrypted session key +packets (tag 1) +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +module:packet/secret_key + + + + Private key with secMPIs unlocked
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ The unencrypted session key +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

read(input, position, len) → {module:packet/public_key_encrypted_session_key}

+ + +
+
+ + +
+ Parsing function for a publickey encrypted session key packet (tag 1). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Payload of a tag 1 packet
position + + +Integer + + + + Position to start reading from the input string
len + + +Integer + + + + Length of the packet or the remaining length of + input at position
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ Object representation +
+ + + +
+
+ Type +
+
+ +module:packet/public_key_encrypted_session_key + + +
+
+ + + + +
+ + + +
+

write(publicKeyId, publicMPIs, pubalgo, symmalgo, sessionkey) → {String}

+ + +
+
+ + +
+ Create a string representation of a tag 1 packet +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
publicKeyId + + +String + + + + The public key id corresponding to publicMPIs key as string
publicMPIs + + +Array.<module:type/mpi> + + + + Multiprecision integer objects describing the public key
pubalgo + + +Integer + + + + The corresponding public key algorithm // See RFC4880 9.1
symmalgo + + +Integer + + + + The symmetric cipher algorithm used to encrypt the data + within an encrypteddatapacket or encryptedintegrity- + protecteddatapacket + following this packet //See RFC4880 9.2
sessionkey + + +String + + + + A string of randombytes representing the session key
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ The string representation +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) +
+ + + + + \ 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 b5864e74..4acc8d27 100644 --- a/doc/public_key_encrypted_session_key.html +++ b/doc/public_key_encrypted_session_key.html @@ -35,6 +35,8 @@
+ +
Public-Key Encrypted Session Key Packets (Tag 1)

@@ -51,74 +53,6 @@ public key, decrypts the session key, and then uses the session key to decrypt the message.
-
-

new (require("packet/public_key_encrypted_session_key"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -179,640 +113,19 @@ decrypt the message.
- - - - -

Members

+

Classes

- -
-

encrypted :Array.<module:type/mpi>

- - -
-
- - - -
Type:
- - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
PublicKeyEncryptedSessionKey
+
-

Methods

- -
- -
-

decrypt(key) → {String}

-
-
-
- Decrypts the session key (only for public key encrypted session key -packets (tag 1) -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
key - - -module:packet/secret_key - - - - Private key with secMPIs unlocked
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- The unencrypted session key -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

read(input, position, len) → {module:packet/public_key_encrypted_session_key}

- - -
-
- - -
- Parsing function for a publickey encrypted session key packet (tag 1). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Payload of a tag 1 packet
position - - -Integer - - - - Position to start reading from the input string
len - - -Integer - - - - Length of the packet or the remaining length of - input at position
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- Object representation -
- - - -
-
- Type -
-
- -module:packet/public_key_encrypted_session_key - - -
-
- - - - -
- - - -
-

write(publicKeyId, publicMPIs, pubalgo, symmalgo, sessionkey) → {String}

- - -
-
- - -
- Create a string representation of a tag 1 packet -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
publicKeyId - - -String - - - - The public key id corresponding to publicMPIs key as string
publicMPIs - - -Array.<module:type/mpi> - - - - Multiprecision integer objects describing the public key
pubalgo - - -Integer - - - - The corresponding public key algorithm // See RFC4880 9.1
symmalgo - - -Integer - - - - The symmetric cipher algorithm used to encrypt the data - within an encrypteddatapacket or encryptedintegrity- - protecteddatapacket - following this packet //See RFC4880 9.2
sessionkey - - -String - - - - A string of randombytes representing the session key
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- The string representation -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- -
- @@ -827,13 +140,13 @@ packets (tag 1)
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST)
diff --git a/doc/public_key_encrypted_session_key.js.html b/doc/public_key_encrypted_session_key.js.html index 8f23c2da..68da00c6 100644 --- a/doc/public_key_encrypted_session_key.js.html +++ b/doc/public_key_encrypted_session_key.js.html @@ -64,6 +64,8 @@ * @module packet/public_key_encrypted_session_key */ +module.exports = PublicKeyEncryptedSessionKey; + var type_keyid = require('../type/keyid.js'), util = require('../util'), type_mpi = require('../type/mpi.js'), @@ -73,7 +75,7 @@ var type_keyid = require('../type/keyid.js'), /** * @constructor */ -module.exports = function public_key_encrypted_session_key() { +function PublicKeyEncryptedSessionKey() { this.version = 3; this.publicKeyId = new type_keyid(); @@ -84,128 +86,128 @@ module.exports = function public_key_encrypted_session_key() { /** @type {Array<module:type/mpi>} */ this.encrypted = []; +} - /** - * Parsing function for a publickey encrypted session key packet (tag 1). - * - * @param {String} input Payload of a tag 1 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/public_key_encrypted_session_key} Object representation - */ - this.read = function (bytes) { +/** + * Parsing function for a publickey encrypted session key packet (tag 1). + * + * @param {String} input Payload of a tag 1 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/public_key_encrypted_session_key} Object representation + */ +PublicKeyEncryptedSessionKey.prototype.read = function (bytes) { - this.version = bytes.charCodeAt(0); - this.publicKeyId.read(bytes.substr(1)); - this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(9)); + this.version = bytes.charCodeAt(0); + this.publicKeyId.read(bytes.substr(1)); + this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(9)); - var i = 10; + var i = 10; - var integerCount = (function(algo) { - switch (algo) { - case 'rsa_encrypt': - case 'rsa_encrypt_sign': - return 1; + var integerCount = (function(algo) { + switch (algo) { + case 'rsa_encrypt': + case 'rsa_encrypt_sign': + return 1; - case 'elgamal': - return 2; + case 'elgamal': + return 2; - default: - throw new Error("Invalid algorithm."); - } - })(this.publicKeyAlgorithm); - - this.encrypted = []; - - for (var j = 0; j < integerCount; j++) { - var mpi = new type_mpi(); - i += mpi.read(bytes.substr(i)); - this.encrypted.push(mpi); + default: + throw new Error("Invalid algorithm."); } - }; + })(this.publicKeyAlgorithm); - /** - * Create a string representation of a tag 1 packet - * - * @param {String} publicKeyId - * The public key id corresponding to publicMPIs key as string - * @param {Array<module:type/mpi>} publicMPIs - * Multiprecision integer objects describing the public key - * @param {Integer} pubalgo - * The corresponding public key algorithm // See RFC4880 9.1 - * @param {Integer} symmalgo - * The symmetric cipher algorithm used to encrypt the data - * within an encrypteddatapacket or encryptedintegrity- - * protecteddatapacket - * following this packet //See RFC4880 9.2 - * @param {String} sessionkey - * A string of randombytes representing the session key - * @return {String} The string representation - */ - this.write = function () { - - var result = String.fromCharCode(this.version); - result += this.publicKeyId.write(); - result += String.fromCharCode( - enums.write(enums.publicKey, this.publicKeyAlgorithm)); - - for (var i = 0; i < this.encrypted.length; i++) { - result += this.encrypted[i].write() - } - - return result; - }; - - this.encrypt = function (key) { - var data = String.fromCharCode( - enums.write(enums.symmetric, this.sessionKeyAlgorithm)); - - data += this.sessionKey; - var checksum = util.calc_checksum(this.sessionKey); - data += util.writeNumber(checksum, 2); + this.encrypted = []; + for (var j = 0; j < integerCount; j++) { var mpi = new type_mpi(); - mpi.fromBytes(crypto.pkcs1.eme.encode( - data, - key.mpi[0].byteLength())); + i += mpi.read(bytes.substr(i)); + this.encrypted.push(mpi); + } +}; - this.encrypted = crypto.publicKeyEncrypt( - this.publicKeyAlgorithm, - key.mpi, - mpi); - }; +/** + * Create a string representation of a tag 1 packet + * + * @param {String} publicKeyId + * The public key id corresponding to publicMPIs key as string + * @param {Array<module:type/mpi>} publicMPIs + * Multiprecision integer objects describing the public key + * @param {Integer} pubalgo + * The corresponding public key algorithm // See RFC4880 9.1 + * @param {Integer} symmalgo + * The symmetric cipher algorithm used to encrypt the data + * within an encrypteddatapacket or encryptedintegrity- + * protecteddatapacket + * following this packet //See RFC4880 9.2 + * @param {String} sessionkey + * A string of randombytes representing the session key + * @return {String} The string representation + */ +PublicKeyEncryptedSessionKey.prototype.write = function () { - /** - * Decrypts the session key (only for public key encrypted session key - * packets (tag 1) - * - * @param {module:packet/secret_key} key - * Private key with secMPIs unlocked - * @return {String} The unencrypted session key - */ - this.decrypt = function (key) { - var result = crypto.publicKeyDecrypt( - this.publicKeyAlgorithm, - key.mpi, - this.encrypted).toBytes(); + var result = String.fromCharCode(this.version); + result += this.publicKeyId.write(); + result += String.fromCharCode( + enums.write(enums.publicKey, this.publicKeyAlgorithm)); - var checksum = util.readNumber(result.substr(result.length - 2)); + for (var i = 0; i < this.encrypted.length; i++) { + result += this.encrypted[i].write(); + } - var decoded = crypto.pkcs1.eme.decode( - result, - key.mpi[0].byteLength()); + return result; +}; - var key = decoded.substring(1, decoded.length - 2); +PublicKeyEncryptedSessionKey.prototype.encrypt = function (key) { + var data = String.fromCharCode( + enums.write(enums.symmetric, this.sessionKeyAlgorithm)); - if (checksum != util.calc_checksum(key)) { - throw new Error('Checksum mismatch'); - } else { - this.sessionKey = key; - this.sessionKeyAlgorithm = - enums.read(enums.symmetric, decoded.charCodeAt(0)); - } - }; + data += this.sessionKey; + var checksum = util.calc_checksum(this.sessionKey); + data += util.writeNumber(checksum, 2); + + var mpi = new type_mpi(); + mpi.fromBytes(crypto.pkcs1.eme.encode( + data, + key.mpi[0].byteLength())); + + this.encrypted = crypto.publicKeyEncrypt( + this.publicKeyAlgorithm, + key.mpi, + mpi); +}; + +/** + * Decrypts the session key (only for public key encrypted session key + * packets (tag 1) + * + * @param {module:packet/secret_key} key + * Private key with secMPIs unlocked + * @return {String} The unencrypted session key + */ +PublicKeyEncryptedSessionKey.prototype.decrypt = function (key) { + var result = crypto.publicKeyDecrypt( + this.publicKeyAlgorithm, + key.mpi, + this.encrypted).toBytes(); + + var checksum = util.readNumber(result.substr(result.length - 2)); + + var decoded = crypto.pkcs1.eme.decode( + result, + key.mpi[0].byteLength()); + + key = decoded.substring(1, decoded.length - 2); + + if (checksum != util.calc_checksum(key)) { + throw new Error('Checksum mismatch'); + } else { + this.sessionKey = key; + this.sessionKeyAlgorithm = + enums.read(enums.symmetric, decoded.charCodeAt(0)); + } };
@@ -217,13 +219,13 @@ module.exports = function public_key_encrypted_session_key() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/public_subkey-PublicSubkey.html b/doc/public_subkey-PublicSubkey.html new file mode 100644 index 00000000..56c22403 --- /dev/null +++ b/doc/public_subkey-PublicSubkey.html @@ -0,0 +1,320 @@ + + + + + JSDoc: Class: PublicSubkey + + + + + + + + + + +
+ +

Class: PublicSubkey

+ + + + + +
+ +
+

+ packet/public_subkey~ + + PublicSubkey +

+ +
+ +
+
+ + + + +
+

new PublicSubkey()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

readPublicKey()

+ + +
+
+ + +
+ Alias of read() +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+
    +
  • module:packet/public_key#read
  • +
+
+ + + +
+ + + + + + + + + + + + + +
+ + + +
+

writePublicKey()

+ + +
+
+ + +
+ Alias of write() +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+
    +
  • module:packet/public_key#write
  • +
+
+ + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/public_subkey.html b/doc/public_subkey.html index 47434920..4c9795d7 100644 --- a/doc/public_subkey.html +++ b/doc/public_subkey.html @@ -35,72 +35,6 @@
- - -
-

new (require("packet/public_subkey"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - @@ -157,899 +91,19 @@ - - - - -

Members

+

Classes

- -
-

algorithm :module:enums.publicKey

- - -
-
- -
- Public key algorithm -
- - - -
Type:
- - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

created :Date

- - -
-
- -
- Key creation date. -
- - - -
Type:
-
    -
  • - -Date - - -
  • -
- - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

mpi :module:type/mpi

- - -
-
- -
- A list of multiprecision integers -
- - - -
Type:
- - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
PublicSubkey
+
-

Methods

- -
- -
-

getFingerprint() → {String}

-
-
-
- Calculates the fingerprint of the key -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A string containing the fingerprint -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

getKeyId() → {String}

- - -
-
- - -
- Calculates the key id of the key -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A 8 byte key id -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

read(input) → {Object}

- - -
-
- - -
- Internal Parser for public keys as specified in RFC 4880 section -5.5.2 Public-Key Packet Formats -called by read_tag<num> -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Input string to read the packet from
- - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- This object with attributes set by the parser -
- - - -
-
- Type -
-
- -Object - - -
-
- - - - -
- - - -
-

readPublicKey()

- - -
-
- - -
- Alias of read() -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - -
See:
-
- -
- - - -
- - - - - - - - - - - - - -
- - - -
-

write() → {Object}

- - -
-
- - -
- Same as write_private_key, but has less information because of -public key. -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- {body: [string]OpenPGP packet body contents, -header: [string] OpenPGP packet header, string: [string] header+body} -
- - - -
-
- Type -
-
- -Object - - -
-
- - - - -
- - - -
-

writeOld()

- - -
-
- - -
- Write an old version packet - it's used by some of the internal routines. -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

writePublicKey()

- - -
-
- - -
- Alias of write() -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - -
See:
-
- -
- - - -
- - - - - - - - - - - - - -
- -
- @@ -1064,13 +118,13 @@ header: [string] OpenPGP packet header, string: [string] header+body}

- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST)
diff --git a/doc/public_subkey.js.html b/doc/public_subkey.js.html index 95da9223..5722a340 100644 --- a/doc/public_subkey.js.html +++ b/doc/public_subkey.js.html @@ -47,15 +47,20 @@ * @module packet/public_subkey */ +module.exports = PublicSubkey; + var publicKey = require('./public_key.js'); /** * @constructor * @extends module:packet/public_key */ -module.exports = function public_subkey() { +function PublicSubkey() { publicKey.call(this); -} +}; + +PublicSubkey.prototype = new publicKey(); +PublicSubkey.prototype.constructor = PublicSubkey();
@@ -66,13 +71,13 @@ module.exports = function public_subkey() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/random.html b/doc/random.html index c5543d9c..167737a2 100644 --- a/doc/random.html +++ b/doc/random.html @@ -717,13 +717,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:41 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST)
diff --git a/doc/random.js.html b/doc/random.js.html index bbe2c829..a352888a 100644 --- a/doc/random.js.html +++ b/doc/random.js.html @@ -144,13 +144,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/ripe-md.html b/doc/ripe-md.html index 40e1b351..fa61d092 100644 --- a/doc/ripe-md.html +++ b/doc/ripe-md.html @@ -105,13 +105,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:41 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST)
diff --git a/doc/ripe-md.js.html b/doc/ripe-md.js.html index a9e5d17b..f4e8d93f 100644 --- a/doc/ripe-md.js.html +++ b/doc/ripe-md.js.html @@ -52,7 +52,7 @@ */ var RMDsize = 160; -var X = new Array(); +var X = []; function ROL(x, n) { return new Number((x << n) | (x >>> (32 - n))); @@ -125,7 +125,7 @@ function mixOneRound(a, b, c, d, e, x, s, roundNumber) { d &= 0xffffffff; e &= 0xffffffff; - var retBlock = new Array(); + var retBlock = []; retBlock[0] = a; retBlock[1] = b; retBlock[2] = c; @@ -172,19 +172,21 @@ var indexes = [ ]; function compress(MDbuf, X) { - blockA = new Array(); - blockB = new Array(); + blockA = []; + blockB = []; var retBlock; - for (var i = 0; i < 5; i++) { + var i, j; + + for (i = 0; i < 5; i++) { blockA[i] = new Number(MDbuf[i]); blockB[i] = new Number(MDbuf[i]); } var step = 0; - for (var j = 0; j < 5; j++) { - for (var i = 0; i < 16; i++) { + for (j = 0; j < 5; j++) { + for (i = 0; i < 16; i++) { retBlock = mixOneRound( blockA[(step + 0) % 5], blockA[(step + 1) % 5], @@ -206,8 +208,8 @@ function compress(MDbuf, X) { } step = 0; - for (var j = 5; j < 10; j++) { - for (var i = 0; i < 16; i++) { + for (j = 5; j < 10; j++) { + for (i = 0; i < 16; i++) { retBlock = mixOneRound( blockB[(step + 0) % 5], blockB[(step + 1) % 5], @@ -255,7 +257,7 @@ function MDfinish(MDbuf, strptr, lswlen, mswlen) { if ((lswlen & 63) > 55) { compress(MDbuf, X); - var X = new Array(16); + X = new Array(16); zeroX(X); } @@ -286,9 +288,9 @@ function RMD(message) { var X = new Array(16); zeroX(X); - var j = 0; - for (var nbytes = length; nbytes > 63; nbytes -= 64) { - for (var i = 0; i < 16; i++) { + var i, j = 0; + for (nbytes = length; nbytes > 63; nbytes -= 64) { + for (i = 0; i < 16; i++) { X[i] = BYTES_TO_DWORD(message.substr(j, 4)); j += 4; } @@ -297,7 +299,7 @@ function RMD(message) { MDfinish(MDbuf, message.substr(j), length, 0); - for (var i = 0; i < RMDsize / 8; i += 4) { + for (i = 0; i < RMDsize / 8; i += 4) { hashcode[i] = MDbuf[i >>> 2] & 255; hashcode[i + 1] = (MDbuf[i >>> 2] >>> 8) & 255; hashcode[i + 2] = (MDbuf[i >>> 2] >>> 16) & 255; @@ -330,13 +332,13 @@ module.exports = RMDstring;
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/rsa.html b/doc/rsa.html index e71cdc92..8aa90457 100644 --- a/doc/rsa.html +++ b/doc/rsa.html @@ -115,13 +115,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:41 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST)
diff --git a/doc/rsa.js.html b/doc/rsa.js.html index 08b16e34..d0858ff0 100644 --- a/doc/rsa.js.html +++ b/doc/rsa.js.html @@ -85,7 +85,7 @@ function RSA() { util.print_debug("rsa.js decrypt\nxpn:" + util.hexstrdump(xp.toMPI()) + "\nxqn:" + util.hexstrdump(xq.toMPI())); var t = xq.subtract(xp); - if (t[0] == 0) { + if (t[0] === 0) { t = xp.subtract(xq); t = t.multiply(u).mod(q); t = q.subtract(t); @@ -140,12 +140,12 @@ function RSA() { for (;;) { for (;;) { key.p = new BigInteger(B - qs, 1, rng); - if (key.p.subtract(BigInteger.ONE).gcd(key.ee).compareTo(BigInteger.ONE) == 0 && key.p.isProbablePrime(10)) + if (key.p.subtract(BigInteger.ONE).gcd(key.ee).compareTo(BigInteger.ONE) === 0 && key.p.isProbablePrime(10)) break; } for (;;) { key.q = new BigInteger(qs, 1, rng); - if (key.q.subtract(BigInteger.ONE).gcd(key.ee).compareTo(BigInteger.ONE) == 0 && key.q.isProbablePrime(10)) + if (key.q.subtract(BigInteger.ONE).gcd(key.ee).compareTo(BigInteger.ONE) === 0 && key.q.isProbablePrime(10)) break; } if (key.p.compareTo(key.q) <= 0) { @@ -156,7 +156,7 @@ function RSA() { var p1 = key.p.subtract(BigInteger.ONE); var q1 = key.q.subtract(BigInteger.ONE); var phi = p1.multiply(q1); - if (phi.gcd(key.ee).compareTo(BigInteger.ONE) == 0) { + if (phi.gcd(key.ee).compareTo(BigInteger.ONE) === 0) { key.n = key.p.multiply(key.q); key.d = key.ee.modInverse(phi); key.dmp1 = key.d.mod(p1); @@ -187,13 +187,13 @@ module.exports = RSA;
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/s2k-S2k.html b/doc/s2k-S2k.html new file mode 100644 index 00000000..b8c79db5 --- /dev/null +++ b/doc/s2k-S2k.html @@ -0,0 +1,711 @@ + + + + + JSDoc: Class: S2k + + + + + + + + + + +
+ +

Class: S2k

+ + + + + +
+ +
+

+ type/s2k~ + + S2k +

+ +
+ +
+
+ + + + +
+

new S2k()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

algorithm :module:enums.hash

+ + +
+
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ + + +
+

salt :String

+ + +
+
+ +
+ Eight bytes of salt in a binary string. +
+ + + +
Type:
+
    +
  • + +String + + +
  • +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ + + +
+

type :module:enums.s2k

+ + +
+
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

produce_key(passphrase) → {String}

+ + +
+
+ + +
+ Produces a key using the specified passphrase and the defined +hashAlgorithm +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
passphrase + + +String + + + + Passphrase containing user input
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ Produced key with a length corresponding to +hashAlgorithm hash length +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

read(input) → {Integer}

+ + +
+
+ + +
+ Parsing function for a string-to-key specifier (RFC 4880 3.7). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Payload of string-to-key specifier
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ Actual length of the object +
+ + + +
+
+ Type +
+
+ +Integer + + +
+
+ + + + +
+ + + +
+

write() → {String}

+ + +
+
+ + +
+ writes an s2k hash based on the inputs. +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ Produced key of hashAlgorithm hash length +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/s2k.html b/doc/s2k.html index dc10b2d5..c67351b0 100644 --- a/doc/s2k.html +++ b/doc/s2k.html @@ -35,6 +35,8 @@
+ +
Implementation of the String-to-key specifier (RFC4880 3.7)

@@ -45,74 +47,6 @@ private keyring, and to convert passphrases to encryption keys for symmetrically encrypted messages.
-
-

new (require("type/s2k"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -169,575 +103,19 @@ symmetrically encrypted messages.
- - - - -

Members

+

Classes

- -
-

algorithm :module:enums.hash

- - -
-
- - - -
Type:
- - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

salt :String

- - -
-
- -
- Eight bytes of salt in a binary string. -
- - - -
Type:
-
    -
  • - -String - - -
  • -
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

type :module:enums.s2k

- - -
-
- - - -
Type:
- - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
S2k
+
-

Methods

- -
- -
-

produce_key(passphrase) → {String}

-
-
-
- Produces a key using the specified passphrase and the defined -hashAlgorithm -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
passphrase - - -String - - - - Passphrase containing user input
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- Produced key with a length corresponding to -hashAlgorithm hash length -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

read(input) → {Integer}

- - -
-
- - -
- Parsing function for a string-to-key specifier (RFC 4880 3.7). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Payload of string-to-key specifier
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- Actual length of the object -
- - - -
-
- Type -
-
- -Integer - - -
-
- - - - -
- - - -
-

write() → {String}

- - -
-
- - -
- writes an s2k hash based on the inputs. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- Produced key of hashAlgorithm hash length -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- -
- @@ -752,13 +130,13 @@ hashAlgorithm hash length
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:45 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/s2k.js.html b/doc/s2k.js.html index a3117f95..abc9bb21 100644 --- a/doc/s2k.js.html +++ b/doc/s2k.js.html @@ -56,6 +56,8 @@ * @module type/s2k */ +module.exports = S2k; + var enums = require('../enums.js'), util = require('../util'), crypto = require('../crypto'); @@ -63,7 +65,7 @@ var enums = require('../enums.js'), /** * @constructor */ -module.exports = function s2k() { +function S2k() { /** @type {module:enums.hash} */ this.algorithm = 'sha256'; /** @type {module:enums.s2k} */ @@ -73,137 +75,135 @@ module.exports = function s2k() { * @type {String} */ this.salt = crypto.random.getRandomBytes(8); +} - +S2k.prototype.get_count = function () { // 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). - * @param {String} input Payload of string-to-key specifier - * @return {Integer} Actual length of the object - */ - this.read = function (bytes) { - var i = 0; - this.type = enums.read(enums.s2k, bytes.charCodeAt(i++)); - this.algorithm = enums.read(enums.hash, bytes.charCodeAt(i++)); +/** + * Parsing function for a string-to-key specifier (RFC 4880 3.7). + * @param {String} input Payload of string-to-key specifier + * @return {Integer} Actual length of the object + */ +S2k.prototype.read = function (bytes) { + var i = 0; + this.type = enums.read(enums.s2k, bytes.charCodeAt(i++)); + this.algorithm = enums.read(enums.hash, bytes.charCodeAt(i++)); - switch (this.type) { - case 'simple': - break; + switch (this.type) { + case 'simple': + break; - case 'salted': - this.salt = bytes.substr(i, 8); - i += 8; - break; + case 'salted': + this.salt = bytes.substr(i, 8); + i += 8; + break; - case 'iterated': - this.salt = bytes.substr(i, 8); - i += 8; + case 'iterated': + this.salt = bytes.substr(i, 8); + i += 8; - // Octet 10: count, a one-octet, coded value - this.c = bytes.charCodeAt(i++); - break; + // Octet 10: count, a one-octet, coded value + this.c = bytes.charCodeAt(i++); + break; - case 'gnu': - if (bytes.substr(i, 3) == "GNU") { - i += 3; // GNU - var gnuExtType = 1000 + bytes.charCodeAt(i++); - if (gnuExtType == 1001) { - this.type = gnuExtType; - // GnuPG extension mode 1001 -- don't write secret key at all - } else { - throw new Error("Unknown s2k gnu protection mode."); - } + case 'gnu': + if (bytes.substr(i, 3) == "GNU") { + i += 3; // GNU + var gnuExtType = 1000 + bytes.charCodeAt(i++); + if (gnuExtType == 1001) { + this.type = gnuExtType; + // GnuPG extension mode 1001 -- don't write secret key at all } else { - throw new Error("Unknown s2k type."); + throw new Error("Unknown s2k gnu protection mode."); } - break; - - default: + } else { throw new Error("Unknown s2k type."); - break; - } - - return i; - }; - - - /** - * writes an s2k hash based on the inputs. - * @return {String} Produced key of hashAlgorithm hash length - */ - this.write = function () { - var bytes = String.fromCharCode(enums.write(enums.s2k, this.type)); - bytes += String.fromCharCode(enums.write(enums.hash, this.algorithm)); - - switch (this.type) { - case 'simple': - break; - case 'salted': - bytes += this.salt; - break; - case 'iterated': - bytes += this.salt; - bytes += String.fromCharCode(this.c); - break; - } - - return bytes; - }; - - /** - * Produces a key using the specified passphrase and the defined - * hashAlgorithm - * @param {String} passphrase Passphrase containing user input - * @return {String} Produced key with a length corresponding to - * hashAlgorithm hash length - */ - this.produce_key = function (passphrase, numBytes) { - passphrase = util.encode_utf8(passphrase); - - function round(prefix, s2k) { - var algorithm = enums.write(enums.hash, s2k.algorithm); - - switch (s2k.type) { - case 'simple': - return crypto.hash.digest(algorithm, prefix + passphrase); - - case 'salted': - return crypto.hash.digest(algorithm, - prefix + s2k.salt + passphrase); - - case 'iterated': - var isp = [], - count = s2k.get_count(); - data = s2k.salt + passphrase; - - while (isp.length * data.length < count) - isp.push(data); - - isp = isp.join(''); - - if (isp.length > count) - isp = isp.substr(0, count); - - return crypto.hash.digest(algorithm, prefix + isp); } + break; + + default: + throw new Error("Unknown s2k type."); + } + + return i; +}; + + +/** + * writes an s2k hash based on the inputs. + * @return {String} Produced key of hashAlgorithm hash length + */ +S2k.prototype.write = function () { + var bytes = String.fromCharCode(enums.write(enums.s2k, this.type)); + bytes += String.fromCharCode(enums.write(enums.hash, this.algorithm)); + + switch (this.type) { + case 'simple': + break; + case 'salted': + bytes += this.salt; + break; + case 'iterated': + bytes += this.salt; + bytes += String.fromCharCode(this.c); + break; + } + + return bytes; +}; + +/** + * Produces a key using the specified passphrase and the defined + * hashAlgorithm + * @param {String} passphrase Passphrase containing user input + * @return {String} Produced key with a length corresponding to + * hashAlgorithm hash length + */ +S2k.prototype.produce_key = function (passphrase, numBytes) { + passphrase = util.encode_utf8(passphrase); + + function round(prefix, s2k) { + var algorithm = enums.write(enums.hash, s2k.algorithm); + + switch (s2k.type) { + case 'simple': + return crypto.hash.digest(algorithm, prefix + passphrase); + + case 'salted': + return crypto.hash.digest(algorithm, + prefix + s2k.salt + passphrase); + + case 'iterated': + var isp = [], + count = s2k.get_count(); + data = s2k.salt + passphrase; + + while (isp.length * data.length < count) + isp.push(data); + + isp = isp.join(''); + + if (isp.length > count) + isp = isp.substr(0, count); + + return crypto.hash.digest(algorithm, prefix + isp); } + } - var result = '', - prefix = ''; + var result = '', + prefix = ''; - while (result.length <= numBytes) { - result += round(prefix, this); - prefix += String.fromCharCode(0); - } + while (result.length <= numBytes) { + result += round(prefix, this); + prefix += String.fromCharCode(0); + } - return result.substr(0, numBytes); - }; + return result.substr(0, numBytes); };
@@ -215,13 +215,13 @@ module.exports = function s2k() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/secret_key.html b/doc/secret_key.html index 59857a24..92f28910 100644 --- a/doc/secret_key.html +++ b/doc/secret_key.html @@ -178,722 +178,12 @@ major versions. Consequently, this section is complex. -

Members

- -
- -
-

algorithm :module:enums.publicKey

- - -
-
- -
- Public key algorithm -
- - - -
Type:
- - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

created :Date

- - -
-
- -
- Key creation date. -
- - - -
Type:
-
    -
  • - -Date - - -
  • -
- - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- -
-

Methods

-
-

decrypt(str_passphrase) → {Boolean}

- - -
-
- - -
- Decrypts the private key MPIs which are needed to use the key. -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
str_passphrase - - -String - - - - The passphrase for this private key -as string
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- True if the passphrase was correct or MPI already - decrypted; false if not -
- - - -
-
- Type -
-
- -Boolean - - -
-
- - - - -
- - - -
-

encrypt(passphrase)

- - -
-
- - -
- Encrypt the payload. By default, we use aes256 and iterated, salted string -to key specifier -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
passphrase - - -String - - - -
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

getFingerprint() → {String}

- - -
-
- - -
- Calculates the fingerprint of the key -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A string containing the fingerprint -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

getKeyId() → {String}

- - -
-
- - -
- Calculates the key id of the key -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A 8 byte key id -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

read(bytes)

- - -
-
- - -
- Internal parser for private keys as specified in RFC 4880 section 5.5.3 -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
bytes - - -String - - - - Input string to read the packet from
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - -

readPublicKey()

@@ -941,7 +231,7 @@ to key specifier
Source:
@@ -951,7 +241,7 @@ to key specifier
See:
@@ -971,171 +261,6 @@ to key specifier - - - - -
-

write() → {String}

- - -
-
- - -
- Creates an OpenPGP key packet for the given key. -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A string of bytes containing the secret key OpenPGP packet -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

writeOld()

- - -
-
- - -
- Write an old version packet - it's used by some of the internal routines. -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - -
@@ -1187,7 +312,7 @@ to key specifier
Source:
@@ -1197,7 +322,7 @@ to key specifier
See:
@@ -1235,13 +360,13 @@ to key specifier
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST)
diff --git a/doc/secret_key.js.html b/doc/secret_key.js.html index 9dd5a367..0e0e924d 100644 --- a/doc/secret_key.js.html +++ b/doc/secret_key.js.html @@ -69,228 +69,229 @@ var publicKey = require('./public_key.js'), * @constructor * @extends module:packet/public_key */ -module.exports = function secret_key() { +module.exports = SecretKey; + +function SecretKey() { publicKey.call(this); // encrypted secret-key data this.encrypted = null; // indicator if secret-key data is available in decrypted form this.isDecrypted = false; - - - function get_hash_len(hash) { - if (hash == 'sha1') - return 20; - else - return 2; - } - - function get_hash_fn(hash) { - if (hash == 'sha1') - return crypto.hash.sha1; - else - return function(c) { - return util.writeNumber(util.calc_checksum(c), 2); - }; - } - - // Helper function - - function parse_cleartext_mpi(hash_algorithm, cleartext, algorithm) { - var hashlen = get_hash_len(hash_algorithm), - hashfn = get_hash_fn(hash_algorithm); - - var hashtext = cleartext.substr(cleartext.length - hashlen); - cleartext = cleartext.substr(0, cleartext.length - hashlen); - - var hash = hashfn(cleartext); - - if (hash != hashtext) - return new Error("Hash mismatch."); - - var mpis = crypto.getPrivateMpiCount(algorithm); - - var j = 0; - var mpi = []; - - for (var i = 0; i < mpis && j < cleartext.length; i++) { - mpi[i] = new type_mpi(); - j += mpi[i].read(cleartext.substr(j)); - } - - return mpi; - } - - function write_cleartext_mpi(hash_algorithm, algorithm, mpi) { - var bytes = ''; - var discard = crypto.getPublicMpiCount(algorithm); - - for (var i = discard; i < mpi.length; i++) { - bytes += mpi[i].write(); - } - - - bytes += get_hash_fn(hash_algorithm)(bytes); - - return bytes; - } - - - // 5.5.3. Secret-Key Packet Formats - - /** - * Internal parser for private keys as specified in RFC 4880 section 5.5.3 - * @param {String} bytes Input string to read the packet from - */ - this.read = function (bytes) { - // - A Public-Key or Public-Subkey packet, as described above. - var len = this.readPublicKey(bytes); - - bytes = bytes.substr(len); - - - // - One octet indicating string-to-key usage conventions. Zero - // indicates that the secret-key data is not encrypted. 255 or 254 - // indicates that a string-to-key specifier is being given. Any - // other value is a symmetric-key encryption algorithm identifier. - var isEncrypted = bytes.charCodeAt(0); - - if (isEncrypted) { - this.encrypted = bytes; - } else { - - // - Plain or encrypted multiprecision integers comprising the secret - // key data. These algorithm-specific fields are as described - // below. - var parsedMPI = parse_cleartext_mpi('mod', bytes.substr(1), this.algorithm); - if (parsedMPI instanceof Error) - throw parsedMPI; - this.mpi = this.mpi.concat(parsedMPI); - this.isDecrypted = true; - } - - }; - - /** Creates an OpenPGP key packet for the given key. - * @return {String} A string of bytes containing the secret key OpenPGP packet - */ - this.write = function () { - var bytes = this.writePublicKey(); - - if (!this.encrypted) { - bytes += String.fromCharCode(0); - - bytes += write_cleartext_mpi('mod', this.algorithm, this.mpi); - } else { - bytes += this.encrypted; - } - - return bytes; - }; - - - - - /** Encrypt the payload. By default, we use aes256 and iterated, salted string - * to key specifier - * @param {String} passphrase - */ - this.encrypt = function (passphrase) { - - var s2k = new type_s2k(), - symmetric = 'aes256', - cleartext = write_cleartext_mpi('sha1', this.algorithm, this.mpi), - key = produceEncryptionKey(s2k, passphrase, symmetric), - blockLen = crypto.cipher[symmetric].blockSize, - iv = crypto.random.getRandomBytes(blockLen); - - - this.encrypted = ''; - this.encrypted += String.fromCharCode(254); - this.encrypted += String.fromCharCode(enums.write(enums.symmetric, symmetric)); - this.encrypted += s2k.write(); - this.encrypted += iv; - - this.encrypted += crypto.cfb.normalEncrypt(symmetric, key, cleartext, iv); - }; - - function produceEncryptionKey(s2k, passphrase, algorithm) { - return s2k.produce_key(passphrase, - crypto.cipher[algorithm].keySize); - } - - /** - * Decrypts the private key MPIs which are needed to use the key. - * @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 - * @return {Boolean} True if the passphrase was correct or MPI already - * decrypted; false if not - */ - this.decrypt = function (passphrase) { - if (this.isDecrypted) - return true; - - var i = 0, - symmetric, - key; - - var s2k_usage = this.encrypted.charCodeAt(i++); - - // - [Optional] If string-to-key usage octet was 255 or 254, a one- - // octet symmetric encryption algorithm. - if (s2k_usage == 255 || s2k_usage == 254) { - symmetric = this.encrypted.charCodeAt(i++); - symmetric = enums.read(enums.symmetric, symmetric); - - // - [Optional] If string-to-key usage octet was 255 or 254, a - // string-to-key specifier. The length of the string-to-key - // specifier is implied by its type, as described above. - var s2k = new type_s2k(); - i += s2k.read(this.encrypted.substr(i)); - - key = produceEncryptionKey(s2k, passphrase, symmetric); - } else { - symmetric = s2k_usage; - symmetric = enums.read(enums.symmetric, symmetric); - key = crypto.hash.md5(passphrase); - } - - - // - [Optional] If secret data is encrypted (string-to-key usage octet - // not zero), an Initial Vector (IV) of the same length as the - // cipher's block size. - var iv = this.encrypted.substr(i, - crypto.cipher[symmetric].blockSize); - - i += iv.length; - - var cleartext, - ciphertext = this.encrypted.substr(i); - - cleartext = crypto.cfb.normalDecrypt(symmetric, key, ciphertext, iv); - - var hash = s2k_usage == 254 ? - 'sha1' : - 'mod'; - - var parsedMPI = parse_cleartext_mpi(hash, cleartext, this.algorithm); - if (parsedMPI instanceof Error) - return false; - this.mpi = this.mpi.concat(parsedMPI); - this.isDecrypted = true; - return true; - }; - - this.generate = function (bits) { - this.mpi = crypto.generateMpi(this.algorithm, bits); - this.isDecrypted = true; - }; - } -module.exports.prototype = new publicKey(); +SecretKey.prototype = new publicKey(); +SecretKey.prototype.constructor = SecretKey(); + +function get_hash_len(hash) { + if (hash == 'sha1') + return 20; + else + return 2; +} + +function get_hash_fn(hash) { + if (hash == 'sha1') + return crypto.hash.sha1; + else + return function(c) { + return util.writeNumber(util.calc_checksum(c), 2); + }; +} + +// Helper function + +function parse_cleartext_mpi(hash_algorithm, cleartext, algorithm) { + var hashlen = get_hash_len(hash_algorithm), + hashfn = get_hash_fn(hash_algorithm); + + var hashtext = cleartext.substr(cleartext.length - hashlen); + cleartext = cleartext.substr(0, cleartext.length - hashlen); + + var hash = hashfn(cleartext); + + if (hash != hashtext) + return new Error("Hash mismatch."); + + var mpis = crypto.getPrivateMpiCount(algorithm); + + var j = 0; + var mpi = []; + + for (var i = 0; i < mpis && j < cleartext.length; i++) { + mpi[i] = new type_mpi(); + j += mpi[i].read(cleartext.substr(j)); + } + + return mpi; +} + +function write_cleartext_mpi(hash_algorithm, algorithm, mpi) { + var bytes = ''; + var discard = crypto.getPublicMpiCount(algorithm); + + for (var i = discard; i < mpi.length; i++) { + bytes += mpi[i].write(); + } + + + bytes += get_hash_fn(hash_algorithm)(bytes); + + return bytes; +} + + +// 5.5.3. Secret-Key Packet Formats + +/** + * Internal parser for private keys as specified in RFC 4880 section 5.5.3 + * @param {String} bytes Input string to read the packet from + */ +SecretKey.prototype.read = function (bytes) { + // - A Public-Key or Public-Subkey packet, as described above. + var len = this.readPublicKey(bytes); + + bytes = bytes.substr(len); + + + // - One octet indicating string-to-key usage conventions. Zero + // indicates that the secret-key data is not encrypted. 255 or 254 + // indicates that a string-to-key specifier is being given. Any + // other value is a symmetric-key encryption algorithm identifier. + var isEncrypted = bytes.charCodeAt(0); + + if (isEncrypted) { + this.encrypted = bytes; + } else { + + // - Plain or encrypted multiprecision integers comprising the secret + // key data. These algorithm-specific fields are as described + // below. + var parsedMPI = parse_cleartext_mpi('mod', bytes.substr(1), this.algorithm); + if (parsedMPI instanceof Error) + throw parsedMPI; + this.mpi = this.mpi.concat(parsedMPI); + this.isDecrypted = true; + } + +}; + +/** Creates an OpenPGP key packet for the given key. + * @return {String} A string of bytes containing the secret key OpenPGP packet + */ +SecretKey.prototype.write = function () { + var bytes = this.writePublicKey(); + + if (!this.encrypted) { + bytes += String.fromCharCode(0); + + bytes += write_cleartext_mpi('mod', this.algorithm, this.mpi); + } else { + bytes += this.encrypted; + } + + return bytes; +}; + + + + +/** Encrypt the payload. By default, we use aes256 and iterated, salted string + * to key specifier + * @param {String} passphrase + */ +SecretKey.prototype.encrypt = function (passphrase) { + + var s2k = new type_s2k(), + symmetric = 'aes256', + cleartext = write_cleartext_mpi('sha1', this.algorithm, this.mpi), + key = produceEncryptionKey(s2k, passphrase, symmetric), + blockLen = crypto.cipher[symmetric].blockSize, + iv = crypto.random.getRandomBytes(blockLen); + + + this.encrypted = ''; + this.encrypted += String.fromCharCode(254); + this.encrypted += String.fromCharCode(enums.write(enums.symmetric, symmetric)); + this.encrypted += s2k.write(); + this.encrypted += iv; + + this.encrypted += crypto.cfb.normalEncrypt(symmetric, key, cleartext, iv); +}; + +function produceEncryptionKey(s2k, passphrase, algorithm) { + return s2k.produce_key(passphrase, + crypto.cipher[algorithm].keySize); +} + +/** + * Decrypts the private key MPIs which are needed to use the key. + * @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 + * @return {Boolean} True if the passphrase was correct or MPI already + * decrypted; false if not + */ +SecretKey.prototype.decrypt = function (passphrase) { + if (this.isDecrypted) + return true; + + var i = 0, + symmetric, + key; + + var s2k_usage = this.encrypted.charCodeAt(i++); + + // - [Optional] If string-to-key usage octet was 255 or 254, a one- + // octet symmetric encryption algorithm. + if (s2k_usage == 255 || s2k_usage == 254) { + symmetric = this.encrypted.charCodeAt(i++); + symmetric = enums.read(enums.symmetric, symmetric); + + // - [Optional] If string-to-key usage octet was 255 or 254, a + // string-to-key specifier. The length of the string-to-key + // specifier is implied by its type, as described above. + var s2k = new type_s2k(); + i += s2k.read(this.encrypted.substr(i)); + + key = produceEncryptionKey(s2k, passphrase, symmetric); + } else { + symmetric = s2k_usage; + symmetric = enums.read(enums.symmetric, symmetric); + key = crypto.hash.md5(passphrase); + } + + + // - [Optional] If secret data is encrypted (string-to-key usage octet + // not zero), an Initial Vector (IV) of the same length as the + // cipher's block size. + var iv = this.encrypted.substr(i, + crypto.cipher[symmetric].blockSize); + + i += iv.length; + + var cleartext, + ciphertext = this.encrypted.substr(i); + + cleartext = crypto.cfb.normalDecrypt(symmetric, key, ciphertext, iv); + + var hash = s2k_usage == 254 ? + 'sha1' : + 'mod'; + + var parsedMPI = parse_cleartext_mpi(hash, cleartext, this.algorithm); + if (parsedMPI instanceof Error) + return false; + this.mpi = this.mpi.concat(parsedMPI); + this.isDecrypted = true; + return true; +}; + +SecretKey.prototype.generate = function (bits) { + this.mpi = crypto.generateMpi(this.algorithm, bits); + this.isDecrypted = true; +};
@@ -301,13 +302,13 @@ module.exports.prototype = new publicKey();
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/secret_subkey-SecretSubkey.html b/doc/secret_subkey-SecretSubkey.html new file mode 100644 index 00000000..37342f36 --- /dev/null +++ b/doc/secret_subkey-SecretSubkey.html @@ -0,0 +1,320 @@ + + + + + JSDoc: Class: SecretSubkey + + + + + + + + + + +
+ +

Class: SecretSubkey

+ + + + + +
+ +
+

+ packet/secret_subkey~ + + SecretSubkey +

+ +
+ +
+
+ + + + +
+

new SecretSubkey()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

readPublicKey()

+ + +
+
+ + +
+ Alias of read() +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+
    +
  • module:packet/public_key#read
  • +
+
+ + + +
+ + + + + + + + + + + + + +
+ + + +
+

writePublicKey()

+ + +
+
+ + +
+ Alias of write() +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+
    +
  • module:packet/public_key#write
  • +
+
+ + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/secret_subkey.html b/doc/secret_subkey.html index 4bbb38ec..c6a4c538 100644 --- a/doc/secret_subkey.html +++ b/doc/secret_subkey.html @@ -35,72 +35,6 @@
- - -
-

new (require("packet/secret_subkey"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - @@ -157,1073 +91,19 @@ - - - - -

Members

+

Classes

- -
-

algorithm :module:enums.publicKey

- - -
-
- -
- Public key algorithm -
- - - -
Type:
- - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

created :Date

- - -
-
- -
- Key creation date. -
- - - -
Type:
-
    -
  • - -Date - - -
  • -
- - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
SecretSubkey
+
-

Methods

- -
- -
-

decrypt(str_passphrase) → {Boolean}

-
-
-
- Decrypts the private key MPIs which are needed to use the key. -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
str_passphrase - - -String - - - - The passphrase for this private key -as string
- - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- True if the passphrase was correct or MPI already - decrypted; false if not -
- - - -
-
- Type -
-
- -Boolean - - -
-
- - - - -
- - - -
-

encrypt(passphrase)

- - -
-
- - -
- Encrypt the payload. By default, we use aes256 and iterated, salted string -to key specifier -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
passphrase - - -String - - - -
- - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

getFingerprint() → {String}

- - -
-
- - -
- Calculates the fingerprint of the key -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A string containing the fingerprint -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

getKeyId() → {String}

- - -
-
- - -
- Calculates the key id of the key -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A 8 byte key id -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

read(bytes)

- - -
-
- - -
- Internal parser for private keys as specified in RFC 4880 section 5.5.3 -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
bytes - - -String - - - - Input string to read the packet from
- - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

readPublicKey()

- - -
-
- - -
- Alias of read() -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - -
See:
-
- -
- - - -
- - - - - - - - - - - - - -
- - - -
-

write() → {String}

- - -
-
- - -
- Creates an OpenPGP key packet for the given key. -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- A string of bytes containing the secret key OpenPGP packet -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

writeOld()

- - -
-
- - -
- Write an old version packet - it's used by some of the internal routines. -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

writePublicKey()

- - -
-
- - -
- Alias of write() -
- - - - - - - - - -
- - - - - - - -
Inherited From:
-
- - - - - - - - - - - - - -
Source:
-
- - - - - -
See:
-
- -
- - - -
- - - - - - - - - - - - - -
- -
- @@ -1238,13 +118,13 @@ to key specifier

- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST)
diff --git a/doc/secret_subkey.js.html b/doc/secret_subkey.js.html index ed2be443..2f9f0146 100644 --- a/doc/secret_subkey.js.html +++ b/doc/secret_subkey.js.html @@ -47,15 +47,20 @@ * @module packet/secret_subkey */ +module.exports = SecretSubkey; + var secretKey = require('./secret_key.js'); /** * @constructor * @extends module:packet/secret_key */ -module.exports = function secret_subkey() { +function SecretSubkey() { secretKey.call(this); } + +SecretSubkey.prototype = new secretKey(); +SecretSubkey.prototype.constructor = SecretSubkey;
@@ -66,13 +71,13 @@ module.exports = function secret_subkey() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/sha.html b/doc/sha.html index 820eddea..d78343ec 100644 --- a/doc/sha.html +++ b/doc/sha.html @@ -454,13 +454,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:41 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST)
diff --git a/doc/sha.js.html b/doc/sha.js.html index 1a78a0d6..da56128f 100644 --- a/doc/sha.js.html +++ b/doc/sha.js.html @@ -126,7 +126,7 @@ var jsSHA = (function() { * * @private * @param {Array} binarray Array of integers to be converted to hexidecimal - * representation + * representation * @return Hexidecimal representation of the parameter in String form */ binb2hex = function(binarray) { @@ -149,7 +149,7 @@ var jsSHA = (function() { * * @private * @param {Array} binarray Array of integers to be converted to base-64 - * representation + * representation * @return Base-64 encoded representation of the parameter in String form */ binb2b64 = function(binarray) { @@ -589,7 +589,7 @@ var jsSHA = (function() { * * @private * @param {Array} message The binary array representation of the string to - * hash + * hash * @param {Number} messageLen The number of bits in the message * @return The array of integers representing the SHA-1 hash of message */ @@ -942,7 +942,7 @@ var jsSHA = (function() { * using the specified parameters * * @param {String} variant The desired SHA variant (SHA-1, SHA-224, - * SHA-256, SHA-384, or SHA-512) + * SHA-256, SHA-384, or SHA-512) * @param {String} format The desired output formatting (B64 or HEX) * @return The string representation of the hash in the format specified */ @@ -1002,9 +1002,9 @@ var jsSHA = (function() { * @param {String} key The key used to calculate the HMAC * @param {String} inputFormat The format of key, ASCII or HEX * @param {String} variant The desired SHA variant (SHA-1, SHA-224, - * SHA-256, SHA-384, or SHA-512) + * SHA-256, SHA-384, or SHA-512) * @param {String} outputFormat The desired output formatting - * (B64 or HEX) + * (B64 or HEX) * @return The string representation of the hash in the format specified */ getHMAC: function(key, inputFormat, variant, outputFormat) { @@ -1149,7 +1149,7 @@ module.exports = { var shaObj = new jsSHA(str, "ASCII"); return shaObj.getHash("SHA-512", "ASCII"); } -} +}; @@ -1160,13 +1160,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/signature-Signature.html b/doc/signature-Signature.html new file mode 100644 index 00000000..cb609bcb --- /dev/null +++ b/doc/signature-Signature.html @@ -0,0 +1,827 @@ + + + + + JSDoc: Class: Signature + + + + + + + + + + +
+ +

Class: Signature

+ + + + + +
+ +
+

+ packet/signature~ + + Signature +

+ +
+ +
+
+ + + + +
+

new Signature()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

isExpired() → {Boolean}

+ + +
+
+ + +
+ Verifies signature expiration date +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ true if expired +
+ + + +
+
+ Type +
+
+ +Boolean + + +
+
+ + + + +
+ + + +
+

read(bytes, position, len) → {module:packet/signature}

+ + +
+
+ + +
+ parsing function for a signature packet (tag 2). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
bytes + + +String + + + + payload of a tag 2 packet
position + + +Integer + + + + position to start reading from the bytes string
len + + +Integer + + + + length of the packet or the remaining length of bytes at position
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ object representation +
+ + + +
+
+ Type +
+
+ +module:packet/signature + + +
+
+ + + + +
+ + + +
+

sign(key, data)

+ + +
+
+ + +
+ Signs provided data. This needs to be done prior to serialization. +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +module:packet/secret_key + + + + private key used to sign the message.
data + + +Object + + + + Contains packets to be signed.
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

verify(data, key) → {boolean}

+ + +
+
+ + +
+ verifys the signature packet. Note: not signature types are implemented +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
data + + +String +| + +Object + + + + data which on the signature applies
key + + +module:packet/public_subkey +| + +module:packet/public_key + + + + the public key to verify the signature
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ True if message is verified, else false. +
+ + + +
+
+ Type +
+
+ +boolean + + +
+
+ + + + +
+ + + +
+

write_all_sub_packets() → {String}

+ + +
+
+ + +
+ Creates string of bytes with all subpacket data +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ a string-representation of a all subpacket data +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/signature.html b/doc/signature.html index fd7e7186..65599a0b 100644 --- a/doc/signature.html +++ b/doc/signature.html @@ -575,13 +575,13 @@ integers which is used to sign the data
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:41 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST)
diff --git a/doc/signature.js.html b/doc/signature.js.html index d2f11bc7..fe3c4a51 100644 --- a/doc/signature.js.html +++ b/doc/signature.js.html @@ -47,6 +47,7 @@ module.exports = { */ verify: function(algo, hash_algo, msg_MPIs, publickey_MPIs, data) { var calc_hash = hashModule.digest(hash_algo, data); + var dopublic; switch (algo) { case 1: @@ -59,7 +60,7 @@ module.exports = { var n = publickey_MPIs[0].toBigInteger(); var e = publickey_MPIs[1].toBigInteger(); var x = msg_MPIs[0].toBigInteger(); - var dopublic = rsa.verify(x, e, n); + dopublic = rsa.verify(x, e, n); var hash = pkcs1.emsa.decode(hash_algo, dopublic.toMPI().substring(2)); if (hash == -1) { throw new Error('PKCS1 padding in message or key incorrect. Aborting...'); @@ -79,12 +80,11 @@ module.exports = { var g = publickey_MPIs[2].toBigInteger(); var y = publickey_MPIs[3].toBigInteger(); var m = data; - var dopublic = dsa.verify(hash_algo, s1, s2, m, p, q, g, y); - return dopublic.compareTo(s1) == 0; + dopublic = dsa.verify(hash_algo, s1, s2, m, p, q, g, y); + return dopublic.compareTo(s1) === 0; default: throw new Error('Invalid signature algorithm.'); } - }, /** @@ -100,6 +100,8 @@ module.exports = { */ sign: function(hash_algo, algo, keyIntegers, data) { + var m; + switch (algo) { case 1: // RSA (Encrypt or Sign) [HAC] @@ -110,7 +112,7 @@ module.exports = { var rsa = new publicKey.rsa(); var d = keyIntegers[2].toBigInteger(); var n = keyIntegers[0].toBigInteger(); - var m = pkcs1.emsa.encode(hash_algo, + m = pkcs1.emsa.encode(hash_algo, data, keyIntegers[0].byteLength()); return rsa.sign(m, d, n).toMPI(); @@ -124,7 +126,7 @@ module.exports = { var g = keyIntegers[2].toBigInteger(); var y = keyIntegers[3].toBigInteger(); var x = keyIntegers[4].toBigInteger(); - var m = data; + m = data; var result = dsa.sign(hash_algo, m, g, p, q, x); return result[0].toString() + result[1].toString(); @@ -135,7 +137,7 @@ module.exports = { throw new Error('Invalid signature algorithm.'); } } -} +}; @@ -146,13 +148,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/signature.js_.html b/doc/signature.js_.html index f3a3d0ab..1a575373 100644 --- a/doc/signature.js_.html +++ b/doc/signature.js_.html @@ -58,6 +58,8 @@ * @module packet/signature */ +module.exports = Signature; + var util = require('../util'), packet = require('./packet.js'), enums = require('../enums.js'), @@ -68,7 +70,7 @@ var util = require('../util'), /** * @constructor */ -module.exports = function signature() { +function Signature() { this.version = 4; this.signatureType = null; @@ -112,559 +114,557 @@ module.exports = function signature() { this.embeddedSignature = null; this.verified = false; - - /** - * parsing function for a signature packet (tag 2). - * @param {String} bytes payload of a tag 2 packet - * @param {Integer} position position to start reading from the bytes string - * @param {Integer} len length of the packet or the remaining length of bytes at position - * @return {module:packet/signature} object representation - */ - this.read = function (bytes) { - var i = 0; - - this.version = bytes.charCodeAt(i++); - // switch on version (3 and 4) - switch (this.version) { - case 3: - // One-octet length of following hashed material. MUST be 5. - if (bytes.charCodeAt(i++) != 5) - util.print_debug("packet/signature.js\n" + - 'invalid One-octet length of following hashed material.' + - 'MUST be 5. @:' + (i - 1)); - - var sigpos = i; - // One-octet signature type. - this.signatureType = bytes.charCodeAt(i++); - - // Four-octet creation time. - this.created = util.readDate(bytes.substr(i, 4)); - i += 4; - - // storing data appended to data which gets verified - this.signatureData = bytes.substring(sigpos, i); - - // Eight-octet Key ID of signer. - this.issuerKeyId.read(bytes.substring(i, i + 8)); - i += 8; - - // One-octet public-key algorithm. - this.publicKeyAlgorithm = bytes.charCodeAt(i++); - - // One-octet hash algorithm. - this.hashAlgorithm = bytes.charCodeAt(i++); - break; - case 4: - this.signatureType = bytes.charCodeAt(i++); - this.publicKeyAlgorithm = bytes.charCodeAt(i++); - this.hashAlgorithm = bytes.charCodeAt(i++); - - function subpackets(bytes) { - // Two-octet scalar octet count for following subpacket data. - var subpacket_length = util.readNumber( - bytes.substr(0, 2)); - - var i = 2; - - // subpacket data set (zero or more subpackets) - var subpacked_read = 0; - while (i < 2 + subpacket_length) { - - var len = packet.readSimpleLength(bytes.substr(i)); - i += len.offset; - - this.read_sub_packet(bytes.substr(i, len.len)); - - i += len.len; - } - - return i; - } - - // hashed subpackets - i += subpackets.call(this, bytes.substr(i), true); - - // A V4 signature hashes the packet body - // starting from its first field, the version number, through the end - // of the hashed subpacket data. Thus, the fields hashed are the - // signature version, the signature type, the public-key algorithm, the - // hash algorithm, the hashed subpacket length, and the hashed - // subpacket body. - this.signatureData = bytes.substr(0, i); - - // unhashed subpackets - i += subpackets.call(this, bytes.substr(i), false); - - break; - default: - throw new Error('Version ' + version + ' of the signature is unsupported.'); - break; - } - - // Two-octet field holding left 16 bits of signed hash value. - this.signedHashValue = bytes.substr(i, 2); - i += 2; - - this.signature = bytes.substr(i); - }; - - this.write = function () { - return this.signatureData + - util.writeNumber(0, 2) + // Number of unsigned subpackets. - this.signedHashValue + - this.signature; - }; - - /** - * Signs provided data. This needs to be done prior to serialization. - * @param {module:packet/secret_key} key private key used to sign the message. - * @param {Object} data Contains packets to be signed. - */ - this.sign = function (key, data) { - var signatureType = enums.write(enums.signature, this.signatureType), - publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), - hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); - - var result = String.fromCharCode(4); - result += String.fromCharCode(signatureType); - result += String.fromCharCode(publicKeyAlgorithm); - result += String.fromCharCode(hashAlgorithm); - - this.issuerKeyId = key.getKeyId(); - - // Add hashed subpackets - result += this.write_all_sub_packets(); - - this.signatureData = result; - - var trailer = this.calculateTrailer(); - - var toHash = this.toSign(signatureType, data) + - this.signatureData + trailer; - - var hash = crypto.hash.digest(hashAlgorithm, toHash); - - this.signedHashValue = hash.substr(0, 2); - - this.signature = crypto.signature.sign(hashAlgorithm, - publicKeyAlgorithm, key.mpi, toHash); - }; - - /** - * Creates string of bytes with all subpacket data - * @return {String} a string-representation of a all subpacket data - */ - this.write_all_sub_packets = function () { - var sub = enums.signatureSubpacket; - var result = ''; - var bytes = ''; - if (this.created !== null) { - result += write_sub_packet(sub.signature_creation_time, util.writeDate(this.created)); - } - if (this.signatureExpirationTime !== null) { - result += write_sub_packet(sub.signature_expiration_time, util.writeNumber(this.signatureExpirationTime, 4)); - } - if (this.exportable !== null) { - result += write_sub_packet(sub.exportable_certification, String.fromCharCode(this.exportable ? 1 : 0)); - } - if (this.trustLevel !== null) { - bytes = String.fromCharCode(this.trustLevel) + String.fromCharCode(this.trustAmount); - result += write_sub_packet(sub.trust_signature, bytes); - } - if (this.regularExpression !== null) { - result += write_sub_packet(sub.regular_expression, this.regularExpression); - } - if (this.revocable !== null) { - result += write_sub_packet(sub.revocable, String.fromCharCode(this.revocable ? 1 : 0)); - } - if (this.keyExpirationTime !== null) { - result += write_sub_packet(sub.key_expiration_time, util.writeNumber(this.keyExpirationTime, 4)); - } - if (this.preferredSymmetricAlgorithms !== null) { - bytes = util.bin2str(this.preferredSymmetricAlgorithms); - result += write_sub_packet(sub.preferred_symmetric_algorithms, bytes); - } - if (this.revocationKeyClass !== null) { - bytes = String.fromCharCode(this.revocationKeyClass); - bytes += String.fromCharCode(this.revocationKeyAlgorithm); - bytes += this.revocationKeyFingerprint; - result += write_sub_packet(sub.revocation_key, bytes); - } - if (!this.issuerKeyId.isNull()) { - result += write_sub_packet(sub.issuer, this.issuerKeyId.write()); - } - if (this.notation !== null) { - for (var name in this.notation) { - if (this.notation.hasOwnProperty(name)) { - var value = this.notation[name]; - bytes = String.fromCharCode(0x80); - bytes += String.fromCharCode(0); - bytes += String.fromCharCode(0); - bytes += String.fromCharCode(0); - // 2 octets of name length - bytes += util.writeNumber(name.length, 2); - // 2 octets of value length - bytes += util.writeNumber(value.length, 2); - bytes += name + value; - result += write_sub_packet(sub.notation_data, bytes); - } - } - } - if (this.preferredHashAlgorithms !== null) { - bytes = util.bin2str(this.preferredHashAlgorithms); - result += write_sub_packet(sub.preferred_hash_algorithms, bytes); - } - if (this.preferredCompressionAlgorithms !== null) { - bytes = util.bin2str(this.preferredCompressionAlgorithms); - result += write_sub_packet(sub.preferred_hash_algorithms, bytes); - } - if (this.keyServerPreferences !== null) { - bytes = util.bin2str(this.keyServerPreferences); - result += write_sub_packet(sub.key_server_preferences, bytes); - } - if (this.preferredKeyServer !== null) { - result += write_sub_packet(sub.preferred_key_server, this.preferredKeyServer); - } - if (this.isPrimaryUserID !== null) { - result += write_sub_packet(sub.primary_user_id, String.fromCharCode(this.isPrimaryUserID ? 1 : 0)); - } - if (this.policyURI !== null) { - result += write_sub_packet(sub.policy_uri, this.policyURI); - } - if (this.keyFlags !== null) { - bytes = util.bin2str(this.keyFlags); - result += write_sub_packet(sub.key_flags, bytes); - } - if (this.signersUserId !== null) { - result += write_sub_packet(sub.signers_user_id, this.signersUserId); - } - if (this.reasonForRevocationFlag !== null) { - bytes = String.fromCharCode(this.reasonForRevocationFlag); - bytes += this.reasonForRevocationString; - result += write_sub_packet(sub.reason_for_revocation, bytes); - } - if (this.features !== null) { - bytes = util.bin2str(this.features); - result += write_sub_packet(sub.features, bytes); - } - if (this.signatureTargetPublicKeyAlgorithm !== null) { - bytes = String.fromCharCode(this.signatureTargetPublicKeyAlgorithm); - bytes += String.fromCharCode(this.signatureTargetHashAlgorithm); - bytes += this.signatureTargetHash; - result += write_sub_packet(sub.signature_target, bytes); - } - if (this.embeddedSignature !== null) { - result += write_sub_packet(sub.embedded_signature, this.embeddedSignature.write()); - } - result = util.writeNumber(result.length, 2) + result; - return result; - }; - - /** - * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) - * @param {Integer} type subpacket signature type. Signature types as described - * in RFC4880 Section 5.2.3.2 - * @param {String} data data to be included - * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) - */ - function write_sub_packet(type, data) { - var result = ""; - result += packet.writeSimpleLength(data.length + 1); - result += String.fromCharCode(type); - result += data; - return result; - } - - // V4 signature sub packets - - this.read_sub_packet = function (bytes) { - var mypos = 0; - - function read_array(prop, bytes) { - this[prop] = []; - - for (var i = 0; i < bytes.length; i++) { - this[prop].push(bytes.charCodeAt(i)); - } - } - - // The leftwost bit denotes a "critical" packet, but we ignore it. - var type = bytes.charCodeAt(mypos++) & 0x7F; - - // subpacket type - switch (type) { - case 2: - // Signature Creation Time - this.created = util.readDate(bytes.substr(mypos)); - break; - case 3: - // Signature Expiration Time in seconds - var seconds = util.readNumber(bytes.substr(mypos)); - - this.signatureNeverExpires = seconds == 0; - this.signatureExpirationTime = seconds; - - break; - case 4: - // Exportable Certification - this.exportable = bytes.charCodeAt(mypos++) == 1; - break; - case 5: - // Trust Signature - this.trustLevel = bytes.charCodeAt(mypos++); - this.trustAmount = bytes.charCodeAt(mypos++); - break; - case 6: - // Regular Expression - this.regularExpression = bytes.substr(mypos); - break; - case 7: - // Revocable - this.revocable = bytes.charCodeAt(mypos++) == 1; - break; - case 9: - // Key Expiration Time in seconds - var seconds = util.readNumber(bytes.substr(mypos)); - - this.keyExpirationTime = seconds; - this.keyNeverExpires = seconds == 0; - - break; - case 11: - // Preferred Symmetric Algorithms - this.preferredSymmetricAlgorithms = []; - - while (mypos != bytes.length) { - this.preferredSymmetricAlgorithms.push(bytes.charCodeAt(mypos++)); - } - - break; - case 12: - // Revocation Key - // (1 octet of class, 1 octet of public-key algorithm ID, 20 - // octets of - // fingerprint) - this.revocationKeyClass = bytes.charCodeAt(mypos++); - this.revocationKeyAlgorithm = bytes.charCodeAt(mypos++); - this.revocationKeyFingerprint = bytes.substr(mypos, 20); - break; - - case 16: - // Issuer - this.issuerKeyId.read(bytes.substr(mypos)); - break; - - case 20: - // Notation Data - // We don't know how to handle anything but a text flagged data. - if (bytes.charCodeAt(mypos) == 0x80) { - - // We extract key/value tuple from the byte stream. - mypos += 4; - var m = util.readNumber(bytes.substr(mypos, 2)); - mypos += 2 - var n = util.readNumber(bytes.substr(mypos, 2)); - mypos += 2 - - var name = bytes.substr(mypos, m), - value = bytes.substr(mypos + m, n); - - this.notation = this.notation || {}; - this.notation[name] = value; - } else throw new Error("Unsupported notation flag."); - break; - case 21: - // Preferred Hash Algorithms - read_array.call(this, 'preferredHashAlgorithms', bytes.substr(mypos)); - break; - case 22: - // Preferred Compression Algorithms - read_array.call(this, 'preferredCompressionAlgorithms ', bytes.substr(mypos)); - break; - case 23: - // Key Server Preferences - read_array.call(this, 'keyServerPreferencess', bytes.substr(mypos)); - break; - case 24: - // Preferred Key Server - this.preferredKeyServer = bytes.substr(mypos); - break; - case 25: - // Primary User ID - this.isPrimaryUserID = bytes[mypos++] != 0; - break; - case 26: - // Policy URI - this.policyURI = bytes.substr(mypos); - break; - case 27: - // Key Flags - read_array.call(this, 'keyFlags', bytes.substr(mypos)); - break; - case 28: - // Signer's User ID - this.signersUserId += bytes.substr(mypos); - break; - case 29: - // Reason for Revocation - this.reasonForRevocationFlag = bytes.charCodeAt(mypos++); - this.reasonForRevocationString = bytes.substr(mypos); - break; - case 30: - // Features - read_array.call(this, 'features', bytes.substr(mypos)); - break; - case 31: - // Signature Target - // (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) - this.signatureTargetPublicKeyAlgorithm = bytes.charCodeAt(mypos++); - this.signatureTargetHashAlgorithm = bytes.charCodeAt(mypos++); - - var len = crypto.getHashByteLength(this.signatureTargetHashAlgorithm); - - this.signatureTargetHash = bytes.substr(mypos, len); - break; - case 32: - // Embedded Signature - this.embeddedSignature = new signature(); - this.embeddedSignature.read(bytes.substr(mypos)); - break; - default: - throw new Error("Unknown signature subpacket type " + type + " @:" + mypos); - break; - } - }; - - // Produces data to produce signature on - this.toSign = function (type, data) { - var t = enums.signature; - - switch (type) { - case t.binary: - case t.text: - return data.getBytes(); - - case t.standalone: - return ''; - - case t.cert_generic: - case t.cert_persona: - case t.cert_casual: - case t.cert_positive: - case t.cert_revocation: - var packet, tag; - - if (data.userid !== undefined) { - tag = 0xB4; - packet = data.userid; - } else if (data.userattribute !== undefined) { - tag = 0xD1; - packet = data.userattribute; - } else throw new Error('Either a userid or userattribute packet needs to be ' + - 'supplied for certification.'); - - var bytes = packet.write(); - - if (this.version == 4) { - return this.toSign(t.key, data) + - String.fromCharCode(tag) + - util.writeNumber(bytes.length, 4) + - bytes; - } else if (this.version == 3) { - return this.toSign(t.key, data) + - bytes; - } - break; - - case t.subkey_binding: - case t.key_binding: - return this.toSign(t.key, data) + this.toSign(t.key, { - key: data.bind - }); - - case t.key: - if (data.key == undefined) - throw new Error('Key packet is required for this sigtature.'); - - return data.key.writeOld(); - - case t.key_revocation: - case t.subkey_revocation: - return this.toSign(t.key, data); - case t.timestamp: - return ''; - case t.third_party: - throw new Error('Not implemented'); - break; - default: - throw new Error('Unknown signature type.') - } - } - - - this.calculateTrailer = function () { - // calculating the trailer - var trailer = ''; - // V3 signatures don't have a trailer - if (this.version == 3) return trailer; - trailer += String.fromCharCode(4); // Version - trailer += String.fromCharCode(0xFF); - trailer += util.writeNumber(this.signatureData.length, 4); - return trailer - } - - - /** - * verifys the signature packet. Note: not signature types are implemented - * @param {String|Object} data data which on the signature applies - * @param {module:packet/public_subkey|module:packet/public_key} key the public key to verify the signature - * @return {boolean} True if message is verified, else false. - */ - this.verify = function (key, data) { - var signatureType = enums.write(enums.signature, this.signatureType), - publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), - hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); - - var bytes = this.toSign(signatureType, data), - trailer = this.calculateTrailer(); - - - 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) - mpicount = 1; - // Algorithm-Specific Fields for DSA signatures: - // - MPI of DSA value r. - // - MPI of DSA value s. - else if (publicKeyAlgorithm == 17) - mpicount = 2; - - var mpi = [], - i = 0; - for (var j = 0; j < mpicount; j++) { - mpi[j] = new type_mpi(); - i += mpi[j].read(this.signature.substr(i)); - } - - this.verified = crypto.signature.verify(publicKeyAlgorithm, - hashAlgorithm, mpi, key.mpi, - bytes + this.signatureData + trailer); - - return this.verified; - } - - /** - * Verifies signature expiration date - * @return {Boolean} true if expired - */ - this.isExpired = function () { - if (!this.signatureNeverExpires) { - return Date.now() > (this.created.getTime() + this.signatureExpirationTime*1000); - } - return false; - } } + +/** + * parsing function for a signature packet (tag 2). + * @param {String} bytes payload of a tag 2 packet + * @param {Integer} position position to start reading from the bytes string + * @param {Integer} len length of the packet or the remaining length of bytes at position + * @return {module:packet/signature} object representation + */ +Signature.prototype.read = function (bytes) { + var i = 0; + + this.version = bytes.charCodeAt(i++); + // switch on version (3 and 4) + switch (this.version) { + case 3: + // One-octet length of following hashed material. MUST be 5. + if (bytes.charCodeAt(i++) != 5) + util.print_debug("packet/signature.js\n" + + 'invalid One-octet length of following hashed material.' + + 'MUST be 5. @:' + (i - 1)); + + var sigpos = i; + // One-octet signature type. + this.signatureType = bytes.charCodeAt(i++); + + // Four-octet creation time. + this.created = util.readDate(bytes.substr(i, 4)); + i += 4; + + // storing data appended to data which gets verified + this.signatureData = bytes.substring(sigpos, i); + + // Eight-octet Key ID of signer. + this.issuerKeyId.read(bytes.substring(i, i + 8)); + i += 8; + + // One-octet public-key algorithm. + this.publicKeyAlgorithm = bytes.charCodeAt(i++); + + // One-octet hash algorithm. + this.hashAlgorithm = bytes.charCodeAt(i++); + break; + case 4: + this.signatureType = bytes.charCodeAt(i++); + this.publicKeyAlgorithm = bytes.charCodeAt(i++); + this.hashAlgorithm = bytes.charCodeAt(i++); + + function subpackets(bytes) { + // Two-octet scalar octet count for following subpacket data. + var subpacket_length = util.readNumber( + bytes.substr(0, 2)); + + var i = 2; + + // subpacket data set (zero or more subpackets) + var subpacked_read = 0; + while (i < 2 + subpacket_length) { + + var len = packet.readSimpleLength(bytes.substr(i)); + i += len.offset; + + this.read_sub_packet(bytes.substr(i, len.len)); + + i += len.len; + } + + return i; + } + + // hashed subpackets + i += subpackets.call(this, bytes.substr(i), true); + + // A V4 signature hashes the packet body + // starting from its first field, the version number, through the end + // of the hashed subpacket data. Thus, the fields hashed are the + // signature version, the signature type, the public-key algorithm, the + // hash algorithm, the hashed subpacket length, and the hashed + // subpacket body. + this.signatureData = bytes.substr(0, i); + + // unhashed subpackets + i += subpackets.call(this, bytes.substr(i), false); + + break; + default: + throw new Error('Version ' + version + ' of the signature is unsupported.'); + } + + // Two-octet field holding left 16 bits of signed hash value. + this.signedHashValue = bytes.substr(i, 2); + i += 2; + + this.signature = bytes.substr(i); +}; + +Signature.prototype.write = function () { + return this.signatureData + + util.writeNumber(0, 2) + // Number of unsigned subpackets. + this.signedHashValue + + this.signature; +}; + +/** + * Signs provided data. This needs to be done prior to serialization. + * @param {module:packet/secret_key} key private key used to sign the message. + * @param {Object} data Contains packets to be signed. + */ +Signature.prototype.sign = function (key, data) { + var signatureType = enums.write(enums.signature, this.signatureType), + publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), + hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); + + var result = String.fromCharCode(4); + result += String.fromCharCode(signatureType); + result += String.fromCharCode(publicKeyAlgorithm); + result += String.fromCharCode(hashAlgorithm); + + this.issuerKeyId = key.getKeyId(); + + // Add hashed subpackets + result += this.write_all_sub_packets(); + + this.signatureData = result; + + var trailer = this.calculateTrailer(); + + var toHash = this.toSign(signatureType, data) + + this.signatureData + trailer; + + var hash = crypto.hash.digest(hashAlgorithm, toHash); + + this.signedHashValue = hash.substr(0, 2); + + this.signature = crypto.signature.sign(hashAlgorithm, + publicKeyAlgorithm, key.mpi, toHash); +}; + +/** + * Creates string of bytes with all subpacket data + * @return {String} a string-representation of a all subpacket data + */ +Signature.prototype.write_all_sub_packets = function () { + var sub = enums.signatureSubpacket; + var result = ''; + var bytes = ''; + if (this.created !== null) { + result += write_sub_packet(sub.signature_creation_time, util.writeDate(this.created)); + } + if (this.signatureExpirationTime !== null) { + result += write_sub_packet(sub.signature_expiration_time, util.writeNumber(this.signatureExpirationTime, 4)); + } + if (this.exportable !== null) { + result += write_sub_packet(sub.exportable_certification, String.fromCharCode(this.exportable ? 1 : 0)); + } + if (this.trustLevel !== null) { + bytes = String.fromCharCode(this.trustLevel) + String.fromCharCode(this.trustAmount); + result += write_sub_packet(sub.trust_signature, bytes); + } + if (this.regularExpression !== null) { + result += write_sub_packet(sub.regular_expression, this.regularExpression); + } + if (this.revocable !== null) { + result += write_sub_packet(sub.revocable, String.fromCharCode(this.revocable ? 1 : 0)); + } + if (this.keyExpirationTime !== null) { + result += write_sub_packet(sub.key_expiration_time, util.writeNumber(this.keyExpirationTime, 4)); + } + if (this.preferredSymmetricAlgorithms !== null) { + bytes = util.bin2str(this.preferredSymmetricAlgorithms); + result += write_sub_packet(sub.preferred_symmetric_algorithms, bytes); + } + if (this.revocationKeyClass !== null) { + bytes = String.fromCharCode(this.revocationKeyClass); + bytes += String.fromCharCode(this.revocationKeyAlgorithm); + bytes += this.revocationKeyFingerprint; + result += write_sub_packet(sub.revocation_key, bytes); + } + if (!this.issuerKeyId.isNull()) { + result += write_sub_packet(sub.issuer, this.issuerKeyId.write()); + } + if (this.notation !== null) { + for (var name in this.notation) { + if (this.notation.hasOwnProperty(name)) { + var value = this.notation[name]; + bytes = String.fromCharCode(0x80); + bytes += String.fromCharCode(0); + bytes += String.fromCharCode(0); + bytes += String.fromCharCode(0); + // 2 octets of name length + bytes += util.writeNumber(name.length, 2); + // 2 octets of value length + bytes += util.writeNumber(value.length, 2); + bytes += name + value; + result += write_sub_packet(sub.notation_data, bytes); + } + } + } + if (this.preferredHashAlgorithms !== null) { + bytes = util.bin2str(this.preferredHashAlgorithms); + result += write_sub_packet(sub.preferred_hash_algorithms, bytes); + } + if (this.preferredCompressionAlgorithms !== null) { + bytes = util.bin2str(this.preferredCompressionAlgorithms); + result += write_sub_packet(sub.preferred_hash_algorithms, bytes); + } + if (this.keyServerPreferences !== null) { + bytes = util.bin2str(this.keyServerPreferences); + result += write_sub_packet(sub.key_server_preferences, bytes); + } + if (this.preferredKeyServer !== null) { + result += write_sub_packet(sub.preferred_key_server, this.preferredKeyServer); + } + if (this.isPrimaryUserID !== null) { + result += write_sub_packet(sub.primary_user_id, String.fromCharCode(this.isPrimaryUserID ? 1 : 0)); + } + if (this.policyURI !== null) { + result += write_sub_packet(sub.policy_uri, this.policyURI); + } + if (this.keyFlags !== null) { + bytes = util.bin2str(this.keyFlags); + result += write_sub_packet(sub.key_flags, bytes); + } + if (this.signersUserId !== null) { + result += write_sub_packet(sub.signers_user_id, this.signersUserId); + } + if (this.reasonForRevocationFlag !== null) { + bytes = String.fromCharCode(this.reasonForRevocationFlag); + bytes += this.reasonForRevocationString; + result += write_sub_packet(sub.reason_for_revocation, bytes); + } + if (this.features !== null) { + bytes = util.bin2str(this.features); + result += write_sub_packet(sub.features, bytes); + } + if (this.signatureTargetPublicKeyAlgorithm !== null) { + bytes = String.fromCharCode(this.signatureTargetPublicKeyAlgorithm); + bytes += String.fromCharCode(this.signatureTargetHashAlgorithm); + bytes += this.signatureTargetHash; + result += write_sub_packet(sub.signature_target, bytes); + } + if (this.embeddedSignature !== null) { + result += write_sub_packet(sub.embedded_signature, this.embeddedSignature.write()); + } + result = util.writeNumber(result.length, 2) + result; + return result; +}; + +/** + * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) + * @param {Integer} type subpacket signature type. Signature types as described + * in RFC4880 Section 5.2.3.2 + * @param {String} data data to be included + * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) + */ +function write_sub_packet(type, data) { + var result = ""; + result += packet.writeSimpleLength(data.length + 1); + result += String.fromCharCode(type); + result += data; + return result; +} + +// V4 signature sub packets + +Signature.prototype.read_sub_packet = function (bytes) { + var mypos = 0; + + function read_array(prop, bytes) { + this[prop] = []; + + for (var i = 0; i < bytes.length; i++) { + this[prop].push(bytes.charCodeAt(i)); + } + } + + // The leftwost bit denotes a "critical" packet, but we ignore it. + var type = bytes.charCodeAt(mypos++) & 0x7F; + var seconds; + + // subpacket type + switch (type) { + case 2: + // Signature Creation Time + this.created = util.readDate(bytes.substr(mypos)); + break; + case 3: + // Signature Expiration Time in seconds + seconds = util.readNumber(bytes.substr(mypos)); + + this.signatureNeverExpires = seconds === 0; + this.signatureExpirationTime = seconds; + + break; + case 4: + // Exportable Certification + this.exportable = bytes.charCodeAt(mypos++) == 1; + break; + case 5: + // Trust Signature + this.trustLevel = bytes.charCodeAt(mypos++); + this.trustAmount = bytes.charCodeAt(mypos++); + break; + case 6: + // Regular Expression + this.regularExpression = bytes.substr(mypos); + break; + case 7: + // Revocable + this.revocable = bytes.charCodeAt(mypos++) == 1; + break; + case 9: + // Key Expiration Time in seconds + seconds = util.readNumber(bytes.substr(mypos)); + + this.keyExpirationTime = seconds; + this.keyNeverExpires = seconds === 0; + + break; + case 11: + // Preferred Symmetric Algorithms + this.preferredSymmetricAlgorithms = []; + + while (mypos != bytes.length) { + this.preferredSymmetricAlgorithms.push(bytes.charCodeAt(mypos++)); + } + + break; + case 12: + // Revocation Key + // (1 octet of class, 1 octet of public-key algorithm ID, 20 + // octets of + // fingerprint) + this.revocationKeyClass = bytes.charCodeAt(mypos++); + this.revocationKeyAlgorithm = bytes.charCodeAt(mypos++); + this.revocationKeyFingerprint = bytes.substr(mypos, 20); + break; + + case 16: + // Issuer + this.issuerKeyId.read(bytes.substr(mypos)); + break; + + case 20: + // Notation Data + // We don't know how to handle anything but a text flagged data. + if (bytes.charCodeAt(mypos) == 0x80) { + + // We extract key/value tuple from the byte stream. + mypos += 4; + var m = util.readNumber(bytes.substr(mypos, 2)); + mypos += 2; + var n = util.readNumber(bytes.substr(mypos, 2)); + mypos += 2; + + var name = bytes.substr(mypos, m), + value = bytes.substr(mypos + m, n); + + this.notation = this.notation || {}; + this.notation[name] = value; + } else throw new Error("Unsupported notation flag."); + break; + case 21: + // Preferred Hash Algorithms + read_array.call(this, 'preferredHashAlgorithms', bytes.substr(mypos)); + break; + case 22: + // Preferred Compression Algorithms + read_array.call(this, 'preferredCompressionAlgorithms ', bytes.substr(mypos)); + break; + case 23: + // Key Server Preferences + read_array.call(this, 'keyServerPreferencess', bytes.substr(mypos)); + break; + case 24: + // Preferred Key Server + this.preferredKeyServer = bytes.substr(mypos); + break; + case 25: + // Primary User ID + this.isPrimaryUserID = bytes[mypos++] !== 0; + break; + case 26: + // Policy URI + this.policyURI = bytes.substr(mypos); + break; + case 27: + // Key Flags + read_array.call(this, 'keyFlags', bytes.substr(mypos)); + break; + case 28: + // Signer's User ID + this.signersUserId += bytes.substr(mypos); + break; + case 29: + // Reason for Revocation + this.reasonForRevocationFlag = bytes.charCodeAt(mypos++); + this.reasonForRevocationString = bytes.substr(mypos); + break; + case 30: + // Features + read_array.call(this, 'features', bytes.substr(mypos)); + break; + case 31: + // Signature Target + // (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) + this.signatureTargetPublicKeyAlgorithm = bytes.charCodeAt(mypos++); + this.signatureTargetHashAlgorithm = bytes.charCodeAt(mypos++); + + var len = crypto.getHashByteLength(this.signatureTargetHashAlgorithm); + + this.signatureTargetHash = bytes.substr(mypos, len); + break; + case 32: + // Embedded Signature + this.embeddedSignature = new Signature(); + this.embeddedSignature.read(bytes.substr(mypos)); + break; + default: + throw new Error("Unknown signature subpacket type " + type + " @:" + mypos); + } +}; + +// Produces data to produce signature on +Signature.prototype.toSign = function (type, data) { + var t = enums.signature; + + switch (type) { + case t.binary: + case t.text: + return data.getBytes(); + + case t.standalone: + return ''; + + case t.cert_generic: + case t.cert_persona: + case t.cert_casual: + case t.cert_positive: + case t.cert_revocation: + var packet, tag; + + if (data.userid !== undefined) { + tag = 0xB4; + packet = data.userid; + } else if (data.userattribute !== undefined) { + tag = 0xD1; + packet = data.userattribute; + } else throw new Error('Either a userid or userattribute packet needs to be ' + + 'supplied for certification.'); + + var bytes = packet.write(); + + if (this.version == 4) { + return this.toSign(t.key, data) + + String.fromCharCode(tag) + + util.writeNumber(bytes.length, 4) + + bytes; + } else if (this.version == 3) { + return this.toSign(t.key, data) + + bytes; + } + break; + + case t.subkey_binding: + case t.key_binding: + return this.toSign(t.key, data) + this.toSign(t.key, { + key: data.bind + }); + + case t.key: + if (data.key === undefined) + throw new Error('Key packet is required for this sigtature.'); + + return data.key.writeOld(); + + case t.key_revocation: + case t.subkey_revocation: + return this.toSign(t.key, data); + case t.timestamp: + return ''; + case t.third_party: + throw new Error('Not implemented'); + default: + throw new Error('Unknown signature type.'); + } +}; + + +Signature.prototype.calculateTrailer = function () { + // calculating the trailer + var trailer = ''; + // V3 signatures don't have a trailer + if (this.version == 3) return trailer; + trailer += String.fromCharCode(4); // Version + trailer += String.fromCharCode(0xFF); + trailer += util.writeNumber(this.signatureData.length, 4); + return trailer; +}; + + +/** + * verifys the signature packet. Note: not signature types are implemented + * @param {String|Object} data data which on the signature applies + * @param {module:packet/public_subkey|module:packet/public_key} key the public key to verify the signature + * @return {boolean} True if message is verified, else false. + */ +Signature.prototype.verify = function (key, data) { + var signatureType = enums.write(enums.signature, this.signatureType), + publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), + hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); + + var bytes = this.toSign(signatureType, data), + trailer = this.calculateTrailer(); + + + 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) + mpicount = 1; + // Algorithm-Specific Fields for DSA signatures: + // - MPI of DSA value r. + // - MPI of DSA value s. + else if (publicKeyAlgorithm == 17) + mpicount = 2; + + var mpi = [], + i = 0; + for (var j = 0; j < mpicount; j++) { + mpi[j] = new type_mpi(); + i += mpi[j].read(this.signature.substr(i)); + } + + this.verified = crypto.signature.verify(publicKeyAlgorithm, + hashAlgorithm, mpi, key.mpi, + bytes + this.signatureData + trailer); + + return this.verified; +}; + +/** + * Verifies signature expiration date + * @return {Boolean} true if expired + */ +Signature.prototype.isExpired = function () { + if (!this.signatureNeverExpires) { + return Date.now() > (this.created.getTime() + this.signatureExpirationTime*1000); + } + return false; +}; @@ -675,13 +675,13 @@ module.exports = function signature() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/signature_.html b/doc/signature_.html index ddf712fe..56d41e0a 100644 --- a/doc/signature_.html +++ b/doc/signature_.html @@ -35,6 +35,8 @@
+ +
Implementation of the Signature Packet (Tag 2)

@@ -44,74 +46,6 @@ 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.
-
-

new (require("packet/signature"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -174,6 +108,13 @@ block of text, and a signature that is a certification of a User ID.
+

Classes

+ +
+
Signature
+
+
+ @@ -184,681 +125,6 @@ block of text, and a signature that is a certification of a User ID.
-
-

isExpired() → {Boolean}

- - -
-
- - -
- Verifies signature expiration date -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- true if expired -
- - - -
-
- Type -
-
- -Boolean - - -
-
- - - - -
- - - -
-

read(bytes, position, len) → {module:packet/signature}

- - -
-
- - -
- parsing function for a signature packet (tag 2). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
bytes - - -String - - - - payload of a tag 2 packet
position - - -Integer - - - - position to start reading from the bytes string
len - - -Integer - - - - length of the packet or the remaining length of bytes at position
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- object representation -
- - - -
-
- Type -
-
- -module:packet/signature - - -
-
- - - - -
- - - -
-

sign(key, data)

- - -
-
- - -
- Signs provided data. This needs to be done prior to serialization. -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
key - - -module:packet/secret_key - - - - private key used to sign the message.
data - - -Object - - - - Contains packets to be signed.
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

verify(data, key) → {boolean}

- - -
-
- - -
- verifys the signature packet. Note: not signature types are implemented -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -String -| - -Object - - - - data which on the signature applies
key - - -module:packet/public_subkey -| - -module:packet/public_key - - - - the public key to verify the signature
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- True if message is verified, else false. -
- - - -
-
- Type -
-
- -boolean - - -
-
- - - - -
- - - -
-

write_all_sub_packets() → {String}

- - -
-
- - -
- Creates string of bytes with all subpacket data -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- a string-representation of a all subpacket data -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - -

<inner> write_sub_packet(type, data) → {String}

@@ -918,7 +184,7 @@ block of text, and a signature that is a certification of a User ID. - subpacket signature type. Signature types as described + subpacket signature type. Signature types as described in RFC4880 Section 5.2.3.2 @@ -973,7 +239,7 @@ in RFC4880 Section 5.2.3.2
Source:
@@ -1036,13 +302,13 @@ in RFC4880 Section 5.2.3.2
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html b/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html new file mode 100644 index 00000000..4efa61e6 --- /dev/null +++ b/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html @@ -0,0 +1,439 @@ + + + + + JSDoc: Class: SymEncryptedIntegrityProtected + + + + + + + + + + +
+ +

Class: SymEncryptedIntegrityProtected

+ + + + + +
+ +
+

+ packet/sym_encrypted_integrity_protected~ + + SymEncryptedIntegrityProtected +

+ +
+ +
+
+ + + + +
+

new SymEncryptedIntegrityProtected()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

encrypted

+ + +
+
+ +
+ The encrypted payload. +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ + + +
+

modification :Boolean

+ + +
+
+ +
+ If after decrypting the packet this is set to true, +a modification has been detected and thus the contents +should be discarded. +
+ + + +
Type:
+
    +
  • + +Boolean + + +
  • +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

decrypt(sessionKeyAlgorithm, key) → {String}

+ + +
+
+ + +
+ Decrypts the encrypted data contained in this object read_packet must +have been called before +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sessionKeyAlgorithm + + +Integer + + + + The selected symmetric encryption algorithm to be used
key + + +String + + + + The key of cipher blocksize length to be used
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ The decrypted data of this packet +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/sym_encrypted_integrity_protected.html b/doc/sym_encrypted_integrity_protected.html index 80784815..8a3225d5 100644 --- a/doc/sym_encrypted_integrity_protected.html +++ b/doc/sym_encrypted_integrity_protected.html @@ -35,6 +35,8 @@
+ +
Implementation of the Sym. Encrypted Integrity Protected Data Packet (Tag 18)
@@ -46,74 +48,6 @@ encrypted data. It is used in combination with a Modification Detection Code packet.
-
-

new (require("packet/sym_encrypted_integrity_protected"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -168,304 +102,20 @@ packet.
- - - - -

Members

+

Classes

- -
-

encrypted

- - -
-
- -
- The encrypted payload. -
- - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- - - -
-

modification :Boolean

- - -
-
- -
- If after decrypting the packet this is set to true, -a modification has been detected and thus the contents -should be discarded. -
- - - -
Type:
-
    -
  • - -Boolean - - -
  • -
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
SymEncryptedIntegrityProtected
+
-

Methods

- -
- -
-

decrypt(sessionKeyAlgorithm, key) → {String}

- - -
-
- - -
- Decrypts the encrypted data contained in this object read_packet must -have been called before -
- - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
sessionKeyAlgorithm - - -Integer - - - - The selected symmetric encryption algorithm to be used
key - - -String - - - - The key of cipher blocksize length to be used
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- The decrypted data of this packet -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- -
- - @@ -479,13 +129,13 @@ have been called before
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_integrity_protected.js.html b/doc/sym_encrypted_integrity_protected.js.html index a83f5c41..4852f9e3 100644 --- a/doc/sym_encrypted_integrity_protected.js.html +++ b/doc/sym_encrypted_integrity_protected.js.html @@ -56,13 +56,15 @@ * @module packet/sym_encrypted_integrity_protected */ +module.exports = SymEncryptedIntegrityProtected; + var util = require('../util'), crypto = require('../crypto'); /** * @constructor */ -module.exports = function sym_encrypted_integrity_protected() { +function SymEncryptedIntegrityProtected() { /** The encrypted payload. */ this.encrypted = null; // string /** @@ -73,78 +75,77 @@ module.exports = function sym_encrypted_integrity_protected() { */ this.modification = false; this.packets = null; +} + +SymEncryptedIntegrityProtected.prototype.read = function (bytes) { + // - A one-octet version number. The only currently defined value is 1. + var version = bytes.charCodeAt(0); + + if (version != 1) { + throw new Error('Invalid packet version.'); + } + + // - Encrypted data, the output of the selected symmetric-key cipher + // 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); +}; + +SymEncryptedIntegrityProtected.prototype.write = function () { + + // 1 = Version + return String.fromCharCode(1) + this.encrypted; +}; + +SymEncryptedIntegrityProtected.prototype.encrypt = function (sessionKeyAlgorithm, key) { + var bytes = this.packets.write(); + + var prefixrandom = crypto.getPrefixRandom(sessionKeyAlgorithm); + var prefix = prefixrandom + prefixrandom.charAt(prefixrandom.length - 2) + prefixrandom.charAt(prefixrandom.length - + 1); + + var tohash = bytes; - this.read = function (bytes) { - // - A one-octet version number. The only currently defined value is 1. - var version = bytes.charCodeAt(0); - - if (version != 1) { - throw new Error('Invalid packet version.'); - } - - // - Encrypted data, the output of the selected symmetric-key cipher - // 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() - - var prefixrandom = crypto.getPrefixRandom(sessionKeyAlgorithm); - var prefix = prefixrandom + prefixrandom.charAt(prefixrandom.length - 2) + prefixrandom.charAt(prefixrandom.length - - 1) - - var tohash = bytes; + // Modification detection code packet. + tohash += String.fromCharCode(0xD3); + tohash += String.fromCharCode(0x14); - // Modification detection code packet. - tohash += String.fromCharCode(0xD3); - tohash += String.fromCharCode(0x14); + tohash += crypto.hash.sha1(prefix + tohash); - tohash += crypto.hash.sha1(prefix + tohash); + 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 + * have been called before + * + * @param {Integer} sessionKeyAlgorithm + * The selected symmetric encryption algorithm to be used + * @param {String} key The key of cipher blocksize length to be used + * @return {String} The decrypted data of this packet + */ +SymEncryptedIntegrityProtected.prototype.decrypt = function (sessionKeyAlgorithm, key) { + var decrypted = crypto.cfb.decrypt( + sessionKeyAlgorithm, key, this.encrypted, false); - 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 - * have been called before - * - * @param {Integer} sessionKeyAlgorithm - * The selected symmetric encryption algorithm to be used - * @param {String} key The key of cipher blocksize length to be used - * @return {String} The decrypted data of this packet - */ - this.decrypt = function (sessionKeyAlgorithm, key) { - var decrypted = crypto.cfb.decrypt( - sessionKeyAlgorithm, key, this.encrypted, false); + // there must be a modification detection code packet as the + // last packet and everything gets hashed except the hash itself + this.hash = crypto.hash.sha1( + crypto.cfb.mdc(sessionKeyAlgorithm, key, this.encrypted) + decrypted.substring(0, decrypted.length - 20)); - // there must be a modification detection code packet as the - // last packet and everything gets hashed except the hash itself - this.hash = crypto.hash.sha1( - crypto.cfb.mdc(sessionKeyAlgorithm, key, this.encrypted) + decrypted.substring(0, decrypted.length - 20)); + var mdc = decrypted.substr(decrypted.length - 20, 20); - - var mdc = decrypted.substr(decrypted.length - 20, 20); - - if (this.hash != mdc) { - throw new Error('Modification detected.'); - } else - this.packets.read(decrypted.substr(0, decrypted.length - 22)); - }; + if (this.hash != mdc) { + throw new Error('Modification detected.'); + } else + this.packets.read(decrypted.substr(0, decrypted.length - 22)); };
@@ -156,13 +157,13 @@ module.exports = function sym_encrypted_integrity_protected() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html b/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html new file mode 100644 index 00000000..509873b3 --- /dev/null +++ b/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html @@ -0,0 +1,430 @@ + + + + + JSDoc: Class: SymEncryptedSessionKey + + + + + + + + + + +
+ +

Class: SymEncryptedSessionKey

+ + + + + +
+ +
+

+ packet/sym_encrypted_session_key~ + + SymEncryptedSessionKey +

+ +
+ +
+
+ + + + +
+

new SymEncryptedSessionKey()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

decrypt() → {String}

+ + +
+
+ + +
+ Decrypts the session key (only for public key encrypted session key +packets (tag 1) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ The unencrypted session key +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

read(input, position, len) → {module:packet/sym_encrypted_session_key}

+ + +
+
+ + +
+ Parsing function for a symmetric encrypted session key packet (tag 3). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Payload of a tag 1 packet
position + + +Integer + + + + Position to start reading from the input string
len + + +Integer + + + + Length of the packet or the remaining length of + input at position
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ Object representation +
+ + + +
+
+ Type +
+
+ +module:packet/sym_encrypted_session_key + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/sym_encrypted_session_key.html b/doc/sym_encrypted_session_key.html index 82399392..1dda29fd 100644 --- a/doc/sym_encrypted_session_key.html +++ b/doc/sym_encrypted_session_key.html @@ -35,6 +35,8 @@
+ +
Public-Key Encrypted Session Key Packets (Tag 1)

@@ -51,74 +53,6 @@ public key, decrypts the session key, and then uses the session key to decrypt the message.
-
-

new (require("packet/sym_encrypted_session_key"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -175,298 +109,23 @@ decrypt the message.
- - - - - - -

Methods

+

Classes

- -
-

decrypt() → {String}

- - -
-
- - -
- Decrypts the session key (only for public key encrypted session key -packets (tag 1) -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- The unencrypted session key -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- - - -
-

read(input, position, len) → {module:packet/sym_encrypted_session_key}

- - -
-
- - -
- Parsing function for a symmetric encrypted session key packet (tag 3). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - Payload of a tag 1 packet
position - - -Integer - - - - Position to start reading from the input string
len - - -Integer - - - - Length of the packet or the remaining length of - input at position
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- Object representation -
- - - -
-
- Type -
-
- -module:packet/sym_encrypted_session_key - - -
-
- - - - -
- +
SymEncryptedSessionKey
+
+ + + + + +
@@ -477,13 +136,13 @@ packets (tag 1)
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_session_key.js.html b/doc/sym_encrypted_session_key.js.html index 5fa2357c..54ab9e19 100644 --- a/doc/sym_encrypted_session_key.js.html +++ b/doc/sym_encrypted_session_key.js.html @@ -66,104 +66,106 @@ var type_s2k = require('../type/s2k.js'), enums = require('../enums.js'), crypto = require('../crypto'); +module.exports = SymEncryptedSessionKey; + /** * @constructor */ -module.exports = function sym_encrypted_session_key() { +function SymEncryptedSessionKey() { this.tag = 3; this.sessionKeyEncryptionAlgorithm = null; this.sessionKeyAlgorithm = 'aes256'; this.encrypted = null; this.s2k = new type_s2k(); +} - /** - * Parsing function for a symmetric encrypted session key packet (tag 3). - * - * @param {String} input Payload of a tag 1 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/sym_encrypted_session_key} Object representation - */ - this.read = function(bytes) { - // A one-octet version number. The only currently defined version is 4. - this.version = bytes.charCodeAt(0); +/** + * Parsing function for a symmetric encrypted session key packet (tag 3). + * + * @param {String} input Payload of a tag 1 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/sym_encrypted_session_key} Object representation + */ +SymEncryptedSessionKey.prototype.read = function(bytes) { + // A one-octet version number. The only currently defined version is 4. + this.version = bytes.charCodeAt(0); - // A one-octet number describing the symmetric algorithm used. - var algo = enums.read(enums.symmetric, bytes.charCodeAt(1)); + // A one-octet number describing the symmetric algorithm used. + var algo = enums.read(enums.symmetric, bytes.charCodeAt(1)); - // A string-to-key (S2K) specifier, length as defined above. - var s2klength = this.s2k.read(bytes.substr(2)); + // A string-to-key (S2K) specifier, length as defined above. + var s2klength = this.s2k.read(bytes.substr(2)); - // Optionally, the encrypted session key itself, which is decrypted - // with the string-to-key object. - var done = s2klength + 2; + // Optionally, the encrypted session key itself, which is decrypted + // with the string-to-key object. + var done = s2klength + 2; - if (done < bytes.length) { - this.encrypted = bytes.substr(done); - this.sessionKeyEncryptionAlgorithm = algo - } else - this.sessionKeyAlgorithm = algo; - }; + if (done < bytes.length) { + this.encrypted = bytes.substr(done); + this.sessionKeyEncryptionAlgorithm = algo; + } else + this.sessionKeyAlgorithm = algo; +}; - this.write = function() { - var algo = this.encrypted == null ? - this.sessionKeyAlgorithm : - this.sessionKeyEncryptionAlgorithm; +SymEncryptedSessionKey.prototype.write = function() { + var algo = this.encrypted === null ? + this.sessionKeyAlgorithm : + this.sessionKeyEncryptionAlgorithm; - var bytes = String.fromCharCode(this.version) + - String.fromCharCode(enums.write(enums.symmetric, algo)) + - this.s2k.write(); + var bytes = String.fromCharCode(this.version) + + String.fromCharCode(enums.write(enums.symmetric, algo)) + + this.s2k.write(); - if (this.encrypted != null) - bytes += this.encrypted; - return bytes; - }; + if (this.encrypted !== null) + bytes += this.encrypted; + return bytes; +}; - /** - * Decrypts the session key (only for public key encrypted session key - * packets (tag 1) - * - * @return {String} The unencrypted session key - */ - this.decrypt = function(passphrase) { - var algo = this.sessionKeyEncryptionAlgorithm != null ? - this.sessionKeyEncryptionAlgorithm : - this.sessionKeyAlgorithm; +/** + * Decrypts the session key (only for public key encrypted session key + * packets (tag 1) + * + * @return {String} The unencrypted session key + */ +SymEncryptedSessionKey.prototype.decrypt = function(passphrase) { + var algo = this.sessionKeyEncryptionAlgorithm !== null ? + this.sessionKeyEncryptionAlgorithm : + this.sessionKeyAlgorithm; - var length = crypto.cipher[algo].keySize; - var key = this.s2k.produce_key(passphrase, length); + var length = crypto.cipher[algo].keySize; + var key = this.s2k.produce_key(passphrase, length); - if (this.encrypted == null) { - this.sessionKey = key; + if (this.encrypted === null) { + this.sessionKey = key; - } else { - var decrypted = crypto.cfb.decrypt( - this.sessionKeyEncryptionAlgorithm, key, this.encrypted, true); + } else { + var decrypted = crypto.cfb.decrypt( + this.sessionKeyEncryptionAlgorithm, key, this.encrypted, true); - this.sessionKeyAlgorithm = enums.read(enums.symmetric, - decrypted[0].keyCodeAt()); + this.sessionKeyAlgorithm = enums.read(enums.symmetric, + decrypted[0].keyCodeAt()); - this.sessionKey = decrypted.substr(1); - } - }; + this.sessionKey = decrypted.substr(1); + } +}; - this.encrypt = function(passphrase) { - var length = crypto.getKeyLength(this.sessionKeyEncryptionAlgorithm); - var key = this.s2k.produce_key(passphrase, length); +SymEncryptedSessionKey.prototype.encrypt = function(passphrase) { + var length = crypto.getKeyLength(this.sessionKeyEncryptionAlgorithm); + var key = this.s2k.produce_key(passphrase, length); - var private_key = String.fromCharCode( - enums.write(enums.symmetric, this.sessionKeyAlgorithm)) + + var private_key = String.fromCharCode( + enums.write(enums.symmetric, this.sessionKeyAlgorithm)) + - crypto.getRandomBytes( - crypto.getKeyLength(this.sessionKeyAlgorithm)); + crypto.getRandomBytes( + crypto.getKeyLength(this.sessionKeyAlgorithm)); - this.encrypted = crypto.cfb.encrypt( - crypto.getPrefixRandom(this.sessionKeyEncryptionAlgorithm), - this.sessionKeyEncryptionAlgorithm, key, private_key, true); - }; + this.encrypted = crypto.cfb.encrypt( + crypto.getPrefixRandom(this.sessionKeyEncryptionAlgorithm), + this.sessionKeyEncryptionAlgorithm, key, private_key, true); };
@@ -175,13 +177,13 @@ module.exports = function sym_encrypted_session_key() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/symmetrically_encrypted-SymmetricallyEncrypted.html b/doc/symmetrically_encrypted-SymmetricallyEncrypted.html new file mode 100644 index 00000000..a25a0d7c --- /dev/null +++ b/doc/symmetrically_encrypted-SymmetricallyEncrypted.html @@ -0,0 +1,361 @@ + + + + + JSDoc: Class: SymmetricallyEncrypted + + + + + + + + + + +
+ +

Class: SymmetricallyEncrypted

+ + + + + +
+ +
+

+ packet/symmetrically_encrypted~ + + SymmetricallyEncrypted +

+ +
+ +
+
+ + + + +
+

new SymmetricallyEncrypted()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

packets :module:packet/packetlist

+ + +
+
+ +
+ Decrypted packets contained within. +
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

decrypt(sessionKeyAlgorithm, key)

+ + +
+
+ + +
+ Symmetrically decrypt the packet data +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sessionKeyAlgorithm + + +Integer + + + + Symmetric key algorithm to use // See RFC4880 9.2
key + + +String + + + + Key as string with the corresponding length to the + algorithm
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/symmetrically_encrypted.html b/doc/symmetrically_encrypted.html index ad3006af..de061a78 100644 --- a/doc/symmetrically_encrypted.html +++ b/doc/symmetrically_encrypted.html @@ -35,6 +35,8 @@
+ +
Implementation of the Symmetrically Encrypted Data Packet (Tag 9)

@@ -45,74 +47,6 @@ theory other Symmetrically Encrypted Data packets or sequences of packets that form whole OpenPGP messages).
-
-

new (require("packet/symmetrically_encrypted"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -165,226 +99,20 @@ that form whole OpenPGP messages).
- - - - -

Members

+

Classes

- -
-

packets :module:packet/packetlist

- - -
-
- -
- Decrypted packets contained within. -
- - - -
Type:
- - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
SymmetricallyEncrypted
+
-

Methods

- -
- -
-

decrypt(sessionKeyAlgorithm, key)

- - -
-
- - -
- Symmetrically decrypt the packet data -
- - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
sessionKeyAlgorithm - - -Integer - - - - Symmetric key algorithm to use // See RFC4880 9.2
key - - -String - - - - Key as string with the corresponding length to the - algorithm
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- -
- - @@ -398,13 +126,13 @@ that form whole OpenPGP messages).
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/symmetrically_encrypted.js.html b/doc/symmetrically_encrypted.js.html index befbf8e1..b8b218b4 100644 --- a/doc/symmetrically_encrypted.js.html +++ b/doc/symmetrically_encrypted.js.html @@ -54,47 +54,49 @@ * @module packet/symmetrically_encrypted */ +module.exports = SymmetricallyEncrypted; + var crypto = require('../crypto'); /** * @constructor */ -module.exports = function symmetrically_encrypted() { +function SymmetricallyEncrypted() { this.encrypted = null; /** Decrypted packets contained within. * @type {module:packet/packetlist} */ this.packets = null; +} - this.read = function(bytes) { - this.encrypted = bytes; - }; +SymmetricallyEncrypted.prototype.read = function (bytes) { + this.encrypted = bytes; +}; - this.write = function() { - return this.encrypted; - }; +SymmetricallyEncrypted.prototype.write = function () { + return this.encrypted; +}; - /** - * Symmetrically decrypt the packet data - * - * @param {Integer} sessionKeyAlgorithm - * Symmetric key algorithm to use // See RFC4880 9.2 - * @param {String} key - * Key as string with the corresponding length to the - * algorithm - */ - this.decrypt = function(sessionKeyAlgorithm, key) { - var decrypted = crypto.cfb.decrypt( - sessionKeyAlgorithm, key, this.encrypted, true); +/** + * Symmetrically decrypt the packet data + * + * @param {Integer} sessionKeyAlgorithm + * Symmetric key algorithm to use // See RFC4880 9.2 + * @param {String} key + * Key as string with the corresponding length to the + * algorithm + */ +SymmetricallyEncrypted.prototype.decrypt = function (sessionKeyAlgorithm, key) { + var decrypted = crypto.cfb.decrypt( + sessionKeyAlgorithm, key, this.encrypted, true); - this.packets.read(decrypted); - }; + this.packets.read(decrypted); +}; - this.encrypt = function(algo, key) { - var data = this.packets.write(); +SymmetricallyEncrypted.prototype.encrypt = function (algo, key) { + var data = this.packets.write(); - this.encrypted = crypto.cfb.encrypt( - crypto.getPrefixRandom(algo), algo, data, key, true); - }; + this.encrypted = crypto.cfb.encrypt( + crypto.getPrefixRandom(algo), algo, data, key, true); };
@@ -106,13 +108,13 @@ module.exports = function symmetrically_encrypted() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/trust-Trust.html b/doc/trust-Trust.html new file mode 100644 index 00000000..6396a902 --- /dev/null +++ b/doc/trust-Trust.html @@ -0,0 +1,148 @@ + + + + + JSDoc: Class: Trust + + + + + + + + + + +
+ +

Class: Trust

+ + + + + +
+ +
+

+ packet/trust~ + + Trust +

+ +
+ +
+
+ + + + +
+

new Trust()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/trust.html b/doc/trust.html index 4ab78f4c..94d672ac 100644 --- a/doc/trust.html +++ b/doc/trust.html @@ -35,72 +35,6 @@
- - -
-

new (require("packet/trust"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - @@ -151,6 +85,13 @@ +

Classes

+ +
+
Trust
+
+
+ @@ -171,13 +112,13 @@

- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/trust.js.html b/doc/trust.js.html index aa796bc7..29582b84 100644 --- a/doc/trust.js.html +++ b/doc/trust.js.html @@ -29,11 +29,12 @@ * @module packet/trust */ +module.exports = Trust; + /** * @constructor */ -module.exports = function trust() { - +function Trust() { };
@@ -45,13 +46,13 @@ module.exports = function trust() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/twofish.html b/doc/twofish.html index a13b1507..1b496f80 100644 --- a/doc/twofish.html +++ b/doc/twofish.html @@ -105,13 +105,13 @@
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:40 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST)
diff --git a/doc/twofish.js.html b/doc/twofish.js.html index a4354261..c056e897 100644 --- a/doc/twofish.js.html +++ b/doc/twofish.js.html @@ -400,7 +400,7 @@ function TF(key) { this.encrypt = function(block) { return this.tf.encrypt([].concat(block), 0); - } + }; } @@ -417,13 +417,13 @@ module.exports.blockSize = TF.prototype.blockSize = 16;
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/user_attribute-UserAttribute.html b/doc/user_attribute-UserAttribute.html new file mode 100644 index 00000000..b00ee713 --- /dev/null +++ b/doc/user_attribute-UserAttribute.html @@ -0,0 +1,269 @@ + + + + + JSDoc: Class: UserAttribute + + + + + + + + + + +
+ +

Class: UserAttribute

+ + + + + +
+ +
+

+ packet/user_attribute~ + + UserAttribute +

+ +
+ +
+
+ + + + +
+

new UserAttribute()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

read(input)

+ + +
+
+ + +
+ parsing function for a user attribute packet (tag 17). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + payload of a tag 17 packet
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/user_attribute.html b/doc/user_attribute.html index 044cd0e1..92f93cc8 100644 --- a/doc/user_attribute.html +++ b/doc/user_attribute.html @@ -35,6 +35,8 @@
+ +
Implementation of the User Attribute Packet (Tag 17)

@@ -54,74 +56,6 @@ an implementation may use any method desired. module packet/user_attribute
-
-

new (require("packet/user_attribute"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -168,137 +102,23 @@ module packet/user_attribute
- - - - - - -

Methods

+

Classes

- -
-

read(input)

- - -
-
- - -
- parsing function for a user attribute packet (tag 17). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - payload of a tag 17 packet
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- +
UserAttribute
+
+ + + + + +
@@ -309,13 +129,13 @@ module packet/user_attribute
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/user_attribute.js.html b/doc/user_attribute.js.html index 81e0c7cf..e34f9681 100644 --- a/doc/user_attribute.js.html +++ b/doc/user_attribute.js.html @@ -65,27 +65,28 @@ var util = require('../util'), packet = require('./packet.js'); +module.exports = UserAttribute; + /** * @constructor */ -module.exports = function user_attribute() { - this.tag = 17; +function UserAttribute() { this.attributes = []; +} - /** - * parsing function for a user attribute packet (tag 17). - * @param {String} input payload of a tag 17 packet - */ - this.read = function(bytes) { - var i = 0; - while (i < bytes.length) { - var len = packet.readSimpleLength(bytes.substr(i)); - i += len.offset; +/** + * parsing function for a user attribute packet (tag 17). + * @param {String} input payload of a tag 17 packet + */ +UserAttribute.prototype.read = function(bytes) { + var i = 0; + while (i < bytes.length) { + var len = packet.readSimpleLength(bytes.substr(i)); + i += len.offset; - this.attributes.push(bytes.substr(i, len.len)); - i += len.len; - } - }; + this.attributes.push(bytes.substr(i, len.len)); + i += len.len; + } }; @@ -97,13 +98,13 @@ module.exports = function user_attribute() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/userid-Userid.html b/doc/userid-Userid.html new file mode 100644 index 00000000..13869573 --- /dev/null +++ b/doc/userid-Userid.html @@ -0,0 +1,429 @@ + + + + + JSDoc: Class: Userid + + + + + + + + + + +
+ +

Class: Userid

+ + + + + +
+ +
+

+ packet/userid~ + + Userid +

+ +
+ +
+
+ + + + +
+

new Userid()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+

userid :String

+ + +
+
+ +
+ A string containing the user id. Usually in the form +John Doe +
+ + + +
Type:
+
    +
  • + +String + + +
  • +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ +
+

read(input)

+ + +
+
+ + +
+ Parsing function for a user id packet (tag 13). +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + payload of a tag 13 packet
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

write() → {String}

+ + +
+
+ + +
+ Creates a string representation of the user id packet +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ string representation +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) +
+ + + + + \ No newline at end of file diff --git a/doc/userid.html b/doc/userid.html index 577681ef..2e8ae624 100644 --- a/doc/userid.html +++ b/doc/userid.html @@ -35,6 +35,8 @@
+ +
Implementation of the User ID Packet (Tag 13)

@@ -45,74 +47,6 @@ restrictions on its content. The packet length in the header specifies the length of the User ID.
-
-

new (require("packet/userid"))()

- - -
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
@@ -165,293 +99,19 @@ specifies the length of the User ID.
- - - - -

Members

+

Classes

- -
-

userid :String

- - -
-
- -
- A string containing the user id. Usually in the form -John Doe -
- - - -
Type:
-
    -
  • - -String - - -
  • -
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- +
Userid
+
-

Methods

- -
- -
-

read(input)

-
-
-
- Parsing function for a user id packet (tag 13). -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -String - - - - payload of a tag 13 packet
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
- - - -
-

write() → {String}

- - -
-
- - -
- Creates a string representation of the user id packet -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- string representation -
- - - -
-
- Type -
-
- -String - - -
-
- - - - -
- -
- @@ -466,13 +126,13 @@ John Doe
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:44 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST)
diff --git a/doc/userid.js.html b/doc/userid.js.html index 25f1adf3..f625c5dc 100644 --- a/doc/userid.js.html +++ b/doc/userid.js.html @@ -54,35 +54,36 @@ * @module packet/userid */ +module.exports = Userid; + var util = require('../util'); /** * @constructor */ -module.exports = function userid() { +function Userid() { /** A string containing the user id. Usually in the form * John Doe <john@example.com> * @type {String} */ this.userid = ''; - - - /** - * Parsing function for a user id packet (tag 13). - * @param {String} input payload of a tag 13 packet - */ - this.read = function (bytes) { - this.userid = util.decode_utf8(bytes); - }; - - /** - * Creates a string representation of the user id packet - * @return {String} string representation - */ - this.write = function () { - return util.encode_utf8(this.userid); - }; } + +/** + * Parsing function for a user id packet (tag 13). + * @param {String} input payload of a tag 13 packet + */ +Userid.prototype.read = function (bytes) { + this.userid = util.decode_utf8(bytes); +}; + +/** + * Creates a string representation of the user id packet + * @return {String} string representation + */ +Userid.prototype.write = function () { + return util.encode_utf8(this.userid); +};
@@ -93,13 +94,13 @@ module.exports = function userid() {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/doc/util.html b/doc/util.html index bbbe6e34..db143f10 100644 --- a/doc/util.html +++ b/doc/util.html @@ -2000,13 +2000,13 @@ the same as bin2str.
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:45 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:13 GMT-0800 (PST)
diff --git a/doc/util.js.html b/doc/util.js.html index dac2954e..152fc6b5 100644 --- a/doc/util.js.html +++ b/doc/util.js.html @@ -97,7 +97,7 @@ module.exports = { while (h.length < 2) h = "0" + h; r.push(" " + h); i++; - if (i % 32 == 0) + if (i % 32 === 0) r.push("\n "); } return r.join(''); @@ -109,7 +109,7 @@ module.exports = { * @return {String} String containing the hexadecimal values */ hexstrdump: function (str) { - if (str == null) + if (str === null) return ""; var r = []; var e = str.length; @@ -277,7 +277,7 @@ module.exports = { getLeftNBits: function (string, bitcount) { var rest = bitcount % 8; - if (rest == 0) + if (rest === 0) return string.substring(0, bitcount / 8); var bytes = (bitcount - rest) / 8 + 1; var result = string.substring(0, bytes); @@ -293,7 +293,7 @@ module.exports = { */ shiftRight: function (value, bitcount) { var temp = util.str2bin(value); - if (bitcount % 8 != 0) { + if (bitcount % 8 !== 0) { for (var i = temp.length - 1; i >= 0; i--) { temp[i] >>= bitcount % 8; if (i > 0) @@ -339,13 +339,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Thu Jan 02 2014 13:02:39 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST)
diff --git a/example/encryption.html b/example/encryption.html index 6f22d0cf..a756154e 100644 --- a/example/encryption.html +++ b/example/encryption.html @@ -135,13 +135,13 @@ function run(encrypt) { var sesskey = null; // Find the private (sub)key for the session key of the message for (var i = 0; i< msg[0].sessionKeys.length; i++) { - if (priv_key[0].privateKeyPacket.publicKey.getKeyId() == msg[0].sessionKeys[i].keyId.bytes) { + if (priv_key[0].privateKeyPacket.PublicKey.getKeyId() == msg[0].sessionKeys[i].keyId.bytes) { keymat = { key: priv_key[0], keymaterial: priv_key[0].privateKeyPacket}; sesskey = msg[0].sessionKeys[i]; break; } for (var j = 0; j < priv_key[0].subKeys.length; j++) { - if (priv_key[0].subKeys[j].publicKey.getKeyId() == msg[0].sessionKeys[i].keyId.bytes) { + if (priv_key[0].subKeys[j].PublicKey.getKeyId() == msg[0].sessionKeys[i].keyId.bytes) { keymat = { key: priv_key[0], keymaterial: priv_key[0].subKeys[j]}; sesskey = msg[0].sessionKeys[i]; break; diff --git a/src/cleartext.js b/src/cleartext.js index e7d8f260..4d9a4c95 100644 --- a/src/cleartext.js +++ b/src/cleartext.js @@ -43,7 +43,7 @@ function CleartextMessage(text, packetlist) { } // normalize EOL to canonical form this.text = text.replace(/\r/g, '').replace(/[\t ]+\n/g, "\n").replace(/\n/g,"\r\n"); - this.packets = packetlist || new packet.list(); + this.packets = packetlist || new packet.List(); } /** @@ -64,11 +64,11 @@ CleartextMessage.prototype.getSigningKeyIds = function() { * @param {Array} privateKeys private keys with decrypted secret key data for signing */ CleartextMessage.prototype.sign = function(privateKeys) { - var packetlist = new packet.list(); - var literalDataPacket = new packet.literal(); + var packetlist = new packet.List(); + var literalDataPacket = new packet.Literal(); literalDataPacket.setText(this.text); for (var i = 0; i < privateKeys.length; i++) { - var signaturePacket = new packet.signature(); + var signaturePacket = new packet.Signature(); signaturePacket.signatureType = enums.signature.text; signaturePacket.hashAlgorithm = config.prefer_hash_algorithm; var signingKeyPacket = privateKeys[i].getSigningKeyPacket(); @@ -88,7 +88,7 @@ CleartextMessage.prototype.sign = function(privateKeys) { CleartextMessage.prototype.verify = function(publicKeys) { var result = []; var signatureList = this.packets.filterByTag(enums.packet.signature); - var literalDataPacket = new packet.literal(); + var literalDataPacket = new packet.Literal(); // we assume that cleartext signature is generated based on UTF8 cleartext literalDataPacket.setText(this.text); publicKeys.forEach(function(pubKey) { @@ -140,7 +140,7 @@ function readArmored(armoredText) { if (input.type !== enums.armor.signed) { throw new Error('No cleartext signed message.'); } - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.read(input.data); var newMessage = new CleartextMessage(input.text, packetlist); return newMessage; diff --git a/src/config/localStorage.js b/src/config/localStorage.js index 7f77e861..fe59fdf3 100644 --- a/src/config/localStorage.js +++ b/src/config/localStorage.js @@ -3,29 +3,31 @@ * @module config/localStorage */ +module.exports = LocalStorage; + /** * @constructor */ -module.exports = function localStorage() { +function LocalStorage() { +} - /** - * 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)); - }; +/** + * Reads the config out of the HTML5 local storage + * and initializes the object config. + * if config is null the default config will be used + */ +LocalStorage.prototype.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 + */ +LocalStorage.prototype.write = function () { + window.localStorage.setItem("config", JSON.stringify(this.config)); }; diff --git a/src/enums.js b/src/enums.js index 97ab8f99..b41ca639 100644 --- a/src/enums.js +++ b/src/enums.js @@ -76,23 +76,23 @@ module.exports = { * @readonly */ packet: { - public_key_encrypted_session_key: 1, + publicKeyEncryptedSessionKey: 1, signature: 2, - sym_encrypted_session_key: 3, - one_pass_signature: 4, - secret_key: 5, - public_key: 6, - secret_subkey: 7, + symEncryptedSessionKey: 3, + onePassSignature: 4, + secretKey: 5, + publicKey: 6, + secretSubkey: 7, compressed: 8, - symmetrically_encrypted: 9, + symmetricallyEncrypted: 9, marker: 10, literal: 11, trust: 12, userid: 13, - public_subkey: 14, - user_attribute: 17, - sym_encrypted_integrity_protected: 18, - modification_detection_code: 19 + publicSubkey: 14, + userAttribute: 17, + symEncryptedIntegrityProtected: 18, + modificationDetectionCode: 19 }, /** Data types in the literal packet diff --git a/src/key.js b/src/key.js index ddea303e..cb9b32f4 100644 --- a/src/key.js +++ b/src/key.js @@ -59,19 +59,19 @@ Key.prototype.packetlist2structure = function(packetlist) { var user, primaryKeyId, subKey; for (var i = 0; i < packetlist.length; i++) { switch (packetlist[i].tag) { - case enums.packet.public_key: - case enums.packet.secret_key: + case enums.packet.publicKey: + case enums.packet.secretKey: this.primaryKey = packetlist[i]; primaryKeyId = this.primaryKey.getKeyId(); break; case enums.packet.userid: - case enums.packet.user_attribute: + case enums.packet.userAttribute: user = new User(packetlist[i]); if (!this.users) this.users = []; this.users.push(user); break; - case enums.packet.public_subkey: - case enums.packet.secret_subkey: + case enums.packet.publicSubkey: + case enums.packet.secretSubkey: user = null; if (!this.subKeys) this.subKeys = []; subKey = new SubKey(packetlist[i]); @@ -124,7 +124,7 @@ Key.prototype.packetlist2structure = function(packetlist) { * @return {module:packet/packetlist} The packets that form a key */ Key.prototype.toPacketlist = function() { - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.push(this.primaryKey); packetlist.push(this.revocationSignature); packetlist.concat(this.directSignatures); @@ -201,7 +201,7 @@ function findKey(keys, keyIds) { * @return {(module:packet/public_subkey|module:packet/public_key|null)} */ Key.prototype.getPublicKeyPacket = function(keyIds) { - if (this.primaryKey.tag == enums.packet.public_key) { + if (this.primaryKey.tag == enums.packet.publicKey) { return findKey(this.getAllKeyPackets(), keyIds); } else { return null; @@ -214,7 +214,7 @@ Key.prototype.getPublicKeyPacket = function(keyIds) { * @return {(module:packet/secret_subkey|module:packet/secret_key|null)} */ Key.prototype.getPrivateKeyPacket = function(keyIds) { - if (this.primaryKey.tag == enums.packet.secret_key) { + if (this.primaryKey.tag == enums.packet.secretKey) { return findKey(this.getAllKeyPackets(), keyIds); } else { return null; @@ -240,7 +240,7 @@ Key.prototype.getUserIds = function() { * @return {Boolean} */ Key.prototype.isPublic = function() { - return this.primaryKey.tag == enums.packet.public_key; + return this.primaryKey.tag == enums.packet.publicKey; }; /** @@ -248,7 +248,7 @@ Key.prototype.isPublic = function() { * @return {Boolean} */ Key.prototype.isPrivate = function() { - return this.primaryKey.tag == enums.packet.secret_key; + return this.primaryKey.tag == enums.packet.secretKey; }; /** @@ -256,20 +256,20 @@ Key.prototype.isPrivate = function() { * @return {module:key~Key} new public Key */ Key.prototype.toPublic = function() { - var packetlist = new packet.list(); + var packetlist = new packet.List(); var keyPackets = this.toPacketlist(); var bytes; for (var i = 0; i < keyPackets.length; i++) { switch (keyPackets[i].tag) { - case enums.packet.secret_key: + case enums.packet.secretKey: bytes = keyPackets[i].writePublicKey(); - var pubKeyPacket = new packet.public_key(); + var pubKeyPacket = new packet.PublicKey(); pubKeyPacket.read(bytes); packetlist.push(pubKeyPacket); break; - case enums.packet.secret_subkey: + case enums.packet.secretSubkey: bytes = keyPackets[i].writePublicKey(); - var pubSubkeyPacket = new packet.public_subkey(); + var pubSubkeyPacket = new packet.PublicSubkey(); pubSubkeyPacket.read(bytes); packetlist.push(pubSubkeyPacket); break; @@ -487,7 +487,7 @@ function User(userPacket) { return new User(userPacket); } this.userId = userPacket.tag == enums.packet.userid ? userPacket : null; - this.userAttribute = userPacket.tag == enums.packet.user_attribute ? userPacket : null; + this.userAttribute = userPacket.tag == enums.packet.userAttribute ? userPacket : null; this.selfCertifications = null; this.otherCertifications = null; this.revocationCertifications = null; @@ -498,7 +498,7 @@ function User(userPacket) { * @return {module:packet/packetlist} */ User.prototype.toPacketlist = function() { - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.push(this.userId || this.userAttribute); packetlist.concat(this.revocationCertifications); packetlist.concat(this.selfCertifications); @@ -604,7 +604,7 @@ function SubKey(subKeyPacket) { * @return {module:packet/packetlist} */ SubKey.prototype.toPacketlist = function() { - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.push(this.subKey); packetlist.push(this.revocationSignature); packetlist.push(this.bindingSignature); @@ -682,9 +682,9 @@ function readArmored(armoredText) { if (!(input.type == enums.armor.public_key || input.type == enums.armor.private_key)) { throw new Error('Armored text not of type key'); } - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.read(input.data); - var keyIndex = packetlist.indexOfTag(enums.packet.public_key, enums.packet.secret_key); + var keyIndex = packetlist.indexOfTag(enums.packet.publicKey, enums.packet.secretKey); if (keyIndex.length === 0) { throw new Error('No key packet found in armored text'); } @@ -717,20 +717,20 @@ function readArmored(armoredText) { * @static */ function generate(keyType, numBits, userId, passphrase) { - var packetlist = new packet.list(); + var packetlist = new packet.List(); - var secretKeyPacket = new packet.secret_key(); + var secretKeyPacket = new packet.SecretKey(); secretKeyPacket.algorithm = enums.read(enums.publicKey, keyType); secretKeyPacket.generate(numBits); secretKeyPacket.encrypt(passphrase); - var userIdPacket = new packet.userid(); + var userIdPacket = new packet.Userid(); userIdPacket.read(userId); var dataToSign = {}; dataToSign.userid = userIdPacket; dataToSign.key = secretKeyPacket; - var signaturePacket = new packet.signature(); + var signaturePacket = new packet.Signature(); signaturePacket.signatureType = enums.signature.cert_generic; signaturePacket.publicKeyAlgorithm = keyType; //TODO we should load preferred hash from config, or as input to this function @@ -738,7 +738,7 @@ function generate(keyType, numBits, userId, passphrase) { signaturePacket.keyFlags = [enums.keyFlags.certify_keys | enums.keyFlags.sign_data]; signaturePacket.sign(secretKeyPacket, dataToSign); - var secretSubkeyPacket = new packet.secret_subkey(); + var secretSubkeyPacket = new packet.SecretSubkey(); secretSubkeyPacket.algorithm = enums.read(enums.publicKey, keyType); secretSubkeyPacket.generate(numBits); secretSubkeyPacket.encrypt(passphrase); @@ -746,7 +746,7 @@ function generate(keyType, numBits, userId, passphrase) { dataToSign = {}; dataToSign.key = secretKeyPacket; dataToSign.bind = secretSubkeyPacket; - var subkeySignaturePacket = new packet.signature(); + var subkeySignaturePacket = new packet.Signature(); subkeySignaturePacket.signatureType = enums.signature.subkey_binding; subkeySignaturePacket.publicKeyAlgorithm = keyType; //TODO we should load preferred hash from config, or as input to this function diff --git a/src/keyring/keyring.js b/src/keyring/keyring.js index 22f33db3..8876da6d 100644 --- a/src/keyring/keyring.js +++ b/src/keyring/keyring.js @@ -31,160 +31,159 @@ var openpgp = require('openpgp'); * @return {Boolean} True if the input matches the specified key */ -/** +module.exports = Keyring; + + /** * 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; +function Keyring(storeHandler) { + this.storeHandler = storeHandler || new (require('./localstore.js'))(); this.keys = this.storeHandler.load(); - - /** - * Calls the storeHandler to save the 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(); - for (var i; i < keyEmails.length; i++) { - //we need to get just the email from the userid key - keyEmail = keyEmails[i].split('<')[1].split('>')[0].trim().toLowerCase(); - if (keyEmail == email) { - return true; - } - } - 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++) { - if (openpgp.util.hexstrdump(keyids[i].write()) == id) { - return true; - } - } - return false; - } - - /** - * searches all public keys in the keyring matching the address or address part of the user ids - * @param {Array} 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} 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)) { - results.push(key); - } - break; - case openpgp.enums.packet.private_key: - if (key.isPrivate() && identityFunction(identityInput, key)) { - results.push(key); - } - break; - } - } - return results; - } - - /** - * searches all public keys in the keyring matching the address or address part of the user ids - * @param {String} email email address to search for - * @return {Array} The public keys associated with provided email address. - */ - 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} private keys found - */ - this.getPrivateKeyForAddress = function (email) { - return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.secret_key); - }; - - /** - * Searches the keyring for public keys having the specified key id - * @param {String} keyId provided as string of hex number (lowercase) - * @return {Array} public keys found - */ - 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 - */ - this.importKey = function (armored) { - this.keys = this.keys.concat(openpgp.key.readArmored(armored).keys); - - return true; - }; - - /** - * 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 - */ - this.exportKey = function (index) { - return this.keys[index].armor(); - }; - - /** - * 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 - */ - this.removeKey = function (index) { - var removed = this.keys.splice(index, 1); - - return removed; - }; - - /** - * 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 - */ - this.exportPublicKey = function (index) { - return this.keys[index].toPublic().armor(); - }; +}; + +/** + * Calls the storeHandler to save the keys + */ +Keyring.prototype.store = function () { + this.storeHandler.store(this.keys); +}; + +/** + * Clear the keyring - erase all the keys + */ +Keyring.prototype.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(); + for (var i; i < keyEmails.length; i++) { + //we need to get just the email from the userid key + keyEmail = keyEmails[i].split('<')[1].split('>')[0].trim().toLowerCase(); + if (keyEmail == email) { + return true; + } + } + 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++) { + if (openpgp.util.hexstrdump(keyids[i].write()) == id) { + return true; + } + } + return false; +} + +/** + * searches all public keys in the keyring matching the address or address part of the user ids + * @param {Array} 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} 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.publicKey: + if (key.isPublic() && identityFunction(identityInput, key)) { + results.push(key); + } + break; + case openpgp.enums.packet.private_key: + if (key.isPrivate() && identityFunction(identityInput, key)) { + results.push(key); + } + break; + } + } + return results; +} + +/** + * searches all public keys in the keyring matching the address or address part of the user ids + * @param {String} email email address to search for + * @return {Array} The public keys associated with provided email address. + */ +Keyring.prototype.getPublicKeyForAddress = function (email) { + return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.publicKey); +}; + +/** + * Searches the keyring for a private key containing the specified email address + * @param {String} email email address to search for + * @return {Array} private keys found + */ +Keyring.prototype.getPrivateKeyForAddress = function (email) { + return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.secretKey); +}; + +/** + * Searches the keyring for public keys having the specified key id + * @param {String} keyId provided as string of hex number (lowercase) + * @return {Array} public keys found + */ +Keyring.prototype.getKeysForKeyId = function (keyId) { + return checkForIdentityAndKeyTypeMatch(this.keys, idCheck, keyId, openpgp.enums.packet.publicKey); +}; + +/** + * Imports a key from an ascii armored message + * @param {String} armored message to read the keys/key from + */ +Keyring.prototype.importKey = function (armored) { + this.keys = this.keys.concat(openpgp.key.readArmored(armored).keys); + + return true; +}; + +/** + * 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 + */ +Keyring.prototype.exportKey = function (index) { + return this.keys[index].armor(); +}; + +/** + * 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 + */ +Keyring.prototype.removeKey = function (index) { + var removed = this.keys.splice(index, 1); + + return removed; +}; + +/** + * 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 + */ +Keyring.prototype.exportPublicKey = function (index) { + return this.keys[index].toPublic().armor(); }; diff --git a/src/keyring/localstore.js b/src/keyring/localstore.js index 4fc1fd8b..c9c18411 100644 --- a/src/keyring/localstore.js +++ b/src/keyring/localstore.js @@ -20,37 +20,39 @@ * @requires openpgp * @module keyring/localstore */ +module.exports = LocalStore; var openpgp = require('openpgp'); -module.exports = function () { - /** - * Load the keyring from HTML5 local storage and initializes this instance. - * @return {Array} array of keys retrieved from localstore - */ - this.load = function () { - var armoredKeys = JSON.parse(window.localStorage.getItem("armoredKeys")); - 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); - } - } - return keys; - }; +function LocalStore() { +} - /** - * Saves the current state of the keyring to HTML5 local storage. - * The privateKeys array and publicKeys array gets Stringified using JSON - * @param {Array} keys array of keys to save in localstore - */ - this.store = function (keys) { - var armoredKeys = []; - for (var i = 0; i < keys.length; i++) { - armoredKeys.push(keys[i].armor()); +/** + * Load the keyring from HTML5 local storage and initializes this instance. + * @return {Array} array of keys retrieved from localstore + */ +LocalStore.prototype.load = function () { + var armoredKeys = JSON.parse(window.localStorage.getItem("armoredKeys")); + 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); } - window.localStorage.setItem("armoredKeys", JSON.stringify(armoredKeys)); - }; + } + 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} keys array of keys to save in localstore + */ +LocalStore.prototype.store = function (keys) { + var armoredKeys = []; + for (var i = 0; i < keys.length; i++) { + armoredKeys.push(keys[i].armor()); + } + window.localStorage.setItem("armoredKeys", JSON.stringify(armoredKeys)); }; diff --git a/src/message.js b/src/message.js index f2c9dfae..111c04a2 100644 --- a/src/message.js +++ b/src/message.js @@ -42,7 +42,7 @@ function Message(packetlist) { if (!(this instanceof Message)) { return new Message(packetlist); } - this.packets = packetlist || new packet.list(); + this.packets = packetlist || new packet.List(); } /** @@ -51,7 +51,7 @@ function Message(packetlist) { */ Message.prototype.getEncryptionKeyIds = function() { var keyIds = []; - var pkESKeyPacketlist = this.packets.filterByTag(enums.packet.public_key_encrypted_session_key); + var pkESKeyPacketlist = this.packets.filterByTag(enums.packet.publicKeyEncryptedSessionKey); pkESKeyPacketlist.forEach(function(packet) { keyIds.push(packet.publicKeyId); }); @@ -66,7 +66,7 @@ Message.prototype.getSigningKeyIds = function() { var keyIds = []; var msg = this.unwrapCompressed(); // search for one pass signatures - var onePassSigList = msg.packets.filterByTag(enums.packet.one_pass_signature); + var onePassSigList = msg.packets.filterByTag(enums.packet.onePassSignature); onePassSigList.forEach(function(packet) { keyIds.push(packet.signingKeyId); }); @@ -93,7 +93,7 @@ Message.prototype.decrypt = function(privateKey) { } var privateKeyPacket = privateKey.getPrivateKeyPacket(encryptionKeyIds); if (!privateKeyPacket.isDecrypted) throw new Error('Private key is not decrypted.'); - var pkESKeyPacketlist = this.packets.filterByTag(enums.packet.public_key_encrypted_session_key); + var pkESKeyPacketlist = this.packets.filterByTag(enums.packet.publicKeyEncryptedSessionKey); var pkESKeyPacket; for (var i = 0; i < pkESKeyPacketlist.length; i++) { if (pkESKeyPacketlist[i].publicKeyId.equals(privateKeyPacket.getKeyId())) { @@ -103,7 +103,7 @@ Message.prototype.decrypt = function(privateKey) { } } if (pkESKeyPacket) { - var symEncryptedPacketlist = this.packets.filterByTag(enums.packet.symmetrically_encrypted, enums.packet.sym_encrypted_integrity_protected); + var symEncryptedPacketlist = this.packets.filterByTag(enums.packet.symmetricallyEncrypted, enums.packet.symEncryptedIntegrityProtected); if (symEncryptedPacketlist.length !== 0) { var symEncryptedPacket = symEncryptedPacketlist[0]; symEncryptedPacket.decrypt(pkESKeyPacket.sessionKeyAlgorithm, pkESKeyPacket.sessionKey); @@ -140,13 +140,13 @@ Message.prototype.getText = function() { * @return {Array} new message with encrypted content */ Message.prototype.encrypt = function(keys) { - var packetlist = new packet.list(); + var packetlist = new packet.List(); //TODO get preferred algo from signature var sessionKey = crypto.generateSessionKey(enums.read(enums.symmetric, config.encryption_cipher)); keys.forEach(function(key) { var encryptionKeyPacket = key.getEncryptionKeyPacket(); if (encryptionKeyPacket) { - var pkESKeyPacket = new packet.public_key_encrypted_session_key(); + var pkESKeyPacket = new packet.PublicKeyEncryptedSessionKey(); pkESKeyPacket.publicKeyId = encryptionKeyPacket.getKeyId(); pkESKeyPacket.publicKeyAlgorithm = encryptionKeyPacket.algorithm; pkESKeyPacket.sessionKey = sessionKey; @@ -160,9 +160,9 @@ Message.prototype.encrypt = function(keys) { }); var symEncryptedPacket; if (config.integrity_protect) { - symEncryptedPacket = new packet.sym_encrypted_integrity_protected(); + symEncryptedPacket = new packet.SymEncryptedIntegrityProtected(); } else { - symEncryptedPacket = new packet.symmetrically_encrypted(); + symEncryptedPacket = new packet.SymmetricallyEncrypted(); } symEncryptedPacket.packets = this.packets; //TODO get preferred algo from signature @@ -178,7 +178,7 @@ Message.prototype.encrypt = function(keys) { */ Message.prototype.sign = function(privateKeys) { - var packetlist = new packet.list(); + var packetlist = new packet.List(); var literalDataPacket = this.packets.findPacket(enums.packet.literal); if (!literalDataPacket) throw new Error('No literal data packet to sign.'); @@ -188,7 +188,7 @@ Message.prototype.sign = function(privateKeys) { enums.signature.binary : enums.signature.text; var i; for (i = 0; i < privateKeys.length; i++) { - var onePassSig = new packet.one_pass_signature(); + var onePassSig = new packet.OnePassSignature(); onePassSig.type = signatureType; //TODO get preferred hashg algo from key signature onePassSig.hashAlgorithm = config.prefer_hash_algorithm; @@ -204,7 +204,7 @@ Message.prototype.sign = function(privateKeys) { packetlist.push(literalDataPacket); for (i = privateKeys.length - 1; i >= 0; i--) { - var signaturePacket = new packet.signature(); + var signaturePacket = new packet.Signature(); signaturePacket.signatureType = signatureType; signaturePacket.hashAlgorithm = config.prefer_hash_algorithm; signaturePacket.publicKeyAlgorithm = signingKeyPacket.algorithm; @@ -273,7 +273,7 @@ function readArmored(armoredText) { //TODO how do we want to handle bad text? Exception throwing //TODO don't accept non-message armored texts var input = armor.decode(armoredText).data; - var packetlist = new packet.list(); + var packetlist = new packet.List(); packetlist.read(input); var newMessage = new Message(packetlist); return newMessage; @@ -286,10 +286,10 @@ function readArmored(armoredText) { * @static */ function fromText(text) { - var literalDataPacket = new packet.literal(); + var literalDataPacket = new packet.Literal(); // text will be converted to UTF8 literalDataPacket.setText(text); - var literalDataPacketlist = new packet.list(); + var literalDataPacketlist = new packet.List(); literalDataPacketlist.push(literalDataPacket); var newMessage = new Message(literalDataPacketlist); return newMessage; @@ -302,9 +302,9 @@ function fromText(text) { * @static */ function fromBinary(bytes) { - var literalDataPacket = new packet.literal(); + var literalDataPacket = new packet.Literal(); literalDataPacket.setBytes(bytes, enums.read(enums.literal, enums.literal.binary)); - var literalDataPacketlist = new packet.list(); + var literalDataPacketlist = new packet.List(); literalDataPacketlist.push(literalDataPacket); var newMessage = new Message(literalDataPacketlist); return newMessage; diff --git a/src/packet/all_packets.js b/src/packet/all_packets.js index c85c7851..48ed71f3 100644 --- a/src/packet/all_packets.js +++ b/src/packet/all_packets.js @@ -8,41 +8,48 @@ var enums = require('../enums.js'); module.exports = { /** @see module:packet/compressed */ - compressed: require('./compressed.js'), + Compressed: require('./compressed.js'), /** @see module:packet/sym_encrypted_integrity_protected */ - sym_encrypted_integrity_protected: require('./sym_encrypted_integrity_protected.js'), + SymEncryptedIntegrityProtected: require('./sym_encrypted_integrity_protected.js'), /** @see module:packet/public_key_encrypted_session_key */ - public_key_encrypted_session_key: require('./public_key_encrypted_session_key.js'), + PublicKeyEncryptedSessionKey: require('./public_key_encrypted_session_key.js'), /** @see module:packet/sym_encrypted_session_key */ - sym_encrypted_session_key: require('./sym_encrypted_session_key.js'), + SymEncryptedSessionKey: require('./sym_encrypted_session_key.js'), /** @see module:packet/literal */ - literal: require('./literal.js'), + Literal: require('./literal.js'), /** @see module:packet/public_key */ - public_key: require('./public_key.js'), + PublicKey: require('./public_key.js'), /** @see module:packet/symmetrically_encrypted */ - symmetrically_encrypted: require('./symmetrically_encrypted.js'), + SymmetricallyEncrypted: require('./symmetrically_encrypted.js'), /** @see module:packet/marker */ - marker: require('./marker.js'), + Marker: require('./marker.js'), /** @see module:packet/public_subkey */ - public_subkey: require('./public_subkey.js'), + PublicSubkey: require('./public_subkey.js'), /** @see module:packet/user_attribute */ - user_attribute: require('./user_attribute.js'), + UserAttribute: require('./user_attribute.js'), /** @see module:packet/one_pass_signature */ - one_pass_signature: require('./one_pass_signature.js'), + OnePassSignature: require('./one_pass_signature.js'), /** @see module:packet/secret_key */ - secret_key: require('./secret_key.js'), + SecretKey: require('./secret_key.js'), /** @see module:packet/userid */ - userid: require('./userid.js'), + Userid: require('./userid.js'), /** @see module:packet/secret_subkey */ - secret_subkey: require('./secret_subkey.js'), + SecretSubkey: require('./secret_subkey.js'), /** @see module:packet/signature */ - signature: require('./signature.js'), + Signature: require('./signature.js'), /** @see module:packet/trust */ - trust: require('./trust.js') + Trust: require('./trust.js'), + + newPacketFromTag: function (tag) { + return new this[packetClassFromTag(tag)](); + } }; +function packetClassFromTag(tag) { + return tag.substr(0, 1).toUpperCase() + tag.substr(1); +} for (var i in enums.packet) { - var packetClass = module.exports[i]; + var packetClass = module.exports[packetClassFromTag(i)]; if (packetClass !== undefined) packetClass.prototype.tag = enums.packet[i]; diff --git a/src/packet/compressed.js b/src/packet/compressed.js index 53edb353..f0687ed9 100644 --- a/src/packet/compressed.js +++ b/src/packet/compressed.js @@ -27,6 +27,8 @@ * @module packet/compressed */ +module.exports = Compressed; + var enums = require('../enums.js'), JXG = require('../compression/jxg.js'), base64 = require('../encoding/base64.js'); @@ -34,7 +36,7 @@ var enums = require('../enums.js'), /** * @constructor */ -module.exports = function compressed() { +function Compressed() { /** * List of packets * @type {module:packet/packetlist} @@ -51,118 +53,117 @@ module.exports = function compressed() { * @type {String} */ this.compressed = null; +} +/** + * Parsing function for the packet. + * @param {String} bytes Payload of a tag 8 packet + */ +Compressed.prototype.read = function (bytes) { + // One octet that gives the algorithm used to compress the packet. + this.algorithm = enums.read(enums.compression, bytes.charCodeAt(0)); - /** - * Parsing function for the packet. - * @param {String} bytes Payload of a tag 8 packet - */ - this.read = function(bytes) { - // One octet that gives the algorithm used to compress the packet. - this.algorithm = enums.read(enums.compression, bytes.charCodeAt(0)); + // Compressed data, which makes up the remainder of the packet. + this.compressed = bytes.substr(1); - // Compressed data, which makes up the remainder of the packet. - this.compressed = bytes.substr(1); - - this.decompress(); - }; - - - - /** - * Return the compressed packet. - * @return {String} binary compressed packet - */ - this.write = function() { - if (this.compressed === null) - this.compress(); - - return String.fromCharCode(enums.write(enums.compression, this.algorithm)) + this.compressed; - }; - - - /** - * Decompression method for decompressing the compressed data - * read by read_packet - */ - this.decompress = function() { - var decompressed, compdata, radix; - - switch (this.algorithm) { - case 'uncompressed': - decompressed = this.compressed; - break; - - case 'zip': - compData = this.compressed; - - radix = base64.encode(compData).replace(/\n/g, ""); - // no header in this case, directly call deflate - var jxg_obj = new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(radix)); - - decompressed = unescape(jxg_obj.deflate()[0][0]); - break; - - case 'zlib': - //RFC 1950. Bits 0-3 Compression Method - var compressionMethod = this.compressed.charCodeAt(0) % 0x10; - - //Bits 4-7 RFC 1950 are LZ77 Window. Generally this value is 7 == 32k window size. - // 2nd Byte in RFC 1950 is for "FLAGs" Allows for a Dictionary - // (how is this defined). Basic checksum, and compression level. - - if (compressionMethod == 8) { //CM 8 is for DEFLATE, RFC 1951 - // remove 4 bytes ADLER32 checksum from the end - compData = this.compressed.substring(0, this.compressed.length - 4); - radix = base64.encode(compData).replace(/\n/g, ""); - //TODO check ADLER32 checksum - decompressed = JXG.decompress(radix); - break; - - } else { - throw new Error("Compression algorithm ZLIB only supports " + - "DEFLATE compression method."); - } - break; - - case 'bzip2': - // TODO: need to implement this - throw new Error('Compression algorithm BZip2 [BZ2] is not implemented.'); - - default: - throw new Error("Compression algorithm unknown :" + this.alogrithm); - } - - this.packets.read(decompressed); - }; - - /** - * Compress the packet data (member decompressedData) - */ - this.compress = function() { - switch (this.algorithm) { - - case 'uncompressed': - // - Uncompressed - this.compressed = this.packets.write(); - break; - - case 'zip': - // - ZIP [RFC1951] - throw new Error("Compression algorithm ZIP [RFC1951] is not implemented."); - - case 'zlib': - // - ZLIB [RFC1950] - // TODO: need to implement this - throw new Error("Compression algorithm ZLIB [RFC1950] is not implemented."); - - case 'bzip2': - // - BZip2 [BZ2] - // TODO: need to implement this - throw new Error("Compression algorithm BZip2 [BZ2] is not implemented."); - - default: - throw new Error("Compression algorithm unknown :" + this.type); - } - }; + this.decompress(); +}; + + + +/** + * Return the compressed packet. + * @return {String} binary compressed packet + */ +Compressed.prototype.write = function () { + if (this.compressed === null) + this.compress(); + + return String.fromCharCode(enums.write(enums.compression, this.algorithm)) + this.compressed; +}; + + +/** + * Decompression method for decompressing the compressed data + * read by read_packet + */ +Compressed.prototype.decompress = function () { + var decompressed, compdata, radix; + + switch (this.algorithm) { + case 'uncompressed': + decompressed = this.compressed; + break; + + case 'zip': + compData = this.compressed; + + radix = base64.encode(compData).replace(/\n/g, ""); + // no header in this case, directly call deflate + var jxg_obj = new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(radix)); + + decompressed = unescape(jxg_obj.deflate()[0][0]); + break; + + case 'zlib': + //RFC 1950. Bits 0-3 Compression Method + var compressionMethod = this.compressed.charCodeAt(0) % 0x10; + + //Bits 4-7 RFC 1950 are LZ77 Window. Generally this value is 7 == 32k window size. + // 2nd Byte in RFC 1950 is for "FLAGs" Allows for a Dictionary + // (how is this defined). Basic checksum, and compression level. + + if (compressionMethod == 8) { //CM 8 is for DEFLATE, RFC 1951 + // remove 4 bytes ADLER32 checksum from the end + compData = this.compressed.substring(0, this.compressed.length - 4); + radix = base64.encode(compData).replace(/\n/g, ""); + //TODO check ADLER32 checksum + decompressed = JXG.decompress(radix); + break; + + } else { + throw new Error("Compression algorithm ZLIB only supports " + + "DEFLATE compression method."); + } + break; + + case 'bzip2': + // TODO: need to implement this + throw new Error('Compression algorithm BZip2 [BZ2] is not implemented.'); + + default: + throw new Error("Compression algorithm unknown :" + this.alogrithm); + } + + this.packets.read(decompressed); +}; + +/** + * Compress the packet data (member decompressedData) + */ +Compressed.prototype.compress = function () { + switch (this.algorithm) { + + case 'uncompressed': + // - Uncompressed + this.compressed = this.packets.write(); + break; + + case 'zip': + // - ZIP [RFC1951] + throw new Error("Compression algorithm ZIP [RFC1951] is not implemented."); + + case 'zlib': + // - ZLIB [RFC1950] + // TODO: need to implement this + throw new Error("Compression algorithm ZLIB [RFC1950] is not implemented."); + + case 'bzip2': + // - BZip2 [BZ2] + // TODO: need to implement this + throw new Error("Compression algorithm BZip2 [BZ2] is not implemented."); + + default: + throw new Error("Compression algorithm unknown :" + this.type); + } }; diff --git a/src/packet/index.js b/src/packet/index.js index 4396464c..2e62eba6 100644 --- a/src/packet/index.js +++ b/src/packet/index.js @@ -1,7 +1,7 @@ var enums = require('../enums.js'); module.exports = { - list: require('./packetlist.js') + List: require('./packetlist.js') }; var packets = require('./all_packets.js'); diff --git a/src/packet/literal.js b/src/packet/literal.js index 7b2f5a7a..17e76ca6 100644 --- a/src/packet/literal.js +++ b/src/packet/literal.js @@ -25,105 +25,106 @@ * @module packet/literal */ +module.exports = Literal; + var util = require('../util'), enums = require('../enums.js'); /** * @constructor */ -module.exports = function literal() { +function Literal() { this.format = 'utf8'; // default format for literal data packets this.data = ''; // literal data representation as native JavaScript string or bytes this.date = new Date(); +} - - /** - * Set the packet data to a javascript native string, end of line - * will be normalized to \r\n and by default text is converted to UTF8 - * @param {String} text Any native javascript string - */ - this.setText = function (text) { - // normalize EOL to \r\n - text = text.replace(/\r/g, '').replace(/\n/g, '\r\n'); - // encode UTF8 - this.data = this.format == 'utf8' ? util.encode_utf8(text) : text; - }; - - /** - * Returns literal data packets as native JavaScript string - * with normalized end of line to \n - * @return {String} literal data as text - */ - this.getText = function () { - // decode UTF8 - var text = util.decode_utf8(this.data); - // normalize EOL to \n - return text.replace(/\r\n/g, '\n'); - }; - - /** - * Set the packet data to value represented by the provided string of bytes. - * @param {String} bytes The string of bytes - * @param {utf8|binary|text} format The format of the string of bytes - */ - this.setBytes = function (bytes, format) { - this.format = format; - this.data = bytes; - }; - - - /** - * Get the byte sequence representing the literal packet data - * @returns {String} A sequence of bytes - */ - this.getBytes = function () { - return this.data; - }; - - - /** - * Parsing function for a literal data packet (tag 11). - * - * @param {String} input Payload of a tag 11 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/literal} object representation - */ - this.read = function (bytes) { - // - A one-octet field that describes how the data is formatted. - - var format = enums.read(enums.literal, bytes.charCodeAt(0)); - - var filename_len = bytes.charCodeAt(1); - this.filename = util.decode_utf8(bytes.substr(2, filename_len)); - - this.date = util.readDate(bytes.substr(2 + filename_len, 4)); - - var data = bytes.substring(6 + filename_len); - - this.setBytes(data, format); - }; - - /** - * Creates a string representation of the packet - * - * @param {String} data The data to be inserted as body - * @return {String} string-representation of the packet - */ - this.write = function () { - var filename = util.encode_utf8("msg.txt"); - - var data = this.getBytes(); - - var result = ''; - result += String.fromCharCode(enums.write(enums.literal, this.format)); - result += String.fromCharCode(filename.length); - result += filename; - result += util.writeDate(this.date); - result += data; - return result; - }; +/** + * Set the packet data to a javascript native string, end of line + * will be normalized to \r\n and by default text is converted to UTF8 + * @param {String} text Any native javascript string + */ +Literal.prototype.setText = function (text) { + // normalize EOL to \r\n + text = text.replace(/\r/g, '').replace(/\n/g, '\r\n'); + // encode UTF8 + this.data = this.format == 'utf8' ? util.encode_utf8(text) : text; +}; + +/** + * Returns literal data packets as native JavaScript string + * with normalized end of line to \n + * @return {String} literal data as text + */ +Literal.prototype.getText = function () { + // decode UTF8 + var text = util.decode_utf8(this.data); + // normalize EOL to \n + return text.replace(/\r\n/g, '\n'); +}; + +/** + * Set the packet data to value represented by the provided string of bytes. + * @param {String} bytes The string of bytes + * @param {utf8|binary|text} format The format of the string of bytes + */ +Literal.prototype.setBytes = function (bytes, format) { + this.format = format; + this.data = bytes; +}; + + +/** + * Get the byte sequence representing the literal packet data + * @returns {String} A sequence of bytes + */ +Literal.prototype.getBytes = function () { + return this.data; +}; + + +/** + * Parsing function for a literal data packet (tag 11). + * + * @param {String} input Payload of a tag 11 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/literal} object representation + */ +Literal.prototype.read = function (bytes) { + // - A one-octet field that describes how the data is formatted. + + var format = enums.read(enums.literal, bytes.charCodeAt(0)); + + var filename_len = bytes.charCodeAt(1); + this.filename = util.decode_utf8(bytes.substr(2, filename_len)); + + this.date = util.readDate(bytes.substr(2 + filename_len, 4)); + + var data = bytes.substring(6 + filename_len); + + this.setBytes(data, format); +}; + +/** + * Creates a string representation of the packet + * + * @param {String} data The data to be inserted as body + * @return {String} string-representation of the packet + */ +Literal.prototype.write = function () { + var filename = util.encode_utf8("msg.txt"); + + var data = this.getBytes(); + + var result = ''; + result += String.fromCharCode(enums.write(enums.literal, this.format)); + result += String.fromCharCode(filename.length); + result += filename; + result += util.writeDate(this.date); + result += data; + return result; }; diff --git a/src/packet/marker.js b/src/packet/marker.js index d1770d76..fd38986e 100644 --- a/src/packet/marker.js +++ b/src/packet/marker.js @@ -28,27 +28,30 @@ * @module packet/marker */ +module.exports = Marker; + /** * @constructor */ -module.exports = function marker() { - /** - * Parsing function for a literal data packet (tag 10). - * - * @param {String} input Payload of a tag 10 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/marker} Object representation - */ - this.read = function (bytes) { - if (bytes.charCodeAt(0) == 0x50 && // P - bytes.charCodeAt(1) == 0x47 && // G - bytes.charCodeAt(2) == 0x50) // P - return true; - // marker packet does not contain "PGP" - return false; - }; +function Marker() { +} + +/** + * Parsing function for a literal data packet (tag 10). + * + * @param {String} input Payload of a tag 10 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/marker} Object representation + */ +Marker.prototype.read = function (bytes) { + if (bytes.charCodeAt(0) == 0x50 && // P + bytes.charCodeAt(1) == 0x47 && // G + bytes.charCodeAt(2) == 0x50) // P + return true; + // marker packet does not contain "PGP" + return false; }; diff --git a/src/packet/one_pass_signature.js b/src/packet/one_pass_signature.js index 5e616435..33781f07 100644 --- a/src/packet/one_pass_signature.js +++ b/src/packet/one_pass_signature.js @@ -29,67 +29,69 @@ * @module packet/one_pass_signature */ +module.exports = OnePassSignature; + var enums = require('../enums.js'), type_keyid = require('../type/keyid.js'); /** * @constructor */ -module.exports = function one_pass_signature() { +function OnePassSignature() { this.version = null; // A one-octet version number. The current version is 3. this.type = null; // A one-octet signature type. Signature types are described in RFC4880 Section 5.2.1. this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See RFC4880 9.4) this.publicKeyAlgorithm = null; // A one-octet number describing the public-key algorithm used. (See RFC4880 9.1) this.signingKeyId = null; // An eight-octet number holding the Key ID of the signing key. this.flags = null; // A one-octet number holding a flag showing whether the signature is nested. A zero value indicates that the next packet is another One-Pass Signature packet that describes another signature to be applied to the same message data. +} - /** - * parsing function for a one-pass signature packet (tag 4). - * @param {String} bytes payload of a tag 4 packet - * @return {module:packet/one_pass_signature} object representation - */ - this.read = function (bytes) { - var mypos = 0; - // A one-octet version number. The current version is 3. - this.version = bytes.charCodeAt(mypos++); +/** + * parsing function for a one-pass signature packet (tag 4). + * @param {String} bytes payload of a tag 4 packet + * @return {module:packet/one_pass_signature} object representation + */ +OnePassSignature.prototype.read = function (bytes) { + var mypos = 0; + // A one-octet version number. The current version is 3. + this.version = bytes.charCodeAt(mypos++); - // A one-octet signature type. Signature types are described in - // Section 5.2.1. - this.type = enums.read(enums.signature, bytes.charCodeAt(mypos++)); + // A one-octet signature type. Signature types are described in + // Section 5.2.1. + this.type = enums.read(enums.signature, bytes.charCodeAt(mypos++)); - // A one-octet number describing the hash algorithm used. - this.hashAlgorithm = enums.read(enums.hash, bytes.charCodeAt(mypos++)); + // A one-octet number describing the hash algorithm used. + this.hashAlgorithm = enums.read(enums.hash, bytes.charCodeAt(mypos++)); - // A one-octet number describing the public-key algorithm used. - this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(mypos++)); + // A one-octet number describing the public-key algorithm used. + this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(mypos++)); - // An eight-octet number holding the Key ID of the signing key. - this.signingKeyId = new type_keyid(); - this.signingKeyId.read(bytes.substr(mypos)); - mypos += 8; + // An eight-octet number holding the Key ID of the signing key. + this.signingKeyId = new type_keyid(); + this.signingKeyId.read(bytes.substr(mypos)); + mypos += 8; - // A one-octet number holding a flag showing whether the signature - // is nested. A zero value indicates that the next packet is - // another One-Pass Signature packet that describes another - // signature to be applied to the same message data. - this.flags = bytes.charCodeAt(mypos++); - return this; - }; - - /** - * creates a string representation of a one-pass signature packet - * @return {String} a string representation of a one-pass signature packet - */ - this.write = function () { - var result = ""; - - result += String.fromCharCode(3); - result += String.fromCharCode(enums.write(enums.signature, this.type)); - result += String.fromCharCode(enums.write(enums.hash, this.hashAlgorithm)); - result += String.fromCharCode(enums.write(enums.publicKey, this.publicKeyAlgorithm)); - result += this.signingKeyId.write(); - result += String.fromCharCode(this.flags); - - return result; - }; + // A one-octet number holding a flag showing whether the signature + // is nested. A zero value indicates that the next packet is + // another One-Pass Signature packet that describes another + // signature to be applied to the same message data. + this.flags = bytes.charCodeAt(mypos++); + return this; +}; + +/** + * creates a string representation of a one-pass signature packet + * @return {String} a string representation of a one-pass signature packet + */ +OnePassSignature.prototype.write = function () { + var result = ""; + + result += String.fromCharCode(3); + result += String.fromCharCode(enums.write(enums.signature, this.type)); + result += String.fromCharCode(enums.write(enums.hash, this.hashAlgorithm)); + result += String.fromCharCode(enums.write(enums.publicKey, this.publicKeyAlgorithm)); + result += this.signingKeyId.write(); + result += String.fromCharCode(this.flags); + + return result; }; diff --git a/src/packet/packet.js b/src/packet/packet.js index 317ff0d2..661d5f47 100644 --- a/src/packet/packet.js +++ b/src/packet/packet.js @@ -24,7 +24,6 @@ var enums = require('../enums.js'), util = require('../util'); - module.exports = { readSimpleLength: function(bytes) { var len = 0, diff --git a/src/packet/packetlist.js b/src/packet/packetlist.js index 7ed4637f..07284b7f 100644 --- a/src/packet/packetlist.js +++ b/src/packet/packetlist.js @@ -8,6 +8,8 @@ * @module packet/packetlist */ +module.exports = Packetlist; + var packetParser = require('./packet.js'), packets = require('./all_packets.js'), enums = require('../enums.js'); @@ -15,162 +17,161 @@ var packetParser = require('./packet.js'), /** * @constructor */ -module.exports = function packetlist() { +function Packetlist() { /** The number of packets contained within the list. * @readonly * @type {Integer} */ this.length = 0; +} +/** + * Reads a stream of binary data and interprents it as a list of packets. + * @param {String} A binary string of bytes. + */ +Packetlist.prototype.read = function (bytes) { + var i = 0; - /** - * Reads a stream of binary data and interprents it as a list of packets. - * @param {String} A binary string of bytes. - */ - this.read = function (bytes) { - var i = 0; + while (i < bytes.length) { + var parsed = packetParser.read(bytes, i, bytes.length - i); + i = parsed.offset; - while (i < bytes.length) { - var parsed = packetParser.read(bytes, i, bytes.length - i); - i = parsed.offset; + var tag = enums.read(enums.packet, parsed.tag); + var packet = packets.newPacketFromTag(tag); - var tag = enums.read(enums.packet, parsed.tag); - var packet = new packets[tag](); + this.push(packet); - this.push(packet); - - packet.read(parsed.packet); - } - }; - - /** - * Creates a binary representation of openpgp objects contained within the - * class instance. - * @returns {String} A binary string of bytes containing valid openpgp packets. - */ - this.write = function () { - var bytes = ''; - - for (var i = 0; i < this.length; i++) { - var packetbytes = this[i].write(); - bytes += packetParser.writeHeader(this[i].tag, packetbytes.length); - bytes += packetbytes; - } - - return bytes; - }; - - /** - * Adds a packet to the list. This is the only supported method of doing so; - * writing to packetlist[i] directly will result in an error. - */ - this.push = function (packet) { - if (!packet) return; - - packet.packets = packet.packets || new packetlist(); - - this[this.length] = packet; - this.length++; - }; - - /** - * Creates a new packetList with all packets that pass the test implemented by the provided function. - */ - this.filter = function (callback) { - - var filtered = new packetlist(); - - for (var i = 0; i < this.length; i++) { - if (callback(this[i], i, this)) { - filtered.push(this[i]); - } - } - - return filtered; - }; - - /** - * Creates a new packetList with all packets from the given types - */ - this.filterByTag = function () { - var args = Array.prototype.slice.call(arguments); - var filtered = new packetlist(); - var that = this; - - for (var i = 0; i < this.length; i++) { - if (args.some(function(packetType) {return that[i].tag == packetType;})) { - filtered.push(this[i]); - } - } - - return filtered; - }; - - /** - * Executes the provided callback once for each element - */ - this.forEach = function (callback) { - for (var i = 0; i < this.length; i++) { - callback(this[i]); - } - }; - - /** - * Traverses packet tree and returns first matching packet - * @param {module:enums.packet} type The packet type - * @return {module:packet/packet|null} - */ - this.findPacket = function (type) { - var packetlist = this.filterByTag(type); - if (packetlist.length) { - return packetlist[0]; - } else { - var found = null; - for (var i = 0; i < this.length; i++) { - if (this[i].packets.length) { - found = this[i].packets.findPacket(type); - if (found) return found; - } - } - } - return null; - }; - - /** - * Returns array of found indices by tag - */ - this.indexOfTag = function () { - var args = Array.prototype.slice.call(arguments); - var tagIndex = []; - var that = this; - for (var i = 0; i < this.length; i++) { - if (args.some(function(packetType) {return that[i].tag == packetType;})) { - tagIndex.push(i); - } - } - return tagIndex; - }; - - /** - * Returns slice of packetlist - */ - this.slice = function (begin, end) { - if (!end) { - end = this.length; - } - var part = new packetlist(); - for (var i = begin; i < end; i++) { - part.push(this[i]); - } - return part; - }; - - /** - * Concatenates packetlist or array of packets - */ - this.concat = function (packetlist) { - if (packetlist) { - for (var i = 0; i < packetlist.length; i++) { - this.push(packetlist[i]); - } - } - }; + packet.read(parsed.packet); + } +}; + +/** + * Creates a binary representation of openpgp objects contained within the + * class instance. + * @returns {String} A binary string of bytes containing valid openpgp packets. + */ +Packetlist.prototype.write = function () { + var bytes = ''; + + for (var i = 0; i < this.length; i++) { + var packetbytes = this[i].write(); + bytes += packetParser.writeHeader(this[i].tag, packetbytes.length); + bytes += packetbytes; + } + + return bytes; +}; + +/** + * Adds a packet to the list. This is the only supported method of doing so; + * writing to packetlist[i] directly will result in an error. + */ +Packetlist.prototype.push = function (packet) { + if (!packet) return; + + packet.packets = packet.packets || new Packetlist(); + + this[this.length] = packet; + this.length++; +}; + +/** +* Creates a new PacketList with all packets that pass the test implemented by the provided function. +*/ +Packetlist.prototype.filter = function (callback) { + + var filtered = new Packetlist(); + + for (var i = 0; i < this.length; i++) { + if (callback(this[i], i, this)) { + filtered.push(this[i]); + } + } + + return filtered; +}; + +/** +* Creates a new PacketList with all packets from the given types +*/ +Packetlist.prototype.filterByTag = function () { + var args = Array.prototype.slice.call(arguments); + var filtered = new Packetlist(); + var that = this; + + for (var i = 0; i < this.length; i++) { + if (args.some(function(packetType) {return that[i].tag == packetType;})) { + filtered.push(this[i]); + } + } + + return filtered; +}; + +/** +* Executes the provided callback once for each element +*/ +Packetlist.prototype.forEach = function (callback) { + for (var i = 0; i < this.length; i++) { + callback(this[i]); + } +}; + +/** + * Traverses packet tree and returns first matching packet + * @param {module:enums.packet} type The packet type + * @return {module:packet/packet|null} + */ +Packetlist.prototype.findPacket = function (type) { + var packetlist = this.filterByTag(type); + if (packetlist.length) { + return packetlist[0]; + } else { + var found = null; + for (var i = 0; i < this.length; i++) { + if (this[i].packets.length) { + found = this[i].packets.findPacket(type); + if (found) return found; + } + } + } + return null; +}; + +/** + * Returns array of found indices by tag + */ +Packetlist.prototype.indexOfTag = function () { + var args = Array.prototype.slice.call(arguments); + var tagIndex = []; + var that = this; + for (var i = 0; i < this.length; i++) { + if (args.some(function(packetType) {return that[i].tag == packetType;})) { + tagIndex.push(i); + } + } + return tagIndex; +}; + +/** + * Returns slice of packetlist + */ +Packetlist.prototype.slice = function (begin, end) { + if (!end) { + end = this.length; + } + var part = new Packetlist(); + for (var i = begin; i < end; i++) { + part.push(this[i]); + } + return part; +}; + +/** + * Concatenates packetlist or array of packets + */ +Packetlist.prototype.concat = function (packetlist) { + if (packetlist) { + for (var i = 0; i < packetlist.length; i++) { + this.push(packetlist[i]); + } + } }; diff --git a/src/packet/public_key.js b/src/packet/public_key.js index 5813134c..1be16ce2 100644 --- a/src/packet/public_key.js +++ b/src/packet/public_key.js @@ -30,6 +30,8 @@ * @module packet/public_key */ +module.exports = PublicKey; + var util = require('../util'), type_mpi = require('../type/mpi.js'), type_keyid = require('../type/keyid.js'), @@ -39,7 +41,7 @@ var util = require('../util'), /** * @constructor */ -module.exports = function public_key() { +function PublicKey() { this.version = 4; /** Key creation date. * @type {Date} */ @@ -52,136 +54,135 @@ module.exports = function public_key() { this.algorithm = 'rsa_sign'; // time in days (V3 only) this.expirationTimeV3 = 0; +} +/** + * Internal Parser for public keys as specified in RFC 4880 section + * 5.5.2 Public-Key Packet Formats + * called by read_tag<num> + * @param {String} input Input string to read the packet from + * @return {Object} This object with attributes set by the parser + */ +PublicKey.prototype.read = function (bytes) { + var pos = 0; + // A one-octet version number (3 or 4). + this.version = bytes.charCodeAt(pos++); - /** - * Internal Parser for public keys as specified in RFC 4880 section - * 5.5.2 Public-Key Packet Formats - * called by read_tag<num> - * @param {String} input Input string to read the packet from - * @return {Object} This object with attributes set by the parser - */ - this.read = function (bytes) { - var pos = 0; - // A one-octet version number (3 or 4). - this.version = bytes.charCodeAt(pos++); + if (this.version == 3 || this.version == 4) { + // - A four-octet number denoting the time that the key was created. + this.created = util.readDate(bytes.substr(pos, 4)); + pos += 4; - if (this.version == 3 || this.version == 4) { - // - A four-octet number denoting the time that the key was created. - this.created = util.readDate(bytes.substr(pos, 4)); - pos += 4; - - if (this.version == 3) { - // - A two-octet number denoting the time in days that this key is - // valid. If this number is zero, then it does not expire. - this.expirationTimeV3 = util.readNumber(bytes.substr(pos, 2)); - pos += 2; - } - - // - A one-octet number denoting the public-key algorithm of this key. - this.algorithm = enums.read(enums.publicKey, bytes.charCodeAt(pos++)); - - var mpicount = crypto.getPublicMpiCount(this.algorithm); - this.mpi = []; - - var bmpi = bytes.substr(pos); - var p = 0; - - for (var i = 0; i < mpicount && p < bmpi.length; i++) { - - this.mpi[i] = new type_mpi(); - - p += this.mpi[i].read(bmpi.substr(p)); - - if (p > bmpi.length) { - throw new Error('Error reading MPI @:' + p); - } - } - - return p + 6; - } 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. - * @return {Object} {body: [string]OpenPGP packet body contents, - * header: [string] OpenPGP packet header, string: [string] header+body} - */ - this.write = function () { - // Version - var result = String.fromCharCode(this.version); - result += util.writeDate(this.created); if (this.version == 3) { - result += util.writeNumber(this.expirationTimeV3, 2); + // - A two-octet number denoting the time in days that this key is + // valid. If this number is zero, then it does not expire. + this.expirationTimeV3 = util.readNumber(bytes.substr(pos, 2)); + pos += 2; } - result += String.fromCharCode(enums.write(enums.publicKey, this.algorithm)); + + // - A one-octet number denoting the public-key algorithm of this key. + this.algorithm = enums.read(enums.publicKey, bytes.charCodeAt(pos++)); var mpicount = crypto.getPublicMpiCount(this.algorithm); + this.mpi = []; - for (var i = 0; i < mpicount; i++) { - result += this.mpi[i].write(); - } + var bmpi = bytes.substr(pos); + var p = 0; - return result; - }; + for (var i = 0; i < mpicount && p < bmpi.length; i++) { - /** - * Alias of write() - * @function module:packet/public_key#writePublicKey - * @see module:packet/public_key#write - */ - this.writePublicKey = this.write; + this.mpi[i] = new type_mpi(); - /** - * Write an old version packet - it's used by some of the internal routines. - */ - this.writeOld = function () { - var bytes = this.writePublicKey(); + p += this.mpi[i].read(bmpi.substr(p)); - return String.fromCharCode(0x99) + - util.writeNumber(bytes.length, 2) + - bytes; - }; - - /** - * Calculates the key id of the key - * @return {String} A 8 byte key id - */ - this.getKeyId = function () { - var keyid = new type_keyid(); - if (this.version == 4) { - keyid.read(this.getFingerprint().substr(12, 8)); - } else if (this.version == 3) { - keyid.read(this.mpi[0].write().substr(-8)); - } - return keyid; - }; - - /** - * Calculates the fingerprint of the key - * @return {String} A string containing the fingerprint - */ - this.getFingerprint = function () { - var toHash = ''; - if (this.version == 4) { - toHash = this.writeOld(); - return crypto.hash.sha1(toHash); - } else if (this.version == 3) { - var mpicount = crypto.getPublicMpiCount(this.algorithm); - for (var i = 0; i < mpicount; i++) { - toHash += this.mpi[i].toBytes(); + if (p > bmpi.length) { + throw new Error('Error reading MPI @:' + p); } - return crypto.hash.md5(toHash); } - }; + + return p + 6; + } 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 + */ +PublicKey.prototype.readPublicKey = PublicKey.prototype.read; + +/** + * Same as write_private_key, but has less information because of + * public key. + * @return {Object} {body: [string]OpenPGP packet body contents, + * header: [string] OpenPGP packet header, string: [string] header+body} + */ +PublicKey.prototype.write = function () { + // Version + var result = String.fromCharCode(this.version); + result += util.writeDate(this.created); + if (this.version == 3) { + result += util.writeNumber(this.expirationTimeV3, 2); + } + result += String.fromCharCode(enums.write(enums.publicKey, this.algorithm)); + + var mpicount = crypto.getPublicMpiCount(this.algorithm); + + for (var i = 0; i < mpicount; i++) { + result += this.mpi[i].write(); + } + + return result; +}; + +/** + * Alias of write() + * @function module:packet/public_key#writePublicKey + * @see module:packet/public_key#write + */ +PublicKey.prototype.writePublicKey = PublicKey.prototype.write; + +/** + * Write an old version packet - it's used by some of the internal routines. + */ +PublicKey.prototype.writeOld = function () { + var bytes = this.writePublicKey(); + + return String.fromCharCode(0x99) + + util.writeNumber(bytes.length, 2) + + bytes; +}; + +/** + * Calculates the key id of the key + * @return {String} A 8 byte key id + */ +PublicKey.prototype.getKeyId = function () { + var keyid = new type_keyid(); + if (this.version == 4) { + keyid.read(this.getFingerprint().substr(12, 8)); + } else if (this.version == 3) { + keyid.read(this.mpi[0].write().substr(-8)); + } + return keyid; +}; + +/** + * Calculates the fingerprint of the key + * @return {String} A string containing the fingerprint + */ +PublicKey.prototype.getFingerprint = function () { + var toHash = ''; + if (this.version == 4) { + toHash = this.writeOld(); + return crypto.hash.sha1(toHash); + } else if (this.version == 3) { + var mpicount = crypto.getPublicMpiCount(this.algorithm); + for (var i = 0; i < mpicount; i++) { + toHash += this.mpi[i].toBytes(); + } + return crypto.hash.md5(toHash); + } }; diff --git a/src/packet/public_key_encrypted_session_key.js b/src/packet/public_key_encrypted_session_key.js index 2aa42b72..5fc27097 100644 --- a/src/packet/public_key_encrypted_session_key.js +++ b/src/packet/public_key_encrypted_session_key.js @@ -37,6 +37,8 @@ * @module packet/public_key_encrypted_session_key */ +module.exports = PublicKeyEncryptedSessionKey; + var type_keyid = require('../type/keyid.js'), util = require('../util'), type_mpi = require('../type/mpi.js'), @@ -46,7 +48,7 @@ var type_keyid = require('../type/keyid.js'), /** * @constructor */ -module.exports = function public_key_encrypted_session_key() { +function PublicKeyEncryptedSessionKey() { this.version = 3; this.publicKeyId = new type_keyid(); @@ -57,126 +59,126 @@ module.exports = function public_key_encrypted_session_key() { /** @type {Array} */ this.encrypted = []; +} - /** - * Parsing function for a publickey encrypted session key packet (tag 1). - * - * @param {String} input Payload of a tag 1 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/public_key_encrypted_session_key} Object representation - */ - this.read = function (bytes) { +/** + * Parsing function for a publickey encrypted session key packet (tag 1). + * + * @param {String} input Payload of a tag 1 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/public_key_encrypted_session_key} Object representation + */ +PublicKeyEncryptedSessionKey.prototype.read = function (bytes) { - this.version = bytes.charCodeAt(0); - this.publicKeyId.read(bytes.substr(1)); - this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(9)); + this.version = bytes.charCodeAt(0); + this.publicKeyId.read(bytes.substr(1)); + this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(9)); - var i = 10; + var i = 10; - var integerCount = (function(algo) { - switch (algo) { - case 'rsa_encrypt': - case 'rsa_encrypt_sign': - return 1; + var integerCount = (function(algo) { + switch (algo) { + case 'rsa_encrypt': + case 'rsa_encrypt_sign': + return 1; - case 'elgamal': - return 2; + case 'elgamal': + return 2; - default: - throw new Error("Invalid algorithm."); - } - })(this.publicKeyAlgorithm); - - this.encrypted = []; - - for (var j = 0; j < integerCount; j++) { - var mpi = new type_mpi(); - i += mpi.read(bytes.substr(i)); - this.encrypted.push(mpi); + default: + throw new Error("Invalid algorithm."); } - }; + })(this.publicKeyAlgorithm); - /** - * Create a string representation of a tag 1 packet - * - * @param {String} publicKeyId - * The public key id corresponding to publicMPIs key as string - * @param {Array} publicMPIs - * Multiprecision integer objects describing the public key - * @param {Integer} pubalgo - * The corresponding public key algorithm // See RFC4880 9.1 - * @param {Integer} symmalgo - * The symmetric cipher algorithm used to encrypt the data - * within an encrypteddatapacket or encryptedintegrity- - * protecteddatapacket - * following this packet //See RFC4880 9.2 - * @param {String} sessionkey - * A string of randombytes representing the session key - * @return {String} The string representation - */ - this.write = function () { - - var result = String.fromCharCode(this.version); - result += this.publicKeyId.write(); - result += String.fromCharCode( - enums.write(enums.publicKey, this.publicKeyAlgorithm)); - - for (var i = 0; i < this.encrypted.length; i++) { - result += this.encrypted[i].write(); - } - - return result; - }; - - this.encrypt = function (key) { - var data = String.fromCharCode( - enums.write(enums.symmetric, this.sessionKeyAlgorithm)); - - data += this.sessionKey; - var checksum = util.calc_checksum(this.sessionKey); - data += util.writeNumber(checksum, 2); + this.encrypted = []; + for (var j = 0; j < integerCount; j++) { var mpi = new type_mpi(); - mpi.fromBytes(crypto.pkcs1.eme.encode( - data, - key.mpi[0].byteLength())); - - this.encrypted = crypto.publicKeyEncrypt( - this.publicKeyAlgorithm, - key.mpi, - mpi); - }; - - /** - * Decrypts the session key (only for public key encrypted session key - * packets (tag 1) - * - * @param {module:packet/secret_key} key - * Private key with secMPIs unlocked - * @return {String} The unencrypted session key - */ - this.decrypt = function (key) { - var result = crypto.publicKeyDecrypt( - this.publicKeyAlgorithm, - key.mpi, - this.encrypted).toBytes(); - - var checksum = util.readNumber(result.substr(result.length - 2)); - - var decoded = crypto.pkcs1.eme.decode( - result, - key.mpi[0].byteLength()); - - key = decoded.substring(1, decoded.length - 2); - - if (checksum != util.calc_checksum(key)) { - throw new Error('Checksum mismatch'); - } else { - this.sessionKey = key; - this.sessionKeyAlgorithm = - enums.read(enums.symmetric, decoded.charCodeAt(0)); - } - }; + i += mpi.read(bytes.substr(i)); + this.encrypted.push(mpi); + } +}; + +/** + * Create a string representation of a tag 1 packet + * + * @param {String} publicKeyId + * The public key id corresponding to publicMPIs key as string + * @param {Array} publicMPIs + * Multiprecision integer objects describing the public key + * @param {Integer} pubalgo + * The corresponding public key algorithm // See RFC4880 9.1 + * @param {Integer} symmalgo + * The symmetric cipher algorithm used to encrypt the data + * within an encrypteddatapacket or encryptedintegrity- + * protecteddatapacket + * following this packet //See RFC4880 9.2 + * @param {String} sessionkey + * A string of randombytes representing the session key + * @return {String} The string representation + */ +PublicKeyEncryptedSessionKey.prototype.write = function () { + + var result = String.fromCharCode(this.version); + result += this.publicKeyId.write(); + result += String.fromCharCode( + enums.write(enums.publicKey, this.publicKeyAlgorithm)); + + for (var i = 0; i < this.encrypted.length; i++) { + result += this.encrypted[i].write(); + } + + return result; +}; + +PublicKeyEncryptedSessionKey.prototype.encrypt = function (key) { + var data = String.fromCharCode( + enums.write(enums.symmetric, this.sessionKeyAlgorithm)); + + data += this.sessionKey; + var checksum = util.calc_checksum(this.sessionKey); + data += util.writeNumber(checksum, 2); + + var mpi = new type_mpi(); + mpi.fromBytes(crypto.pkcs1.eme.encode( + data, + key.mpi[0].byteLength())); + + this.encrypted = crypto.publicKeyEncrypt( + this.publicKeyAlgorithm, + key.mpi, + mpi); +}; + +/** + * Decrypts the session key (only for public key encrypted session key + * packets (tag 1) + * + * @param {module:packet/secret_key} key + * Private key with secMPIs unlocked + * @return {String} The unencrypted session key + */ +PublicKeyEncryptedSessionKey.prototype.decrypt = function (key) { + var result = crypto.publicKeyDecrypt( + this.publicKeyAlgorithm, + key.mpi, + this.encrypted).toBytes(); + + var checksum = util.readNumber(result.substr(result.length - 2)); + + var decoded = crypto.pkcs1.eme.decode( + result, + key.mpi[0].byteLength()); + + key = decoded.substring(1, decoded.length - 2); + + if (checksum != util.calc_checksum(key)) { + throw new Error('Checksum mismatch'); + } else { + this.sessionKey = key; + this.sessionKeyAlgorithm = + enums.read(enums.symmetric, decoded.charCodeAt(0)); + } }; diff --git a/src/packet/public_subkey.js b/src/packet/public_subkey.js index db36cad7..8ef4e213 100644 --- a/src/packet/public_subkey.js +++ b/src/packet/public_subkey.js @@ -20,12 +20,17 @@ * @module packet/public_subkey */ +module.exports = PublicSubkey; + var publicKey = require('./public_key.js'); /** * @constructor * @extends module:packet/public_key */ -module.exports = function public_subkey() { +function PublicSubkey() { publicKey.call(this); }; + +PublicSubkey.prototype = new publicKey(); +PublicSubkey.prototype.constructor = PublicSubkey(); diff --git a/src/packet/secret_key.js b/src/packet/secret_key.js index 7e477835..243e9baa 100644 --- a/src/packet/secret_key.js +++ b/src/packet/secret_key.js @@ -42,225 +42,226 @@ var publicKey = require('./public_key.js'), * @constructor * @extends module:packet/public_key */ -module.exports = function secret_key() { +module.exports = SecretKey; + +function SecretKey() { publicKey.call(this); // encrypted secret-key data this.encrypted = null; // indicator if secret-key data is available in decrypted form this.isDecrypted = false; +} +SecretKey.prototype = new publicKey(); +SecretKey.prototype.constructor = SecretKey(); - function get_hash_len(hash) { - if (hash == 'sha1') - return 20; - else - return 2; - } - - function get_hash_fn(hash) { - if (hash == 'sha1') - return crypto.hash.sha1; - else - return function(c) { - return util.writeNumber(util.calc_checksum(c), 2); - }; - } - - // Helper function - - function parse_cleartext_mpi(hash_algorithm, cleartext, algorithm) { - var hashlen = get_hash_len(hash_algorithm), - hashfn = get_hash_fn(hash_algorithm); - - var hashtext = cleartext.substr(cleartext.length - hashlen); - cleartext = cleartext.substr(0, cleartext.length - hashlen); - - var hash = hashfn(cleartext); - - if (hash != hashtext) - return new Error("Hash mismatch."); - - var mpis = crypto.getPrivateMpiCount(algorithm); - - var j = 0; - var mpi = []; - - for (var i = 0; i < mpis && j < cleartext.length; i++) { - mpi[i] = new type_mpi(); - j += mpi[i].read(cleartext.substr(j)); - } - - return mpi; - } - - function write_cleartext_mpi(hash_algorithm, algorithm, mpi) { - var bytes = ''; - var discard = crypto.getPublicMpiCount(algorithm); - - for (var i = discard; i < mpi.length; i++) { - bytes += mpi[i].write(); - } - - - bytes += get_hash_fn(hash_algorithm)(bytes); - - return bytes; - } - - - // 5.5.3. Secret-Key Packet Formats - - /** - * Internal parser for private keys as specified in RFC 4880 section 5.5.3 - * @param {String} bytes Input string to read the packet from - */ - this.read = function (bytes) { - // - A Public-Key or Public-Subkey packet, as described above. - var len = this.readPublicKey(bytes); - - bytes = bytes.substr(len); - - - // - One octet indicating string-to-key usage conventions. Zero - // indicates that the secret-key data is not encrypted. 255 or 254 - // indicates that a string-to-key specifier is being given. Any - // other value is a symmetric-key encryption algorithm identifier. - var isEncrypted = bytes.charCodeAt(0); - - if (isEncrypted) { - this.encrypted = bytes; - } else { - - // - Plain or encrypted multiprecision integers comprising the secret - // key data. These algorithm-specific fields are as described - // below. - var parsedMPI = parse_cleartext_mpi('mod', bytes.substr(1), this.algorithm); - if (parsedMPI instanceof Error) - throw parsedMPI; - this.mpi = this.mpi.concat(parsedMPI); - this.isDecrypted = true; - } +function get_hash_len(hash) { + if (hash == 'sha1') + return 20; + else + return 2; +} +function get_hash_fn(hash) { + if (hash == 'sha1') + return crypto.hash.sha1; + else + return function(c) { + return util.writeNumber(util.calc_checksum(c), 2); }; +} - /** Creates an OpenPGP key packet for the given key. - * @return {String} A string of bytes containing the secret key OpenPGP packet - */ - this.write = function () { - var bytes = this.writePublicKey(); +// Helper function - if (!this.encrypted) { - bytes += String.fromCharCode(0); +function parse_cleartext_mpi(hash_algorithm, cleartext, algorithm) { + var hashlen = get_hash_len(hash_algorithm), + hashfn = get_hash_fn(hash_algorithm); - bytes += write_cleartext_mpi('mod', this.algorithm, this.mpi); - } else { - bytes += this.encrypted; - } + var hashtext = cleartext.substr(cleartext.length - hashlen); + cleartext = cleartext.substr(0, cleartext.length - hashlen); - return bytes; - }; + var hash = hashfn(cleartext); + if (hash != hashtext) + return new Error("Hash mismatch."); + var mpis = crypto.getPrivateMpiCount(algorithm); + var j = 0; + var mpi = []; - /** Encrypt the payload. By default, we use aes256 and iterated, salted string - * to key specifier - * @param {String} passphrase - */ - this.encrypt = function (passphrase) { - - var s2k = new type_s2k(), - symmetric = 'aes256', - cleartext = write_cleartext_mpi('sha1', this.algorithm, this.mpi), - key = produceEncryptionKey(s2k, passphrase, symmetric), - blockLen = crypto.cipher[symmetric].blockSize, - iv = crypto.random.getRandomBytes(blockLen); - - - this.encrypted = ''; - this.encrypted += String.fromCharCode(254); - this.encrypted += String.fromCharCode(enums.write(enums.symmetric, symmetric)); - this.encrypted += s2k.write(); - this.encrypted += iv; - - this.encrypted += crypto.cfb.normalEncrypt(symmetric, key, cleartext, iv); - }; - - function produceEncryptionKey(s2k, passphrase, algorithm) { - return s2k.produce_key(passphrase, - crypto.cipher[algorithm].keySize); + for (var i = 0; i < mpis && j < cleartext.length; i++) { + mpi[i] = new type_mpi(); + j += mpi[i].read(cleartext.substr(j)); } - /** - * Decrypts the private key MPIs which are needed to use the key. - * @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 - * @return {Boolean} True if the passphrase was correct or MPI already - * decrypted; false if not - */ - this.decrypt = function (passphrase) { - if (this.isDecrypted) - return true; + return mpi; +} - var i = 0, - symmetric, - key; +function write_cleartext_mpi(hash_algorithm, algorithm, mpi) { + var bytes = ''; + var discard = crypto.getPublicMpiCount(algorithm); - var s2k_usage = this.encrypted.charCodeAt(i++); - - // - [Optional] If string-to-key usage octet was 255 or 254, a one- - // octet symmetric encryption algorithm. - if (s2k_usage == 255 || s2k_usage == 254) { - symmetric = this.encrypted.charCodeAt(i++); - symmetric = enums.read(enums.symmetric, symmetric); - - // - [Optional] If string-to-key usage octet was 255 or 254, a - // string-to-key specifier. The length of the string-to-key - // specifier is implied by its type, as described above. - var s2k = new type_s2k(); - i += s2k.read(this.encrypted.substr(i)); - - key = produceEncryptionKey(s2k, passphrase, symmetric); - } else { - symmetric = s2k_usage; - symmetric = enums.read(enums.symmetric, symmetric); - key = crypto.hash.md5(passphrase); - } + for (var i = discard; i < mpi.length; i++) { + bytes += mpi[i].write(); + } - // - [Optional] If secret data is encrypted (string-to-key usage octet - // not zero), an Initial Vector (IV) of the same length as the - // cipher's block size. - var iv = this.encrypted.substr(i, - crypto.cipher[symmetric].blockSize); + bytes += get_hash_fn(hash_algorithm)(bytes); - i += iv.length; + return bytes; +} - var cleartext, - ciphertext = this.encrypted.substr(i); - cleartext = crypto.cfb.normalDecrypt(symmetric, key, ciphertext, iv); +// 5.5.3. Secret-Key Packet Formats - var hash = s2k_usage == 254 ? - 'sha1' : - 'mod'; +/** + * Internal parser for private keys as specified in RFC 4880 section 5.5.3 + * @param {String} bytes Input string to read the packet from + */ +SecretKey.prototype.read = function (bytes) { + // - A Public-Key or Public-Subkey packet, as described above. + var len = this.readPublicKey(bytes); - var parsedMPI = parse_cleartext_mpi(hash, cleartext, this.algorithm); + bytes = bytes.substr(len); + + + // - One octet indicating string-to-key usage conventions. Zero + // indicates that the secret-key data is not encrypted. 255 or 254 + // indicates that a string-to-key specifier is being given. Any + // other value is a symmetric-key encryption algorithm identifier. + var isEncrypted = bytes.charCodeAt(0); + + if (isEncrypted) { + this.encrypted = bytes; + } else { + + // - Plain or encrypted multiprecision integers comprising the secret + // key data. These algorithm-specific fields are as described + // below. + var parsedMPI = parse_cleartext_mpi('mod', bytes.substr(1), this.algorithm); if (parsedMPI instanceof Error) - return false; + throw parsedMPI; this.mpi = this.mpi.concat(parsedMPI); this.isDecrypted = true; - return true; - }; - - this.generate = function (bits) { - this.mpi = crypto.generateMpi(this.algorithm, bits); - this.isDecrypted = true; - }; + } }; -module.exports.prototype = new publicKey(); +/** Creates an OpenPGP key packet for the given key. + * @return {String} A string of bytes containing the secret key OpenPGP packet + */ +SecretKey.prototype.write = function () { + var bytes = this.writePublicKey(); + + if (!this.encrypted) { + bytes += String.fromCharCode(0); + + bytes += write_cleartext_mpi('mod', this.algorithm, this.mpi); + } else { + bytes += this.encrypted; + } + + return bytes; +}; + + + + +/** Encrypt the payload. By default, we use aes256 and iterated, salted string + * to key specifier + * @param {String} passphrase + */ +SecretKey.prototype.encrypt = function (passphrase) { + + var s2k = new type_s2k(), + symmetric = 'aes256', + cleartext = write_cleartext_mpi('sha1', this.algorithm, this.mpi), + key = produceEncryptionKey(s2k, passphrase, symmetric), + blockLen = crypto.cipher[symmetric].blockSize, + iv = crypto.random.getRandomBytes(blockLen); + + + this.encrypted = ''; + this.encrypted += String.fromCharCode(254); + this.encrypted += String.fromCharCode(enums.write(enums.symmetric, symmetric)); + this.encrypted += s2k.write(); + this.encrypted += iv; + + this.encrypted += crypto.cfb.normalEncrypt(symmetric, key, cleartext, iv); +}; + +function produceEncryptionKey(s2k, passphrase, algorithm) { + return s2k.produce_key(passphrase, + crypto.cipher[algorithm].keySize); +} + +/** + * Decrypts the private key MPIs which are needed to use the key. + * @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 + * @return {Boolean} True if the passphrase was correct or MPI already + * decrypted; false if not + */ +SecretKey.prototype.decrypt = function (passphrase) { + if (this.isDecrypted) + return true; + + var i = 0, + symmetric, + key; + + var s2k_usage = this.encrypted.charCodeAt(i++); + + // - [Optional] If string-to-key usage octet was 255 or 254, a one- + // octet symmetric encryption algorithm. + if (s2k_usage == 255 || s2k_usage == 254) { + symmetric = this.encrypted.charCodeAt(i++); + symmetric = enums.read(enums.symmetric, symmetric); + + // - [Optional] If string-to-key usage octet was 255 or 254, a + // string-to-key specifier. The length of the string-to-key + // specifier is implied by its type, as described above. + var s2k = new type_s2k(); + i += s2k.read(this.encrypted.substr(i)); + + key = produceEncryptionKey(s2k, passphrase, symmetric); + } else { + symmetric = s2k_usage; + symmetric = enums.read(enums.symmetric, symmetric); + key = crypto.hash.md5(passphrase); + } + + + // - [Optional] If secret data is encrypted (string-to-key usage octet + // not zero), an Initial Vector (IV) of the same length as the + // cipher's block size. + var iv = this.encrypted.substr(i, + crypto.cipher[symmetric].blockSize); + + i += iv.length; + + var cleartext, + ciphertext = this.encrypted.substr(i); + + cleartext = crypto.cfb.normalDecrypt(symmetric, key, ciphertext, iv); + + var hash = s2k_usage == 254 ? + 'sha1' : + 'mod'; + + var parsedMPI = parse_cleartext_mpi(hash, cleartext, this.algorithm); + if (parsedMPI instanceof Error) + return false; + this.mpi = this.mpi.concat(parsedMPI); + this.isDecrypted = true; + return true; +}; + +SecretKey.prototype.generate = function (bits) { + this.mpi = crypto.generateMpi(this.algorithm, bits); + this.isDecrypted = true; +}; diff --git a/src/packet/secret_subkey.js b/src/packet/secret_subkey.js index 84d72306..614c6288 100644 --- a/src/packet/secret_subkey.js +++ b/src/packet/secret_subkey.js @@ -20,12 +20,17 @@ * @module packet/secret_subkey */ +module.exports = SecretSubkey; + var secretKey = require('./secret_key.js'); /** * @constructor * @extends module:packet/secret_key */ -module.exports = function secret_subkey() { +function SecretSubkey() { secretKey.call(this); -}; +} + +SecretSubkey.prototype = new secretKey(); +SecretSubkey.prototype.constructor = SecretSubkey; diff --git a/src/packet/signature.js b/src/packet/signature.js index 8c35c48b..c6f15df3 100644 --- a/src/packet/signature.js +++ b/src/packet/signature.js @@ -31,6 +31,8 @@ * @module packet/signature */ +module.exports = Signature; + var util = require('../util'), packet = require('./packet.js'), enums = require('../enums.js'), @@ -41,7 +43,7 @@ var util = require('../util'), /** * @constructor */ -module.exports = function signature() { +function Signature() { this.version = 4; this.signatureType = null; @@ -85,555 +87,554 @@ module.exports = function signature() { this.embeddedSignature = null; this.verified = false; +} - /** - * parsing function for a signature packet (tag 2). - * @param {String} bytes payload of a tag 2 packet - * @param {Integer} position position to start reading from the bytes string - * @param {Integer} len length of the packet or the remaining length of bytes at position - * @return {module:packet/signature} object representation - */ - this.read = function (bytes) { - var i = 0; +/** + * parsing function for a signature packet (tag 2). + * @param {String} bytes payload of a tag 2 packet + * @param {Integer} position position to start reading from the bytes string + * @param {Integer} len length of the packet or the remaining length of bytes at position + * @return {module:packet/signature} object representation + */ +Signature.prototype.read = function (bytes) { + var i = 0; - this.version = bytes.charCodeAt(i++); - // switch on version (3 and 4) - switch (this.version) { - case 3: - // One-octet length of following hashed material. MUST be 5. - if (bytes.charCodeAt(i++) != 5) - util.print_debug("packet/signature.js\n" + - 'invalid One-octet length of following hashed material.' + - 'MUST be 5. @:' + (i - 1)); + this.version = bytes.charCodeAt(i++); + // switch on version (3 and 4) + switch (this.version) { + case 3: + // One-octet length of following hashed material. MUST be 5. + if (bytes.charCodeAt(i++) != 5) + util.print_debug("packet/signature.js\n" + + 'invalid One-octet length of following hashed material.' + + 'MUST be 5. @:' + (i - 1)); - var sigpos = i; - // One-octet signature type. - this.signatureType = bytes.charCodeAt(i++); + var sigpos = i; + // One-octet signature type. + this.signatureType = bytes.charCodeAt(i++); - // Four-octet creation time. - this.created = util.readDate(bytes.substr(i, 4)); - i += 4; + // Four-octet creation time. + this.created = util.readDate(bytes.substr(i, 4)); + i += 4; - // storing data appended to data which gets verified - this.signatureData = bytes.substring(sigpos, i); + // storing data appended to data which gets verified + this.signatureData = bytes.substring(sigpos, i); - // Eight-octet Key ID of signer. - this.issuerKeyId.read(bytes.substring(i, i + 8)); - i += 8; + // Eight-octet Key ID of signer. + this.issuerKeyId.read(bytes.substring(i, i + 8)); + i += 8; - // One-octet public-key algorithm. - this.publicKeyAlgorithm = bytes.charCodeAt(i++); + // One-octet public-key algorithm. + this.publicKeyAlgorithm = bytes.charCodeAt(i++); - // One-octet hash algorithm. - this.hashAlgorithm = bytes.charCodeAt(i++); - break; - case 4: - this.signatureType = bytes.charCodeAt(i++); - this.publicKeyAlgorithm = bytes.charCodeAt(i++); - this.hashAlgorithm = bytes.charCodeAt(i++); + // One-octet hash algorithm. + this.hashAlgorithm = bytes.charCodeAt(i++); + break; + case 4: + this.signatureType = bytes.charCodeAt(i++); + this.publicKeyAlgorithm = bytes.charCodeAt(i++); + this.hashAlgorithm = bytes.charCodeAt(i++); - function subpackets(bytes) { - // Two-octet scalar octet count for following subpacket data. - var subpacket_length = util.readNumber( - bytes.substr(0, 2)); + function subpackets(bytes) { + // Two-octet scalar octet count for following subpacket data. + var subpacket_length = util.readNumber( + bytes.substr(0, 2)); - var i = 2; + var i = 2; - // subpacket data set (zero or more subpackets) - var subpacked_read = 0; - while (i < 2 + subpacket_length) { + // subpacket data set (zero or more subpackets) + var subpacked_read = 0; + while (i < 2 + subpacket_length) { - var len = packet.readSimpleLength(bytes.substr(i)); - i += len.offset; + var len = packet.readSimpleLength(bytes.substr(i)); + i += len.offset; - this.read_sub_packet(bytes.substr(i, len.len)); + this.read_sub_packet(bytes.substr(i, len.len)); - i += len.len; - } - - return i; + i += len.len; } - // hashed subpackets - i += subpackets.call(this, bytes.substr(i), true); - - // A V4 signature hashes the packet body - // starting from its first field, the version number, through the end - // of the hashed subpacket data. Thus, the fields hashed are the - // signature version, the signature type, the public-key algorithm, the - // hash algorithm, the hashed subpacket length, and the hashed - // subpacket body. - this.signatureData = bytes.substr(0, i); - - // unhashed subpackets - i += subpackets.call(this, bytes.substr(i), false); - - break; - default: - throw new Error('Version ' + version + ' of the signature is unsupported.'); - } - - // Two-octet field holding left 16 bits of signed hash value. - this.signedHashValue = bytes.substr(i, 2); - i += 2; - - this.signature = bytes.substr(i); - }; - - this.write = function () { - return this.signatureData + - util.writeNumber(0, 2) + // Number of unsigned subpackets. - this.signedHashValue + - this.signature; - }; - - /** - * Signs provided data. This needs to be done prior to serialization. - * @param {module:packet/secret_key} key private key used to sign the message. - * @param {Object} data Contains packets to be signed. - */ - this.sign = function (key, data) { - var signatureType = enums.write(enums.signature, this.signatureType), - publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), - hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); - - var result = String.fromCharCode(4); - result += String.fromCharCode(signatureType); - result += String.fromCharCode(publicKeyAlgorithm); - result += String.fromCharCode(hashAlgorithm); - - this.issuerKeyId = key.getKeyId(); - - // Add hashed subpackets - result += this.write_all_sub_packets(); - - this.signatureData = result; - - var trailer = this.calculateTrailer(); - - var toHash = this.toSign(signatureType, data) + - this.signatureData + trailer; - - var hash = crypto.hash.digest(hashAlgorithm, toHash); - - this.signedHashValue = hash.substr(0, 2); - - this.signature = crypto.signature.sign(hashAlgorithm, - publicKeyAlgorithm, key.mpi, toHash); - }; - - /** - * Creates string of bytes with all subpacket data - * @return {String} a string-representation of a all subpacket data - */ - this.write_all_sub_packets = function () { - var sub = enums.signatureSubpacket; - var result = ''; - var bytes = ''; - if (this.created !== null) { - result += write_sub_packet(sub.signature_creation_time, util.writeDate(this.created)); - } - if (this.signatureExpirationTime !== null) { - result += write_sub_packet(sub.signature_expiration_time, util.writeNumber(this.signatureExpirationTime, 4)); - } - if (this.exportable !== null) { - result += write_sub_packet(sub.exportable_certification, String.fromCharCode(this.exportable ? 1 : 0)); - } - if (this.trustLevel !== null) { - bytes = String.fromCharCode(this.trustLevel) + String.fromCharCode(this.trustAmount); - result += write_sub_packet(sub.trust_signature, bytes); - } - if (this.regularExpression !== null) { - result += write_sub_packet(sub.regular_expression, this.regularExpression); - } - if (this.revocable !== null) { - result += write_sub_packet(sub.revocable, String.fromCharCode(this.revocable ? 1 : 0)); - } - if (this.keyExpirationTime !== null) { - result += write_sub_packet(sub.key_expiration_time, util.writeNumber(this.keyExpirationTime, 4)); - } - if (this.preferredSymmetricAlgorithms !== null) { - bytes = util.bin2str(this.preferredSymmetricAlgorithms); - result += write_sub_packet(sub.preferred_symmetric_algorithms, bytes); - } - if (this.revocationKeyClass !== null) { - bytes = String.fromCharCode(this.revocationKeyClass); - bytes += String.fromCharCode(this.revocationKeyAlgorithm); - bytes += this.revocationKeyFingerprint; - result += write_sub_packet(sub.revocation_key, bytes); - } - if (!this.issuerKeyId.isNull()) { - result += write_sub_packet(sub.issuer, this.issuerKeyId.write()); - } - if (this.notation !== null) { - for (var name in this.notation) { - if (this.notation.hasOwnProperty(name)) { - var value = this.notation[name]; - bytes = String.fromCharCode(0x80); - bytes += String.fromCharCode(0); - bytes += String.fromCharCode(0); - bytes += String.fromCharCode(0); - // 2 octets of name length - bytes += util.writeNumber(name.length, 2); - // 2 octets of value length - bytes += util.writeNumber(value.length, 2); - bytes += name + value; - result += write_sub_packet(sub.notation_data, bytes); - } + return i; } - } - if (this.preferredHashAlgorithms !== null) { - bytes = util.bin2str(this.preferredHashAlgorithms); - result += write_sub_packet(sub.preferred_hash_algorithms, bytes); - } - if (this.preferredCompressionAlgorithms !== null) { - bytes = util.bin2str(this.preferredCompressionAlgorithms); - result += write_sub_packet(sub.preferred_hash_algorithms, bytes); - } - if (this.keyServerPreferences !== null) { - bytes = util.bin2str(this.keyServerPreferences); - result += write_sub_packet(sub.key_server_preferences, bytes); - } - if (this.preferredKeyServer !== null) { - result += write_sub_packet(sub.preferred_key_server, this.preferredKeyServer); - } - if (this.isPrimaryUserID !== null) { - result += write_sub_packet(sub.primary_user_id, String.fromCharCode(this.isPrimaryUserID ? 1 : 0)); - } - if (this.policyURI !== null) { - result += write_sub_packet(sub.policy_uri, this.policyURI); - } - if (this.keyFlags !== null) { - bytes = util.bin2str(this.keyFlags); - result += write_sub_packet(sub.key_flags, bytes); - } - if (this.signersUserId !== null) { - result += write_sub_packet(sub.signers_user_id, this.signersUserId); - } - if (this.reasonForRevocationFlag !== null) { - bytes = String.fromCharCode(this.reasonForRevocationFlag); - bytes += this.reasonForRevocationString; - result += write_sub_packet(sub.reason_for_revocation, bytes); - } - if (this.features !== null) { - bytes = util.bin2str(this.features); - result += write_sub_packet(sub.features, bytes); - } - if (this.signatureTargetPublicKeyAlgorithm !== null) { - bytes = String.fromCharCode(this.signatureTargetPublicKeyAlgorithm); - bytes += String.fromCharCode(this.signatureTargetHashAlgorithm); - bytes += this.signatureTargetHash; - result += write_sub_packet(sub.signature_target, bytes); - } - if (this.embeddedSignature !== null) { - result += write_sub_packet(sub.embedded_signature, this.embeddedSignature.write()); - } - result = util.writeNumber(result.length, 2) + result; - return result; - }; - /** - * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) - * @param {Integer} type subpacket signature type. Signature types as described - * in RFC4880 Section 5.2.3.2 - * @param {String} data data to be included - * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) - */ - function write_sub_packet(type, data) { - var result = ""; - result += packet.writeSimpleLength(data.length + 1); - result += String.fromCharCode(type); - result += data; - return result; + // hashed subpackets + i += subpackets.call(this, bytes.substr(i), true); + + // A V4 signature hashes the packet body + // starting from its first field, the version number, through the end + // of the hashed subpacket data. Thus, the fields hashed are the + // signature version, the signature type, the public-key algorithm, the + // hash algorithm, the hashed subpacket length, and the hashed + // subpacket body. + this.signatureData = bytes.substr(0, i); + + // unhashed subpackets + i += subpackets.call(this, bytes.substr(i), false); + + break; + default: + throw new Error('Version ' + version + ' of the signature is unsupported.'); } - // V4 signature sub packets + // Two-octet field holding left 16 bits of signed hash value. + this.signedHashValue = bytes.substr(i, 2); + i += 2; - this.read_sub_packet = function (bytes) { - var mypos = 0; - - function read_array(prop, bytes) { - this[prop] = []; - - for (var i = 0; i < bytes.length; i++) { - this[prop].push(bytes.charCodeAt(i)); - } - } - - // The leftwost bit denotes a "critical" packet, but we ignore it. - var type = bytes.charCodeAt(mypos++) & 0x7F; - var seconds; - - // subpacket type - switch (type) { - case 2: - // Signature Creation Time - this.created = util.readDate(bytes.substr(mypos)); - break; - case 3: - // Signature Expiration Time in seconds - seconds = util.readNumber(bytes.substr(mypos)); - - this.signatureNeverExpires = seconds === 0; - this.signatureExpirationTime = seconds; - - break; - case 4: - // Exportable Certification - this.exportable = bytes.charCodeAt(mypos++) == 1; - break; - case 5: - // Trust Signature - this.trustLevel = bytes.charCodeAt(mypos++); - this.trustAmount = bytes.charCodeAt(mypos++); - break; - case 6: - // Regular Expression - this.regularExpression = bytes.substr(mypos); - break; - case 7: - // Revocable - this.revocable = bytes.charCodeAt(mypos++) == 1; - break; - case 9: - // Key Expiration Time in seconds - seconds = util.readNumber(bytes.substr(mypos)); - - this.keyExpirationTime = seconds; - this.keyNeverExpires = seconds === 0; - - break; - case 11: - // Preferred Symmetric Algorithms - this.preferredSymmetricAlgorithms = []; - - while (mypos != bytes.length) { - this.preferredSymmetricAlgorithms.push(bytes.charCodeAt(mypos++)); - } - - break; - case 12: - // Revocation Key - // (1 octet of class, 1 octet of public-key algorithm ID, 20 - // octets of - // fingerprint) - this.revocationKeyClass = bytes.charCodeAt(mypos++); - this.revocationKeyAlgorithm = bytes.charCodeAt(mypos++); - this.revocationKeyFingerprint = bytes.substr(mypos, 20); - break; - - case 16: - // Issuer - this.issuerKeyId.read(bytes.substr(mypos)); - break; - - case 20: - // Notation Data - // We don't know how to handle anything but a text flagged data. - if (bytes.charCodeAt(mypos) == 0x80) { - - // We extract key/value tuple from the byte stream. - mypos += 4; - var m = util.readNumber(bytes.substr(mypos, 2)); - mypos += 2; - var n = util.readNumber(bytes.substr(mypos, 2)); - mypos += 2; - - var name = bytes.substr(mypos, m), - value = bytes.substr(mypos + m, n); - - this.notation = this.notation || {}; - this.notation[name] = value; - } else throw new Error("Unsupported notation flag."); - break; - case 21: - // Preferred Hash Algorithms - read_array.call(this, 'preferredHashAlgorithms', bytes.substr(mypos)); - break; - case 22: - // Preferred Compression Algorithms - read_array.call(this, 'preferredCompressionAlgorithms ', bytes.substr(mypos)); - break; - case 23: - // Key Server Preferences - read_array.call(this, 'keyServerPreferencess', bytes.substr(mypos)); - break; - case 24: - // Preferred Key Server - this.preferredKeyServer = bytes.substr(mypos); - break; - case 25: - // Primary User ID - this.isPrimaryUserID = bytes[mypos++] !== 0; - break; - case 26: - // Policy URI - this.policyURI = bytes.substr(mypos); - break; - case 27: - // Key Flags - read_array.call(this, 'keyFlags', bytes.substr(mypos)); - break; - case 28: - // Signer's User ID - this.signersUserId += bytes.substr(mypos); - break; - case 29: - // Reason for Revocation - this.reasonForRevocationFlag = bytes.charCodeAt(mypos++); - this.reasonForRevocationString = bytes.substr(mypos); - break; - case 30: - // Features - read_array.call(this, 'features', bytes.substr(mypos)); - break; - case 31: - // Signature Target - // (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) - this.signatureTargetPublicKeyAlgorithm = bytes.charCodeAt(mypos++); - this.signatureTargetHashAlgorithm = bytes.charCodeAt(mypos++); - - var len = crypto.getHashByteLength(this.signatureTargetHashAlgorithm); - - this.signatureTargetHash = bytes.substr(mypos, len); - break; - case 32: - // Embedded Signature - this.embeddedSignature = new signature(); - this.embeddedSignature.read(bytes.substr(mypos)); - break; - default: - throw new Error("Unknown signature subpacket type " + type + " @:" + mypos); - } - }; - - // Produces data to produce signature on - this.toSign = function (type, data) { - var t = enums.signature; - - switch (type) { - case t.binary: - case t.text: - return data.getBytes(); - - case t.standalone: - return ''; - - case t.cert_generic: - case t.cert_persona: - case t.cert_casual: - case t.cert_positive: - case t.cert_revocation: - var packet, tag; - - if (data.userid !== undefined) { - tag = 0xB4; - packet = data.userid; - } else if (data.userattribute !== undefined) { - tag = 0xD1; - packet = data.userattribute; - } else throw new Error('Either a userid or userattribute packet needs to be ' + - 'supplied for certification.'); - - var bytes = packet.write(); - - if (this.version == 4) { - return this.toSign(t.key, data) + - String.fromCharCode(tag) + - util.writeNumber(bytes.length, 4) + - bytes; - } else if (this.version == 3) { - return this.toSign(t.key, data) + - bytes; - } - break; - - case t.subkey_binding: - case t.key_binding: - return this.toSign(t.key, data) + this.toSign(t.key, { - key: data.bind - }); - - case t.key: - if (data.key === undefined) - throw new Error('Key packet is required for this sigtature.'); - - return data.key.writeOld(); - - case t.key_revocation: - case t.subkey_revocation: - return this.toSign(t.key, data); - case t.timestamp: - return ''; - case t.third_party: - throw new Error('Not implemented'); - default: - throw new Error('Unknown signature type.'); - } - }; - - - this.calculateTrailer = function () { - // calculating the trailer - var trailer = ''; - // V3 signatures don't have a trailer - if (this.version == 3) return trailer; - trailer += String.fromCharCode(4); // Version - trailer += String.fromCharCode(0xFF); - trailer += util.writeNumber(this.signatureData.length, 4); - return trailer; - }; - - - /** - * verifys the signature packet. Note: not signature types are implemented - * @param {String|Object} data data which on the signature applies - * @param {module:packet/public_subkey|module:packet/public_key} key the public key to verify the signature - * @return {boolean} True if message is verified, else false. - */ - this.verify = function (key, data) { - var signatureType = enums.write(enums.signature, this.signatureType), - publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), - hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); - - var bytes = this.toSign(signatureType, data), - trailer = this.calculateTrailer(); - - - 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) - mpicount = 1; - // Algorithm-Specific Fields for DSA signatures: - // - MPI of DSA value r. - // - MPI of DSA value s. - else if (publicKeyAlgorithm == 17) - mpicount = 2; - - var mpi = [], - i = 0; - for (var j = 0; j < mpicount; j++) { - mpi[j] = new type_mpi(); - i += mpi[j].read(this.signature.substr(i)); - } - - this.verified = crypto.signature.verify(publicKeyAlgorithm, - hashAlgorithm, mpi, key.mpi, - bytes + this.signatureData + trailer); - - return this.verified; - }; - - /** - * Verifies signature expiration date - * @return {Boolean} true if expired - */ - this.isExpired = function () { - if (!this.signatureNeverExpires) { - return Date.now() > (this.created.getTime() + this.signatureExpirationTime*1000); - } - return false; - }; + this.signature = bytes.substr(i); }; +Signature.prototype.write = function () { + return this.signatureData + + util.writeNumber(0, 2) + // Number of unsigned subpackets. + this.signedHashValue + + this.signature; +}; + +/** + * Signs provided data. This needs to be done prior to serialization. + * @param {module:packet/secret_key} key private key used to sign the message. + * @param {Object} data Contains packets to be signed. + */ +Signature.prototype.sign = function (key, data) { + var signatureType = enums.write(enums.signature, this.signatureType), + publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), + hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); + + var result = String.fromCharCode(4); + result += String.fromCharCode(signatureType); + result += String.fromCharCode(publicKeyAlgorithm); + result += String.fromCharCode(hashAlgorithm); + + this.issuerKeyId = key.getKeyId(); + + // Add hashed subpackets + result += this.write_all_sub_packets(); + + this.signatureData = result; + + var trailer = this.calculateTrailer(); + + var toHash = this.toSign(signatureType, data) + + this.signatureData + trailer; + + var hash = crypto.hash.digest(hashAlgorithm, toHash); + + this.signedHashValue = hash.substr(0, 2); + + this.signature = crypto.signature.sign(hashAlgorithm, + publicKeyAlgorithm, key.mpi, toHash); +}; + +/** + * Creates string of bytes with all subpacket data + * @return {String} a string-representation of a all subpacket data + */ +Signature.prototype.write_all_sub_packets = function () { + var sub = enums.signatureSubpacket; + var result = ''; + var bytes = ''; + if (this.created !== null) { + result += write_sub_packet(sub.signature_creation_time, util.writeDate(this.created)); + } + if (this.signatureExpirationTime !== null) { + result += write_sub_packet(sub.signature_expiration_time, util.writeNumber(this.signatureExpirationTime, 4)); + } + if (this.exportable !== null) { + result += write_sub_packet(sub.exportable_certification, String.fromCharCode(this.exportable ? 1 : 0)); + } + if (this.trustLevel !== null) { + bytes = String.fromCharCode(this.trustLevel) + String.fromCharCode(this.trustAmount); + result += write_sub_packet(sub.trust_signature, bytes); + } + if (this.regularExpression !== null) { + result += write_sub_packet(sub.regular_expression, this.regularExpression); + } + if (this.revocable !== null) { + result += write_sub_packet(sub.revocable, String.fromCharCode(this.revocable ? 1 : 0)); + } + if (this.keyExpirationTime !== null) { + result += write_sub_packet(sub.key_expiration_time, util.writeNumber(this.keyExpirationTime, 4)); + } + if (this.preferredSymmetricAlgorithms !== null) { + bytes = util.bin2str(this.preferredSymmetricAlgorithms); + result += write_sub_packet(sub.preferred_symmetric_algorithms, bytes); + } + if (this.revocationKeyClass !== null) { + bytes = String.fromCharCode(this.revocationKeyClass); + bytes += String.fromCharCode(this.revocationKeyAlgorithm); + bytes += this.revocationKeyFingerprint; + result += write_sub_packet(sub.revocation_key, bytes); + } + if (!this.issuerKeyId.isNull()) { + result += write_sub_packet(sub.issuer, this.issuerKeyId.write()); + } + if (this.notation !== null) { + for (var name in this.notation) { + if (this.notation.hasOwnProperty(name)) { + var value = this.notation[name]; + bytes = String.fromCharCode(0x80); + bytes += String.fromCharCode(0); + bytes += String.fromCharCode(0); + bytes += String.fromCharCode(0); + // 2 octets of name length + bytes += util.writeNumber(name.length, 2); + // 2 octets of value length + bytes += util.writeNumber(value.length, 2); + bytes += name + value; + result += write_sub_packet(sub.notation_data, bytes); + } + } + } + if (this.preferredHashAlgorithms !== null) { + bytes = util.bin2str(this.preferredHashAlgorithms); + result += write_sub_packet(sub.preferred_hash_algorithms, bytes); + } + if (this.preferredCompressionAlgorithms !== null) { + bytes = util.bin2str(this.preferredCompressionAlgorithms); + result += write_sub_packet(sub.preferred_hash_algorithms, bytes); + } + if (this.keyServerPreferences !== null) { + bytes = util.bin2str(this.keyServerPreferences); + result += write_sub_packet(sub.key_server_preferences, bytes); + } + if (this.preferredKeyServer !== null) { + result += write_sub_packet(sub.preferred_key_server, this.preferredKeyServer); + } + if (this.isPrimaryUserID !== null) { + result += write_sub_packet(sub.primary_user_id, String.fromCharCode(this.isPrimaryUserID ? 1 : 0)); + } + if (this.policyURI !== null) { + result += write_sub_packet(sub.policy_uri, this.policyURI); + } + if (this.keyFlags !== null) { + bytes = util.bin2str(this.keyFlags); + result += write_sub_packet(sub.key_flags, bytes); + } + if (this.signersUserId !== null) { + result += write_sub_packet(sub.signers_user_id, this.signersUserId); + } + if (this.reasonForRevocationFlag !== null) { + bytes = String.fromCharCode(this.reasonForRevocationFlag); + bytes += this.reasonForRevocationString; + result += write_sub_packet(sub.reason_for_revocation, bytes); + } + if (this.features !== null) { + bytes = util.bin2str(this.features); + result += write_sub_packet(sub.features, bytes); + } + if (this.signatureTargetPublicKeyAlgorithm !== null) { + bytes = String.fromCharCode(this.signatureTargetPublicKeyAlgorithm); + bytes += String.fromCharCode(this.signatureTargetHashAlgorithm); + bytes += this.signatureTargetHash; + result += write_sub_packet(sub.signature_target, bytes); + } + if (this.embeddedSignature !== null) { + result += write_sub_packet(sub.embedded_signature, this.embeddedSignature.write()); + } + result = util.writeNumber(result.length, 2) + result; + return result; +}; + +/** + * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) + * @param {Integer} type subpacket signature type. Signature types as described + * in RFC4880 Section 5.2.3.2 + * @param {String} data data to be included + * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) + */ +function write_sub_packet(type, data) { + var result = ""; + result += packet.writeSimpleLength(data.length + 1); + result += String.fromCharCode(type); + result += data; + return result; +} + +// V4 signature sub packets + +Signature.prototype.read_sub_packet = function (bytes) { + var mypos = 0; + + function read_array(prop, bytes) { + this[prop] = []; + + for (var i = 0; i < bytes.length; i++) { + this[prop].push(bytes.charCodeAt(i)); + } + } + + // The leftwost bit denotes a "critical" packet, but we ignore it. + var type = bytes.charCodeAt(mypos++) & 0x7F; + var seconds; + + // subpacket type + switch (type) { + case 2: + // Signature Creation Time + this.created = util.readDate(bytes.substr(mypos)); + break; + case 3: + // Signature Expiration Time in seconds + seconds = util.readNumber(bytes.substr(mypos)); + + this.signatureNeverExpires = seconds === 0; + this.signatureExpirationTime = seconds; + + break; + case 4: + // Exportable Certification + this.exportable = bytes.charCodeAt(mypos++) == 1; + break; + case 5: + // Trust Signature + this.trustLevel = bytes.charCodeAt(mypos++); + this.trustAmount = bytes.charCodeAt(mypos++); + break; + case 6: + // Regular Expression + this.regularExpression = bytes.substr(mypos); + break; + case 7: + // Revocable + this.revocable = bytes.charCodeAt(mypos++) == 1; + break; + case 9: + // Key Expiration Time in seconds + seconds = util.readNumber(bytes.substr(mypos)); + + this.keyExpirationTime = seconds; + this.keyNeverExpires = seconds === 0; + + break; + case 11: + // Preferred Symmetric Algorithms + this.preferredSymmetricAlgorithms = []; + + while (mypos != bytes.length) { + this.preferredSymmetricAlgorithms.push(bytes.charCodeAt(mypos++)); + } + + break; + case 12: + // Revocation Key + // (1 octet of class, 1 octet of public-key algorithm ID, 20 + // octets of + // fingerprint) + this.revocationKeyClass = bytes.charCodeAt(mypos++); + this.revocationKeyAlgorithm = bytes.charCodeAt(mypos++); + this.revocationKeyFingerprint = bytes.substr(mypos, 20); + break; + + case 16: + // Issuer + this.issuerKeyId.read(bytes.substr(mypos)); + break; + + case 20: + // Notation Data + // We don't know how to handle anything but a text flagged data. + if (bytes.charCodeAt(mypos) == 0x80) { + + // We extract key/value tuple from the byte stream. + mypos += 4; + var m = util.readNumber(bytes.substr(mypos, 2)); + mypos += 2; + var n = util.readNumber(bytes.substr(mypos, 2)); + mypos += 2; + + var name = bytes.substr(mypos, m), + value = bytes.substr(mypos + m, n); + + this.notation = this.notation || {}; + this.notation[name] = value; + } else throw new Error("Unsupported notation flag."); + break; + case 21: + // Preferred Hash Algorithms + read_array.call(this, 'preferredHashAlgorithms', bytes.substr(mypos)); + break; + case 22: + // Preferred Compression Algorithms + read_array.call(this, 'preferredCompressionAlgorithms ', bytes.substr(mypos)); + break; + case 23: + // Key Server Preferences + read_array.call(this, 'keyServerPreferencess', bytes.substr(mypos)); + break; + case 24: + // Preferred Key Server + this.preferredKeyServer = bytes.substr(mypos); + break; + case 25: + // Primary User ID + this.isPrimaryUserID = bytes[mypos++] !== 0; + break; + case 26: + // Policy URI + this.policyURI = bytes.substr(mypos); + break; + case 27: + // Key Flags + read_array.call(this, 'keyFlags', bytes.substr(mypos)); + break; + case 28: + // Signer's User ID + this.signersUserId += bytes.substr(mypos); + break; + case 29: + // Reason for Revocation + this.reasonForRevocationFlag = bytes.charCodeAt(mypos++); + this.reasonForRevocationString = bytes.substr(mypos); + break; + case 30: + // Features + read_array.call(this, 'features', bytes.substr(mypos)); + break; + case 31: + // Signature Target + // (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) + this.signatureTargetPublicKeyAlgorithm = bytes.charCodeAt(mypos++); + this.signatureTargetHashAlgorithm = bytes.charCodeAt(mypos++); + + var len = crypto.getHashByteLength(this.signatureTargetHashAlgorithm); + + this.signatureTargetHash = bytes.substr(mypos, len); + break; + case 32: + // Embedded Signature + this.embeddedSignature = new Signature(); + this.embeddedSignature.read(bytes.substr(mypos)); + break; + default: + throw new Error("Unknown signature subpacket type " + type + " @:" + mypos); + } +}; + +// Produces data to produce signature on +Signature.prototype.toSign = function (type, data) { + var t = enums.signature; + + switch (type) { + case t.binary: + case t.text: + return data.getBytes(); + + case t.standalone: + return ''; + + case t.cert_generic: + case t.cert_persona: + case t.cert_casual: + case t.cert_positive: + case t.cert_revocation: + var packet, tag; + + if (data.userid !== undefined) { + tag = 0xB4; + packet = data.userid; + } else if (data.userattribute !== undefined) { + tag = 0xD1; + packet = data.userattribute; + } else throw new Error('Either a userid or userattribute packet needs to be ' + + 'supplied for certification.'); + + var bytes = packet.write(); + + if (this.version == 4) { + return this.toSign(t.key, data) + + String.fromCharCode(tag) + + util.writeNumber(bytes.length, 4) + + bytes; + } else if (this.version == 3) { + return this.toSign(t.key, data) + + bytes; + } + break; + + case t.subkey_binding: + case t.key_binding: + return this.toSign(t.key, data) + this.toSign(t.key, { + key: data.bind + }); + + case t.key: + if (data.key === undefined) + throw new Error('Key packet is required for this sigtature.'); + + return data.key.writeOld(); + + case t.key_revocation: + case t.subkey_revocation: + return this.toSign(t.key, data); + case t.timestamp: + return ''; + case t.third_party: + throw new Error('Not implemented'); + default: + throw new Error('Unknown signature type.'); + } +}; + + +Signature.prototype.calculateTrailer = function () { + // calculating the trailer + var trailer = ''; + // V3 signatures don't have a trailer + if (this.version == 3) return trailer; + trailer += String.fromCharCode(4); // Version + trailer += String.fromCharCode(0xFF); + trailer += util.writeNumber(this.signatureData.length, 4); + return trailer; +}; + + +/** + * verifys the signature packet. Note: not signature types are implemented + * @param {String|Object} data data which on the signature applies + * @param {module:packet/public_subkey|module:packet/public_key} key the public key to verify the signature + * @return {boolean} True if message is verified, else false. + */ +Signature.prototype.verify = function (key, data) { + var signatureType = enums.write(enums.signature, this.signatureType), + publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), + hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); + + var bytes = this.toSign(signatureType, data), + trailer = this.calculateTrailer(); + + + 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) + mpicount = 1; + // Algorithm-Specific Fields for DSA signatures: + // - MPI of DSA value r. + // - MPI of DSA value s. + else if (publicKeyAlgorithm == 17) + mpicount = 2; + + var mpi = [], + i = 0; + for (var j = 0; j < mpicount; j++) { + mpi[j] = new type_mpi(); + i += mpi[j].read(this.signature.substr(i)); + } + + this.verified = crypto.signature.verify(publicKeyAlgorithm, + hashAlgorithm, mpi, key.mpi, + bytes + this.signatureData + trailer); + + return this.verified; +}; + +/** + * Verifies signature expiration date + * @return {Boolean} true if expired + */ +Signature.prototype.isExpired = function () { + if (!this.signatureNeverExpires) { + return Date.now() > (this.created.getTime() + this.signatureExpirationTime*1000); + } + return false; +}; diff --git a/src/packet/sym_encrypted_integrity_protected.js b/src/packet/sym_encrypted_integrity_protected.js index dec28bb5..8ca0aa2b 100644 --- a/src/packet/sym_encrypted_integrity_protected.js +++ b/src/packet/sym_encrypted_integrity_protected.js @@ -29,13 +29,15 @@ * @module packet/sym_encrypted_integrity_protected */ +module.exports = SymEncryptedIntegrityProtected; + var util = require('../util'), crypto = require('../crypto'); /** * @constructor */ -module.exports = function sym_encrypted_integrity_protected() { +function SymEncryptedIntegrityProtected() { /** The encrypted payload. */ this.encrypted = null; // string /** @@ -46,76 +48,75 @@ module.exports = function sym_encrypted_integrity_protected() { */ this.modification = false; this.packets = null; +} +SymEncryptedIntegrityProtected.prototype.read = function (bytes) { + // - A one-octet version number. The only currently defined value is 1. + var version = bytes.charCodeAt(0); - this.read = function (bytes) { - // - A one-octet version number. The only currently defined value is 1. - var version = bytes.charCodeAt(0); + if (version != 1) { + throw new Error('Invalid packet version.'); + } - if (version != 1) { - throw new Error('Invalid packet version.'); - } - - // - Encrypted data, the output of the selected symmetric-key cipher - // 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 () { - - // 1 = Version - return String.fromCharCode(1) + this.encrypted; - }; - - this.encrypt = function (sessionKeyAlgorithm, key) { - var bytes = this.packets.write(); - - var prefixrandom = crypto.getPrefixRandom(sessionKeyAlgorithm); - var prefix = prefixrandom + prefixrandom.charAt(prefixrandom.length - 2) + prefixrandom.charAt(prefixrandom.length - - 1); - - var tohash = bytes; - - - // Modification detection code packet. - tohash += String.fromCharCode(0xD3); - tohash += String.fromCharCode(0x14); - - - tohash += crypto.hash.sha1(prefix + tohash); - - - 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 - * have been called before - * - * @param {Integer} sessionKeyAlgorithm - * The selected symmetric encryption algorithm to be used - * @param {String} key The key of cipher blocksize length to be used - * @return {String} The decrypted data of this packet - */ - this.decrypt = function (sessionKeyAlgorithm, key) { - var decrypted = crypto.cfb.decrypt( - sessionKeyAlgorithm, key, this.encrypted, false); - - - // there must be a modification detection code packet as the - // last packet and everything gets hashed except the hash itself - this.hash = crypto.hash.sha1( - crypto.cfb.mdc(sessionKeyAlgorithm, key, this.encrypted) + decrypted.substring(0, decrypted.length - 20)); - - - var mdc = decrypted.substr(decrypted.length - 20, 20); - - if (this.hash != mdc) { - throw new Error('Modification detected.'); - } else - this.packets.read(decrypted.substr(0, decrypted.length - 22)); - }; + // - Encrypted data, the output of the selected symmetric-key cipher + // 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); +}; + +SymEncryptedIntegrityProtected.prototype.write = function () { + + // 1 = Version + return String.fromCharCode(1) + this.encrypted; +}; + +SymEncryptedIntegrityProtected.prototype.encrypt = function (sessionKeyAlgorithm, key) { + var bytes = this.packets.write(); + + var prefixrandom = crypto.getPrefixRandom(sessionKeyAlgorithm); + var prefix = prefixrandom + prefixrandom.charAt(prefixrandom.length - 2) + prefixrandom.charAt(prefixrandom.length - + 1); + + var tohash = bytes; + + + // Modification detection code packet. + tohash += String.fromCharCode(0xD3); + tohash += String.fromCharCode(0x14); + + + tohash += crypto.hash.sha1(prefix + tohash); + + + 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 + * have been called before + * + * @param {Integer} sessionKeyAlgorithm + * The selected symmetric encryption algorithm to be used + * @param {String} key The key of cipher blocksize length to be used + * @return {String} The decrypted data of this packet + */ +SymEncryptedIntegrityProtected.prototype.decrypt = function (sessionKeyAlgorithm, key) { + var decrypted = crypto.cfb.decrypt( + sessionKeyAlgorithm, key, this.encrypted, false); + + + // there must be a modification detection code packet as the + // last packet and everything gets hashed except the hash itself + this.hash = crypto.hash.sha1( + crypto.cfb.mdc(sessionKeyAlgorithm, key, this.encrypted) + decrypted.substring(0, decrypted.length - 20)); + + + var mdc = decrypted.substr(decrypted.length - 20, 20); + + if (this.hash != mdc) { + throw new Error('Modification detected.'); + } else + this.packets.read(decrypted.substr(0, decrypted.length - 22)); }; diff --git a/src/packet/sym_encrypted_session_key.js b/src/packet/sym_encrypted_session_key.js index 68d7936e..bc3686bd 100644 --- a/src/packet/sym_encrypted_session_key.js +++ b/src/packet/sym_encrypted_session_key.js @@ -39,102 +39,104 @@ var type_s2k = require('../type/s2k.js'), enums = require('../enums.js'), crypto = require('../crypto'); +module.exports = SymEncryptedSessionKey; + /** * @constructor */ -module.exports = function sym_encrypted_session_key() { +function SymEncryptedSessionKey() { this.tag = 3; this.sessionKeyEncryptionAlgorithm = null; this.sessionKeyAlgorithm = 'aes256'; this.encrypted = null; this.s2k = new type_s2k(); +} - /** - * Parsing function for a symmetric encrypted session key packet (tag 3). - * - * @param {String} input Payload of a tag 1 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/sym_encrypted_session_key} Object representation - */ - this.read = function(bytes) { - // A one-octet version number. The only currently defined version is 4. - this.version = bytes.charCodeAt(0); +/** + * Parsing function for a symmetric encrypted session key packet (tag 3). + * + * @param {String} input Payload of a tag 1 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/sym_encrypted_session_key} Object representation + */ +SymEncryptedSessionKey.prototype.read = function(bytes) { + // A one-octet version number. The only currently defined version is 4. + this.version = bytes.charCodeAt(0); - // A one-octet number describing the symmetric algorithm used. - var algo = enums.read(enums.symmetric, bytes.charCodeAt(1)); + // A one-octet number describing the symmetric algorithm used. + var algo = enums.read(enums.symmetric, bytes.charCodeAt(1)); - // A string-to-key (S2K) specifier, length as defined above. - var s2klength = this.s2k.read(bytes.substr(2)); + // A string-to-key (S2K) specifier, length as defined above. + var s2klength = this.s2k.read(bytes.substr(2)); - // Optionally, the encrypted session key itself, which is decrypted - // with the string-to-key object. - var done = s2klength + 2; + // Optionally, the encrypted session key itself, which is decrypted + // with the string-to-key object. + var done = s2klength + 2; - if (done < bytes.length) { - this.encrypted = bytes.substr(done); - this.sessionKeyEncryptionAlgorithm = algo; - } else - this.sessionKeyAlgorithm = algo; - }; - - this.write = function() { - var algo = this.encrypted === null ? - this.sessionKeyAlgorithm : - this.sessionKeyEncryptionAlgorithm; - - var bytes = String.fromCharCode(this.version) + - String.fromCharCode(enums.write(enums.symmetric, algo)) + - this.s2k.write(); - - if (this.encrypted !== null) - bytes += this.encrypted; - return bytes; - }; - - /** - * Decrypts the session key (only for public key encrypted session key - * packets (tag 1) - * - * @return {String} The unencrypted session key - */ - this.decrypt = function(passphrase) { - var algo = this.sessionKeyEncryptionAlgorithm !== null ? - this.sessionKeyEncryptionAlgorithm : - this.sessionKeyAlgorithm; - - - var length = crypto.cipher[algo].keySize; - var key = this.s2k.produce_key(passphrase, length); - - if (this.encrypted === null) { - this.sessionKey = key; - - } else { - var decrypted = crypto.cfb.decrypt( - this.sessionKeyEncryptionAlgorithm, key, this.encrypted, true); - - this.sessionKeyAlgorithm = enums.read(enums.symmetric, - decrypted[0].keyCodeAt()); - - this.sessionKey = decrypted.substr(1); - } - }; - - this.encrypt = function(passphrase) { - var length = crypto.getKeyLength(this.sessionKeyEncryptionAlgorithm); - var key = this.s2k.produce_key(passphrase, length); - - var private_key = String.fromCharCode( - enums.write(enums.symmetric, this.sessionKeyAlgorithm)) + - - crypto.getRandomBytes( - crypto.getKeyLength(this.sessionKeyAlgorithm)); - - this.encrypted = crypto.cfb.encrypt( - crypto.getPrefixRandom(this.sessionKeyEncryptionAlgorithm), - this.sessionKeyEncryptionAlgorithm, key, private_key, true); - }; + if (done < bytes.length) { + this.encrypted = bytes.substr(done); + this.sessionKeyEncryptionAlgorithm = algo; + } else + this.sessionKeyAlgorithm = algo; +}; + +SymEncryptedSessionKey.prototype.write = function() { + var algo = this.encrypted === null ? + this.sessionKeyAlgorithm : + this.sessionKeyEncryptionAlgorithm; + + var bytes = String.fromCharCode(this.version) + + String.fromCharCode(enums.write(enums.symmetric, algo)) + + this.s2k.write(); + + if (this.encrypted !== null) + bytes += this.encrypted; + return bytes; +}; + +/** + * Decrypts the session key (only for public key encrypted session key + * packets (tag 1) + * + * @return {String} The unencrypted session key + */ +SymEncryptedSessionKey.prototype.decrypt = function(passphrase) { + var algo = this.sessionKeyEncryptionAlgorithm !== null ? + this.sessionKeyEncryptionAlgorithm : + this.sessionKeyAlgorithm; + + + var length = crypto.cipher[algo].keySize; + var key = this.s2k.produce_key(passphrase, length); + + if (this.encrypted === null) { + this.sessionKey = key; + + } else { + var decrypted = crypto.cfb.decrypt( + this.sessionKeyEncryptionAlgorithm, key, this.encrypted, true); + + this.sessionKeyAlgorithm = enums.read(enums.symmetric, + decrypted[0].keyCodeAt()); + + this.sessionKey = decrypted.substr(1); + } +}; + +SymEncryptedSessionKey.prototype.encrypt = function(passphrase) { + var length = crypto.getKeyLength(this.sessionKeyEncryptionAlgorithm); + var key = this.s2k.produce_key(passphrase, length); + + var private_key = String.fromCharCode( + enums.write(enums.symmetric, this.sessionKeyAlgorithm)) + + + crypto.getRandomBytes( + crypto.getKeyLength(this.sessionKeyAlgorithm)); + + this.encrypted = crypto.cfb.encrypt( + crypto.getPrefixRandom(this.sessionKeyEncryptionAlgorithm), + this.sessionKeyEncryptionAlgorithm, key, private_key, true); }; diff --git a/src/packet/symmetrically_encrypted.js b/src/packet/symmetrically_encrypted.js index cc949d93..873cdd5f 100644 --- a/src/packet/symmetrically_encrypted.js +++ b/src/packet/symmetrically_encrypted.js @@ -27,45 +27,47 @@ * @module packet/symmetrically_encrypted */ +module.exports = SymmetricallyEncrypted; + var crypto = require('../crypto'); /** * @constructor */ -module.exports = function symmetrically_encrypted() { +function SymmetricallyEncrypted() { this.encrypted = null; /** Decrypted packets contained within. * @type {module:packet/packetlist} */ this.packets = null; +} - this.read = function(bytes) { - this.encrypted = bytes; - }; - - this.write = function() { - return this.encrypted; - }; - - /** - * Symmetrically decrypt the packet data - * - * @param {Integer} sessionKeyAlgorithm - * Symmetric key algorithm to use // See RFC4880 9.2 - * @param {String} key - * Key as string with the corresponding length to the - * algorithm - */ - this.decrypt = function(sessionKeyAlgorithm, key) { - var decrypted = crypto.cfb.decrypt( - sessionKeyAlgorithm, key, this.encrypted, true); - - this.packets.read(decrypted); - }; - - this.encrypt = function(algo, key) { - var data = this.packets.write(); - - this.encrypted = crypto.cfb.encrypt( - crypto.getPrefixRandom(algo), algo, data, key, true); - }; +SymmetricallyEncrypted.prototype.read = function (bytes) { + this.encrypted = bytes; +}; + +SymmetricallyEncrypted.prototype.write = function () { + return this.encrypted; +}; + +/** + * Symmetrically decrypt the packet data + * + * @param {Integer} sessionKeyAlgorithm + * Symmetric key algorithm to use // See RFC4880 9.2 + * @param {String} key + * Key as string with the corresponding length to the + * algorithm + */ +SymmetricallyEncrypted.prototype.decrypt = function (sessionKeyAlgorithm, key) { + var decrypted = crypto.cfb.decrypt( + sessionKeyAlgorithm, key, this.encrypted, true); + + this.packets.read(decrypted); +}; + +SymmetricallyEncrypted.prototype.encrypt = function (algo, key) { + var data = this.packets.write(); + + this.encrypted = crypto.cfb.encrypt( + crypto.getPrefixRandom(algo), algo, data, key, true); }; diff --git a/src/packet/trust.js b/src/packet/trust.js index f35ce337..e96b3c33 100644 --- a/src/packet/trust.js +++ b/src/packet/trust.js @@ -2,9 +2,10 @@ * @module packet/trust */ +module.exports = Trust; + /** * @constructor */ -module.exports = function trust() { - +function Trust() { }; diff --git a/src/packet/user_attribute.js b/src/packet/user_attribute.js index fc344d21..787739dd 100644 --- a/src/packet/user_attribute.js +++ b/src/packet/user_attribute.js @@ -38,25 +38,26 @@ var util = require('../util'), packet = require('./packet.js'); +module.exports = UserAttribute; + /** * @constructor */ -module.exports = function user_attribute() { - this.tag = 17; +function UserAttribute() { this.attributes = []; +} - /** - * parsing function for a user attribute packet (tag 17). - * @param {String} input payload of a tag 17 packet - */ - this.read = function(bytes) { - var i = 0; - while (i < bytes.length) { - var len = packet.readSimpleLength(bytes.substr(i)); - i += len.offset; +/** + * parsing function for a user attribute packet (tag 17). + * @param {String} input payload of a tag 17 packet + */ +UserAttribute.prototype.read = function(bytes) { + var i = 0; + while (i < bytes.length) { + var len = packet.readSimpleLength(bytes.substr(i)); + i += len.offset; - this.attributes.push(bytes.substr(i, len.len)); - i += len.len; - } - }; + this.attributes.push(bytes.substr(i, len.len)); + i += len.len; + } }; diff --git a/src/packet/userid.js b/src/packet/userid.js index fb983daa..bc0ad6a8 100644 --- a/src/packet/userid.js +++ b/src/packet/userid.js @@ -27,32 +27,33 @@ * @module packet/userid */ +module.exports = Userid; + var util = require('../util'); /** * @constructor */ -module.exports = function userid() { +function Userid() { /** A string containing the user id. Usually in the form * John Doe * @type {String} */ this.userid = ''; +} - - /** - * Parsing function for a user id packet (tag 13). - * @param {String} input payload of a tag 13 packet - */ - this.read = function (bytes) { - this.userid = util.decode_utf8(bytes); - }; - - /** - * Creates a string representation of the user id packet - * @return {String} string representation - */ - this.write = function () { - return util.encode_utf8(this.userid); - }; +/** + * Parsing function for a user id packet (tag 13). + * @param {String} input payload of a tag 13 packet + */ +Userid.prototype.read = function (bytes) { + this.userid = util.decode_utf8(bytes); +}; + +/** + * Creates a string representation of the user id packet + * @return {String} string representation + */ +Userid.prototype.write = function () { + return util.encode_utf8(this.userid); }; diff --git a/src/type/keyid.js b/src/type/keyid.js index 5a632f3d..40cb8d9e 100644 --- a/src/type/keyid.js +++ b/src/type/keyid.js @@ -26,41 +26,42 @@ * @module type/keyid */ +module.exports = Keyid; + var util = require('../util'); /** * @constructor */ -module.exports = function keyid() { +function Keyid() { this.bytes = ''; +} - - /** - * Parsing method for a key id - * @param {String} input Input to read the key id from - */ - this.read = function(bytes) { - this.bytes = bytes.substr(0, 8); - }; - - this.write = function() { - return this.bytes; - }; - - this.toHex = function() { - return util.hexstrdump(this.bytes); - }; - - this.equals = function(keyid) { - return this.bytes == keyid.bytes; - }; - - this.isNull = function() { - return this.bytes === ''; - }; +/** + * Parsing method for a key id + * @param {String} input Input to read the key id from + */ +Keyid.prototype.read = function(bytes) { + this.bytes = bytes.substr(0, 8); }; -module.exports.mapToHex = function(keyId) { +Keyid.prototype.write = function() { + return this.bytes; +}; + +Keyid.prototype.toHex = function() { + return util.hexstrdump(this.bytes); +}; + +Keyid.prototype.equals = function(keyid) { + return this.bytes == keyid.bytes; +}; + +Keyid.prototype.isNull = function() { + return this.bytes === ''; +}; + +module.exports.mapToHex = function (keyId) { return keyId.toHex(); }; diff --git a/src/type/mpi.js b/src/type/mpi.js index a094cee1..43ddb0f5 100644 --- a/src/type/mpi.js +++ b/src/type/mpi.js @@ -34,67 +34,69 @@ * @module type/mpi */ +module.exports = Mpi; + var BigInteger = require('../crypto/public_key/jsbn.js'), util = require('../util'); /** * @constructor */ -module.exports = function mpi() { +function Mpi() { /** An implementation dependent integer */ this.data = null; +} - /** - * Parsing function for a mpi (RFC 4880 3.2). - * @param {String} input Payload of mpi data - * @return {Integer} Length of data read - */ - this.read = function (bytes) { - var bits = (bytes.charCodeAt(0) << 8) | bytes.charCodeAt(1); +/** + * Parsing function for a mpi (RFC 4880 3.2). + * @param {String} input Payload of mpi data + * @return {Integer} Length of data read + */ +Mpi.prototype.read = function (bytes) { + var bits = (bytes.charCodeAt(0) << 8) | bytes.charCodeAt(1); - // Additional rules: - // - // The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. - // - // The length field of an MPI describes the length starting from its - // most significant non-zero bit. Thus, the MPI [00 02 01] is not - // formed correctly. It should be [00 01 01]. + // Additional rules: + // + // The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. + // + // The length field of an MPI describes the length starting from its + // most significant non-zero bit. Thus, the MPI [00 02 01] is not + // formed correctly. It should be [00 01 01]. - // TODO: Verification of this size method! This size calculation as - // specified above is not applicable in JavaScript - var bytelen = Math.ceil(bits / 8); + // TODO: Verification of this size method! This size calculation as + // specified above is not applicable in JavaScript + var bytelen = Math.ceil(bits / 8); - var raw = bytes.substr(2, bytelen); - this.fromBytes(raw); + var raw = bytes.substr(2, bytelen); + 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 - * @return {String} mpi Byte representation - */ - this.write = function () { - return this.data.toMPI(); - }; - - this.toBigInteger = function () { - return this.data.clone(); - }; - - this.fromBigInteger = function (bn) { - this.data = bn.clone(); - }; + return 2 + bytelen; +}; + +Mpi.prototype.fromBytes = function (bytes) { + this.data = new BigInteger(util.hexstrdump(bytes), 16); +}; + +Mpi.prototype.toBytes = function () { + return this.write().substr(2); +}; + +Mpi.prototype.byteLength = function () { + return this.toBytes().length; +}; + +/** + * Converts the mpi object to a string as specified in RFC4880 3.2 + * @return {String} mpi Byte representation + */ +Mpi.prototype.write = function () { + return this.data.toMPI(); +}; + +Mpi.prototype.toBigInteger = function () { + return this.data.clone(); +}; + +Mpi.prototype.fromBigInteger = function (bn) { + this.data = bn.clone(); }; diff --git a/src/type/s2k.js b/src/type/s2k.js index 48e680de..aa5f8379 100644 --- a/src/type/s2k.js +++ b/src/type/s2k.js @@ -29,6 +29,8 @@ * @module type/s2k */ +module.exports = S2k; + var enums = require('../enums.js'), util = require('../util'), crypto = require('../crypto'); @@ -36,7 +38,7 @@ var enums = require('../enums.js'), /** * @constructor */ -module.exports = function s2k() { +function S2k() { /** @type {module:enums.hash} */ this.algorithm = 'sha256'; /** @type {module:enums.s2k} */ @@ -46,134 +48,133 @@ module.exports = function s2k() { * @type {String} */ this.salt = crypto.random.getRandomBytes(8); +} - +S2k.prototype.get_count = function () { // Exponent bias, defined in RFC4880 var expbias = 6; - this.get_count = function () { - return (16 + (this.c & 15)) << ((this.c >> 4) + expbias); - }; - - /** - * Parsing function for a string-to-key specifier (RFC 4880 3.7). - * @param {String} input Payload of string-to-key specifier - * @return {Integer} Actual length of the object - */ - this.read = function (bytes) { - var i = 0; - this.type = enums.read(enums.s2k, bytes.charCodeAt(i++)); - this.algorithm = enums.read(enums.hash, bytes.charCodeAt(i++)); - - switch (this.type) { - case 'simple': - break; - - case 'salted': - this.salt = bytes.substr(i, 8); - i += 8; - break; - - case 'iterated': - this.salt = bytes.substr(i, 8); - i += 8; - - // Octet 10: count, a one-octet, coded value - this.c = bytes.charCodeAt(i++); - break; - - case 'gnu': - if (bytes.substr(i, 3) == "GNU") { - i += 3; // GNU - var gnuExtType = 1000 + bytes.charCodeAt(i++); - if (gnuExtType == 1001) { - this.type = gnuExtType; - // GnuPG extension mode 1001 -- don't write secret key at all - } else { - throw new Error("Unknown s2k gnu protection mode."); - } - } else { - throw new Error("Unknown s2k type."); - } - break; - - default: - throw new Error("Unknown s2k type."); - } - - return i; - }; - - - /** - * writes an s2k hash based on the inputs. - * @return {String} Produced key of hashAlgorithm hash length - */ - this.write = function () { - var bytes = String.fromCharCode(enums.write(enums.s2k, this.type)); - bytes += String.fromCharCode(enums.write(enums.hash, this.algorithm)); - - switch (this.type) { - case 'simple': - break; - case 'salted': - bytes += this.salt; - break; - case 'iterated': - bytes += this.salt; - bytes += String.fromCharCode(this.c); - break; - } - - return bytes; - }; - - /** - * Produces a key using the specified passphrase and the defined - * hashAlgorithm - * @param {String} passphrase Passphrase containing user input - * @return {String} Produced key with a length corresponding to - * hashAlgorithm hash length - */ - this.produce_key = function (passphrase, numBytes) { - passphrase = util.encode_utf8(passphrase); - - function round(prefix, s2k) { - var algorithm = enums.write(enums.hash, s2k.algorithm); - - switch (s2k.type) { - case 'simple': - return crypto.hash.digest(algorithm, prefix + passphrase); - - case 'salted': - return crypto.hash.digest(algorithm, - prefix + s2k.salt + passphrase); - - case 'iterated': - var isp = [], - count = s2k.get_count(); - data = s2k.salt + passphrase; - - while (isp.length * data.length < count) - isp.push(data); - - isp = isp.join(''); - - if (isp.length > count) - isp = isp.substr(0, count); - - return crypto.hash.digest(algorithm, prefix + isp); - } - } - - var result = '', - prefix = ''; - - while (result.length <= numBytes) { - result += round(prefix, this); - prefix += String.fromCharCode(0); - } - - return result.substr(0, numBytes); - }; + return (16 + (this.c & 15)) << ((this.c >> 4) + expbias); +}; + +/** + * Parsing function for a string-to-key specifier (RFC 4880 3.7). + * @param {String} input Payload of string-to-key specifier + * @return {Integer} Actual length of the object + */ +S2k.prototype.read = function (bytes) { + var i = 0; + this.type = enums.read(enums.s2k, bytes.charCodeAt(i++)); + this.algorithm = enums.read(enums.hash, bytes.charCodeAt(i++)); + + switch (this.type) { + case 'simple': + break; + + case 'salted': + this.salt = bytes.substr(i, 8); + i += 8; + break; + + case 'iterated': + this.salt = bytes.substr(i, 8); + i += 8; + + // Octet 10: count, a one-octet, coded value + this.c = bytes.charCodeAt(i++); + break; + + case 'gnu': + if (bytes.substr(i, 3) == "GNU") { + i += 3; // GNU + var gnuExtType = 1000 + bytes.charCodeAt(i++); + if (gnuExtType == 1001) { + this.type = gnuExtType; + // GnuPG extension mode 1001 -- don't write secret key at all + } else { + throw new Error("Unknown s2k gnu protection mode."); + } + } else { + throw new Error("Unknown s2k type."); + } + break; + + default: + throw new Error("Unknown s2k type."); + } + + return i; +}; + + +/** + * writes an s2k hash based on the inputs. + * @return {String} Produced key of hashAlgorithm hash length + */ +S2k.prototype.write = function () { + var bytes = String.fromCharCode(enums.write(enums.s2k, this.type)); + bytes += String.fromCharCode(enums.write(enums.hash, this.algorithm)); + + switch (this.type) { + case 'simple': + break; + case 'salted': + bytes += this.salt; + break; + case 'iterated': + bytes += this.salt; + bytes += String.fromCharCode(this.c); + break; + } + + return bytes; +}; + +/** + * Produces a key using the specified passphrase and the defined + * hashAlgorithm + * @param {String} passphrase Passphrase containing user input + * @return {String} Produced key with a length corresponding to + * hashAlgorithm hash length + */ +S2k.prototype.produce_key = function (passphrase, numBytes) { + passphrase = util.encode_utf8(passphrase); + + function round(prefix, s2k) { + var algorithm = enums.write(enums.hash, s2k.algorithm); + + switch (s2k.type) { + case 'simple': + return crypto.hash.digest(algorithm, prefix + passphrase); + + case 'salted': + return crypto.hash.digest(algorithm, + prefix + s2k.salt + passphrase); + + case 'iterated': + var isp = [], + count = s2k.get_count(); + data = s2k.salt + passphrase; + + while (isp.length * data.length < count) + isp.push(data); + + isp = isp.join(''); + + if (isp.length > count) + isp = isp.substr(0, count); + + return crypto.hash.digest(algorithm, prefix + isp); + } + } + + var result = '', + prefix = ''; + + while (result.length <= numBytes) { + result += round(prefix, this); + prefix += String.fromCharCode(0); + } + + return result.substr(0, numBytes); }; diff --git a/test/general/key.js b/test/general/key.js index 1cf127c1..ce7e8d36 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -265,7 +265,7 @@ describe('Key', function() { var pubKey = pubKeys.keys[0]; expect(pubKey).to.exist; - var packetlist = new openpgp.packet.list(); + var packetlist = new openpgp.packet.List(); packetlist.read(openpgp.armor.decode(pub_sig_test).data); diff --git a/test/general/keyring.js b/test/general/keyring.js index dd37d8d6..271c0df8 100644 --- a/test/general/keyring.js +++ b/test/general/keyring.js @@ -1,7 +1,7 @@ 'use strict'; var openpgp = require('openpgp'), - keyring = new (new require('keyring'))(), + keyring = new (require('keyring'))(), expect = chai.expect; describe("Keyring", function() { diff --git a/test/general/packet.js b/test/general/packet.js index 8b2dba28..ab84d779 100644 --- a/test/general/packet.js +++ b/test/general/packet.js @@ -43,12 +43,12 @@ describe("Packet", function() { '-----END PGP PRIVATE KEY BLOCK-----'; it('Symmetrically encrypted packet', function(done) { - var message = new openpgp.packet.list(); + var message = new openpgp.packet.List(); - var literal = new openpgp.packet.literal(); + var literal = new openpgp.packet.Literal(); literal.setText('Hello world'); - var enc = new openpgp.packet.symmetrically_encrypted(); + var enc = new openpgp.packet.SymmetricallyEncrypted(); message.push(enc); enc.packets.push(literal); @@ -57,7 +57,7 @@ describe("Packet", function() { enc.encrypt(algo, key); - var msg2 = new openpgp.packet.list(); + var msg2 = new openpgp.packet.List(); msg2.read(message.write()); msg2[0].decrypt(algo, key); @@ -70,16 +70,16 @@ describe("Packet", function() { var key = '12345678901234567890123456789012', algo = 'aes256'; - var literal = new openpgp.packet.literal(), - enc = new openpgp.packet.sym_encrypted_integrity_protected(), - msg = new openpgp.packet.list(); + var literal = new openpgp.packet.Literal(), + enc = new openpgp.packet.SymEncryptedIntegrityProtected(), + msg = new openpgp.packet.List(); msg.push(enc); literal.setText('Hello world!'); enc.packets.push(literal); enc.encrypt(algo, key); - var msg2 = new openpgp.packet.list(); + var msg2 = new openpgp.packet.List(); msg2.read(msg.write()); msg2[0].decrypt(algo, key); @@ -100,7 +100,7 @@ describe("Packet", function() { var msgbytes = openpgp.armor.decode(msg).data; - var parsed = new openpgp.packet.list(); + var parsed = new openpgp.packet.List(); parsed.read(msgbytes); parsed[0].decrypt('test'); @@ -127,9 +127,9 @@ describe("Packet", function() { return mpi; }); - var enc = new openpgp.packet.public_key_encrypted_session_key(), - msg = new openpgp.packet.list(), - msg2 = new openpgp.packet.list(); + var enc = new openpgp.packet.PublicKeyEncryptedSessionKey(), + msg = new openpgp.packet.List(), + msg2 = new openpgp.packet.List(); enc.sessionKey = '12345678901234567890123456789012'; enc.publicKeyAlgorithm = 'rsa_encrypt'; @@ -171,11 +171,11 @@ describe("Packet", function() { '=lKiS\n' + '-----END PGP PRIVATE KEY BLOCK-----'; - var key = new openpgp.packet.list(); + var key = new openpgp.packet.List(); key.read(openpgp.armor.decode(armored_key).data); key = key[0]; - var enc = new openpgp.packet.public_key_encrypted_session_key(), + var enc = new openpgp.packet.PublicKeyEncryptedSessionKey(), secret = '12345678901234567890123456789012'; enc.sessionKey = secret; @@ -240,11 +240,11 @@ describe("Packet", function() { '-----END PGP MESSAGE-----'; - var key = new openpgp.packet.list(); + var key = new openpgp.packet.List(); key.read(openpgp.armor.decode(armored_key).data); key = key[3]; - var msg = new openpgp.packet.list(); + var msg = new openpgp.packet.List(); msg.read(openpgp.armor.decode(armored_msg).data); msg[0].decrypt(key); @@ -260,10 +260,10 @@ describe("Packet", function() { var passphrase = 'hello', algo = 'aes256'; - var literal = new openpgp.packet.literal(), - key_enc = new openpgp.packet.sym_encrypted_session_key(), - enc = new openpgp.packet.sym_encrypted_integrity_protected(), - msg = new openpgp.packet.list(); + var literal = new openpgp.packet.Literal(), + key_enc = new openpgp.packet.SymEncryptedSessionKey(), + enc = new openpgp.packet.SymEncryptedIntegrityProtected(), + msg = new openpgp.packet.List(); msg.push(key_enc); msg.push(enc); @@ -278,7 +278,7 @@ describe("Packet", function() { enc.encrypt(algo, key); - var msg2 = new openpgp.packet.list(); + var msg2 = new openpgp.packet.List(); msg2.read(msg.write()); msg2[0].decrypt(passphrase); @@ -302,12 +302,12 @@ describe("Packet", function() { '=pR+C\n' + '-----END PGP MESSAGE-----'; - var key = new openpgp.packet.list(); + var key = new openpgp.packet.List(); key.read(openpgp.armor.decode(armored_key).data); key = key[3]; key.decrypt('test'); - var msg = new openpgp.packet.list(); + var msg = new openpgp.packet.List(); msg.read(openpgp.armor.decode(armored_msg).data); msg[0].decrypt(key); @@ -320,7 +320,7 @@ describe("Packet", function() { }); it('Secret key reading with signature verification.', function(done) { - var key = new openpgp.packet.list(); + var key = new openpgp.packet.List(); key.read(openpgp.armor.decode(armored_key).data); @@ -357,11 +357,11 @@ describe("Packet", function() { '=htrB\n' + '-----END PGP MESSAGE-----' - var key = new openpgp.packet.list(); + var key = new openpgp.packet.List(); key.read(openpgp.armor.decode(armored_key).data); key[3].decrypt('test') - var msg = new openpgp.packet.list(); + var msg = new openpgp.packet.List(); msg.read(openpgp.armor.decode(armored_msg).data); msg[0].decrypt(key[3]); @@ -376,8 +376,8 @@ describe("Packet", function() { }); it('Writing and encryption of a secret key packet.', function(done) { - var key = new openpgp.packet.list(); - key.push(new openpgp.packet.secret_key); + var key = new openpgp.packet.List(); + key.push(new openpgp.packet.SecretKey); var rsa = new openpgp.crypto.publicKey.rsa(), mpi = rsa.generate(512, "10001") @@ -397,7 +397,7 @@ describe("Packet", function() { var raw = key.write(); - var key2 = new openpgp.packet.list(); + var key2 = new openpgp.packet.List(); key2.read(raw); key2[0].decrypt('hello'); @@ -406,7 +406,7 @@ describe("Packet", function() { }); it('Writing and verification of a signature packet.', function(done) { - var key = new openpgp.packet.secret_key(); + var key = new openpgp.packet.SecretKey(); var rsa = new openpgp.crypto.publicKey.rsa, mpi = rsa.generate(512, "10001") @@ -421,9 +421,9 @@ describe("Packet", function() { key.mpi = mpi; - var signed = new openpgp.packet.list(), - literal = new openpgp.packet.literal(), - signature = new openpgp.packet.signature(); + var signed = new openpgp.packet.List(), + literal = new openpgp.packet.Literal(), + signature = new openpgp.packet.Signature(); literal.setText('Hello world'); @@ -438,7 +438,7 @@ describe("Packet", function() { var raw = signed.write(); - var signed2 = new openpgp.packet.list(); + var signed2 = new openpgp.packet.List(); signed2.read(raw); var verified = signed2[1].verify(key, signed2[0]); From 2c8a4daec5402308cae5792cf99c4bd21692e333 Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Sun, 5 Jan 2014 14:25:45 -0800 Subject: [PATCH 2/3] Show full class names in nav --- doc/JXG.Util.html | 4 ++-- doc/aes.html | 4 ++-- doc/aes.js.html | 4 ++-- doc/all_packets.js.html | 4 ++-- doc/armor.html | 4 ++-- doc/armor.js.html | 4 ++-- doc/base64.html | 4 ++-- doc/base64.js.html | 4 ++-- doc/blowfish.html | 4 ++-- doc/blowfish.js.html | 4 ++-- doc/cast5.html | 4 ++-- doc/cast5.js.html | 4 ++-- doc/cfb.html | 4 ++-- doc/cfb.js.html | 4 ++-- doc/cipher.html | 4 ++-- doc/cleartext.js.html | 4 ++-- doc/compressed-Compressed.html | 4 ++-- doc/compressed.html | 4 ++-- doc/compressed.js.html | 4 ++-- doc/config.html | 4 ++-- doc/config.js.html | 4 ++-- doc/crypto.html | 4 ++-- doc/crypto.js.html | 4 ++-- doc/des.html | 4 ++-- doc/des.js.html | 4 ++-- doc/dsa.html | 4 ++-- doc/dsa.js.html | 4 ++-- doc/elgamal.html | 4 ++-- doc/elgamal.js.html | 4 ++-- doc/enums.js.html | 4 ++-- doc/hash.html | 4 ++-- doc/index.html | 4 ++-- doc/index.js.html | 4 ++-- doc/index.js_.html | 4 ++-- doc/index.js__.html | 4 ++-- doc/index.js___.html | 4 ++-- doc/index.js____.html | 4 ++-- doc/jsbn.html | 4 ++-- doc/jsbn.js.html | 4 ++-- doc/jxg.js.html | 4 ++-- doc/key.js.html | 4 ++-- doc/keyid-Keyid.html | 4 ++-- doc/keyid.html | 4 ++-- doc/keyid.js.html | 4 ++-- doc/keyring-Keyring.html | 4 ++-- doc/keyring.html | 4 ++-- doc/keyring.js.html | 4 ++-- doc/literal-Literal.html | 4 ++-- doc/literal.html | 4 ++-- doc/literal.js.html | 4 ++-- doc/localStorage-LocalStorage.html | 4 ++-- doc/localStorage.html | 4 ++-- doc/localStorage.js.html | 4 ++-- doc/localstore.html | 4 ++-- doc/localstore.js.html | 4 ++-- doc/marker-Marker.html | 4 ++-- doc/marker.html | 4 ++-- doc/marker.js.html | 4 ++-- doc/md5.html | 4 ++-- doc/md5.js.html | 4 ++-- doc/message.js.html | 4 ++-- doc/module-armor.html | 4 ++-- doc/module-cleartext-CleartextMessage.html | 4 ++-- doc/module-cleartext.html | 4 ++-- doc/module-config.html | 4 ++-- doc/module-crypto.html | 4 ++-- doc/module-enums.html | 4 ++-- doc/module-key-Key.html | 4 ++-- doc/module-key-SubKey.html | 4 ++-- doc/module-key-User.html | 4 ++-- doc/module-key.html | 4 ++-- doc/module-keyid.html | 4 ++-- doc/module-message-Message.html | 4 ++-- doc/module-message.html | 4 ++-- doc/module-mpi.html | 4 ++-- doc/module-openpgp.html | 4 ++-- doc/module-packet.html | 4 ++-- doc/module-s2k.html | 4 ++-- doc/module-util.html | 4 ++-- doc/mpi-Mpi.html | 4 ++-- doc/mpi.html | 4 ++-- doc/mpi.js.html | 4 ++-- doc/one_pass_signature-OnePassSignature.html | 4 ++-- doc/one_pass_signature.html | 4 ++-- doc/one_pass_signature.js.html | 4 ++-- doc/openpgp.js.html | 4 ++-- doc/packet.html | 4 ++-- doc/packet.js.html | 4 ++-- doc/packetlist-Packetlist.html | 4 ++-- doc/packetlist.html | 4 ++-- doc/packetlist.js.html | 4 ++-- doc/pkcs1.html | 4 ++-- doc/pkcs1.js.html | 4 ++-- doc/public_key-PublicKey.html | 4 ++-- doc/public_key.html | 4 ++-- doc/public_key.js.html | 4 ++-- doc/public_key_.html | 4 ++-- ...ey_encrypted_session_key-PublicKeyEncryptedSessionKey.html | 4 ++-- doc/public_key_encrypted_session_key.html | 4 ++-- doc/public_key_encrypted_session_key.js.html | 4 ++-- doc/public_subkey-PublicSubkey.html | 4 ++-- doc/public_subkey.html | 4 ++-- doc/public_subkey.js.html | 4 ++-- doc/random.html | 4 ++-- doc/random.js.html | 4 ++-- doc/ripe-md.html | 4 ++-- doc/ripe-md.js.html | 4 ++-- doc/rsa.html | 4 ++-- doc/rsa.js.html | 4 ++-- doc/s2k-S2k.html | 4 ++-- doc/s2k.html | 4 ++-- doc/s2k.js.html | 4 ++-- doc/secret_key.html | 4 ++-- doc/secret_key.js.html | 4 ++-- doc/secret_subkey-SecretSubkey.html | 4 ++-- doc/secret_subkey.html | 4 ++-- doc/secret_subkey.js.html | 4 ++-- doc/sha.html | 4 ++-- doc/sha.js.html | 4 ++-- doc/signature-Signature.html | 4 ++-- doc/signature.html | 4 ++-- doc/signature.js.html | 4 ++-- doc/signature.js_.html | 4 ++-- doc/signature_.html | 4 ++-- ...ed_integrity_protected-SymEncryptedIntegrityProtected.html | 4 ++-- doc/sym_encrypted_integrity_protected.html | 4 ++-- doc/sym_encrypted_integrity_protected.js.html | 4 ++-- doc/sym_encrypted_session_key-SymEncryptedSessionKey.html | 4 ++-- doc/sym_encrypted_session_key.html | 4 ++-- doc/sym_encrypted_session_key.js.html | 4 ++-- doc/symmetrically_encrypted-SymmetricallyEncrypted.html | 4 ++-- doc/symmetrically_encrypted.html | 4 ++-- doc/symmetrically_encrypted.js.html | 4 ++-- doc/trust-Trust.html | 4 ++-- doc/trust.html | 4 ++-- doc/trust.js.html | 4 ++-- doc/twofish.html | 4 ++-- doc/twofish.js.html | 4 ++-- doc/user_attribute-UserAttribute.html | 4 ++-- doc/user_attribute.html | 4 ++-- doc/user_attribute.js.html | 4 ++-- doc/userid-Userid.html | 4 ++-- doc/userid.html | 4 ++-- doc/userid.js.html | 4 ++-- doc/util.html | 4 ++-- doc/util.js.html | 4 ++-- jsdoc.template/publish.js | 2 +- 147 files changed, 293 insertions(+), 293 deletions(-) diff --git a/doc/JXG.Util.html b/doc/JXG.Util.html index 906c6076..6a1eb63c 100644 --- a/doc/JXG.Util.html +++ b/doc/JXG.Util.html @@ -554,13 +554,13 @@ EXAMPLES:
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/aes.html b/doc/aes.html index f0e7bad3..59ee6484 100644 --- a/doc/aes.html +++ b/doc/aes.html @@ -111,13 +111,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/aes.js.html b/doc/aes.js.html index c8216446..394dfb9b 100644 --- a/doc/aes.js.html +++ b/doc/aes.js.html @@ -546,13 +546,13 @@ for (var i in types) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/all_packets.js.html b/doc/all_packets.js.html index d054963e..36ccfd48 100644 --- a/doc/all_packets.js.html +++ b/doc/all_packets.js.html @@ -91,13 +91,13 @@ for (var i in enums.packet) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/armor.html b/doc/armor.html index 5b5878f2..e8b4107c 100644 --- a/doc/armor.html +++ b/doc/armor.html @@ -1358,13 +1358,13 @@ given base64 encoded checksum
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/armor.js.html b/doc/armor.js.html index e4437f19..5f8f97b0 100644 --- a/doc/armor.js.html +++ b/doc/armor.js.html @@ -413,13 +413,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/base64.html b/doc/base64.html index 5f76ecb4..73d80009 100644 --- a/doc/base64.html +++ b/doc/base64.html @@ -387,13 +387,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/base64.js.html b/doc/base64.js.html index 0d7369c8..92f2fd83 100644 --- a/doc/base64.js.html +++ b/doc/base64.js.html @@ -136,13 +136,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/blowfish.html b/doc/blowfish.html index 49fab594..54ead50b 100644 --- a/doc/blowfish.html +++ b/doc/blowfish.html @@ -105,13 +105,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/blowfish.js.html b/doc/blowfish.js.html index f5483eda..72c370ac 100644 --- a/doc/blowfish.js.html +++ b/doc/blowfish.js.html @@ -451,13 +451,13 @@ module.exports.blockSize = BF.prototype.blockSize = 16;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/cast5.html b/doc/cast5.html index 3c1cdff0..2dd7d523 100644 --- a/doc/cast5.html +++ b/doc/cast5.html @@ -105,13 +105,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/cast5.js.html b/doc/cast5.js.html index 63f41963..9d9bc7f8 100644 --- a/doc/cast5.js.html +++ b/doc/cast5.js.html @@ -642,13 +642,13 @@ module.exports.keySize = cast5.prototype.keySize = 16;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/cfb.html b/doc/cfb.html index bfb6c6de..a6a7ebc1 100644 --- a/doc/cfb.html +++ b/doc/cfb.html @@ -762,13 +762,13 @@ This will be passed to the cipherfn
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/cfb.js.html b/doc/cfb.js.html index b015f56a..0ce6b808 100644 --- a/doc/cfb.js.html +++ b/doc/cfb.js.html @@ -335,13 +335,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/cipher.html b/doc/cipher.html index 7a127c6f..9a15e5e3 100644 --- a/doc/cipher.html +++ b/doc/cipher.html @@ -406,13 +406,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/cleartext.js.html b/doc/cleartext.js.html index c1d7289b..60a981b7 100644 --- a/doc/cleartext.js.html +++ b/doc/cleartext.js.html @@ -185,13 +185,13 @@ exports.readArmored = readArmored;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/compressed-Compressed.html b/doc/compressed-Compressed.html index 3034d7d3..2f053989 100644 --- a/doc/compressed-Compressed.html +++ b/doc/compressed-Compressed.html @@ -680,13 +680,13 @@ read by read_packet
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/compressed.html b/doc/compressed.html index c3001e3f..d38dd089 100644 --- a/doc/compressed.html +++ b/doc/compressed.html @@ -128,13 +128,13 @@ a Signature or One-Pass Signature packet, and contains a literal data packet.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/compressed.js.html b/doc/compressed.js.html index 3937d5b7..8478a89a 100644 --- a/doc/compressed.js.html +++ b/doc/compressed.js.html @@ -204,13 +204,13 @@ Compressed.prototype.compress = function () {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/config.html b/doc/config.html index fc43ecf1..20fded96 100644 --- a/doc/config.html +++ b/doc/config.html @@ -325,13 +325,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/config.js.html b/doc/config.js.html index f23d5772..bf0b0928 100644 --- a/doc/config.js.html +++ b/doc/config.js.html @@ -82,13 +82,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/crypto.html b/doc/crypto.html index 0dd34c94..148c59ab 100644 --- a/doc/crypto.html +++ b/doc/crypto.html @@ -937,13 +937,13 @@ if elgamal encryption an array of two module:type/mpi is returned; otherwise nul
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/crypto.js.html b/doc/crypto.js.html index 8f39f1f5..5a1c815d 100644 --- a/doc/crypto.js.html +++ b/doc/crypto.js.html @@ -261,13 +261,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/des.html b/doc/des.html index a8dc29a7..0dfac5e4 100644 --- a/doc/des.html +++ b/doc/des.html @@ -209,13 +209,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/des.js.html b/doc/des.js.html index 92b0d2a0..d3837411 100644 --- a/doc/des.js.html +++ b/doc/des.js.html @@ -444,13 +444,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/dsa.html b/doc/dsa.html index 864d5d86..2b2e077b 100644 --- a/doc/dsa.html +++ b/doc/dsa.html @@ -117,13 +117,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/dsa.js.html b/doc/dsa.js.html index f86d494e..9e33e53a 100644 --- a/doc/dsa.js.html +++ b/doc/dsa.js.html @@ -206,13 +206,13 @@ module.exports = DSA;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/elgamal.html b/doc/elgamal.html index 205c25a3..f3f1e27d 100644 --- a/doc/elgamal.html +++ b/doc/elgamal.html @@ -115,13 +115,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/elgamal.js.html b/doc/elgamal.js.html index 17564971..34173463 100644 --- a/doc/elgamal.js.html +++ b/doc/elgamal.js.html @@ -95,13 +95,13 @@ module.exports = Elgamal;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/enums.js.html b/doc/enums.js.html index 85bcaea4..e459df97 100644 --- a/doc/enums.js.html +++ b/doc/enums.js.html @@ -352,13 +352,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/hash.html b/doc/hash.html index 43db4644..7c3d6bec 100644 --- a/doc/hash.html +++ b/doc/hash.html @@ -819,13 +819,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/index.html b/doc/index.html index d4bad455..e89d0881 100644 --- a/doc/index.html +++ b/doc/index.html @@ -180,13 +180,13 @@ for extending and developing on top of the base library.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/index.js.html b/doc/index.js.html index 707293a9..68870032 100644 --- a/doc/index.js.html +++ b/doc/index.js.html @@ -74,13 +74,13 @@ module.exports.crypto = require('./crypto');
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/index.js_.html b/doc/index.js_.html index 46f490ff..842bd1b0 100644 --- a/doc/index.js_.html +++ b/doc/index.js_.html @@ -60,13 +60,13 @@ for (var i in crypto)
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/index.js__.html b/doc/index.js__.html index 0eca47b5..6fd9ad4c 100644 --- a/doc/index.js__.html +++ b/doc/index.js__.html @@ -63,13 +63,13 @@ for (var i in aes) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/index.js___.html b/doc/index.js___.html index 628ec272..515a5ae0 100644 --- a/doc/index.js___.html +++ b/doc/index.js___.html @@ -123,13 +123,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/index.js____.html b/doc/index.js____.html index 8127b5a5..d3df77ee 100644 --- a/doc/index.js____.html +++ b/doc/index.js____.html @@ -49,13 +49,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/jsbn.html b/doc/jsbn.html index ddd108a3..3035335a 100644 --- a/doc/jsbn.html +++ b/doc/jsbn.html @@ -111,13 +111,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/jsbn.js.html b/doc/jsbn.js.html index ac948d90..21c4d235 100644 --- a/doc/jsbn.js.html +++ b/doc/jsbn.js.html @@ -1745,13 +1745,13 @@ BigInteger.prototype.square = bnSquare;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/jxg.js.html b/doc/jxg.js.html index 506b0840..41d49338 100644 --- a/doc/jxg.js.html +++ b/doc/jxg.js.html @@ -1297,13 +1297,13 @@ module.exports = JXG;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/key.js.html b/doc/key.js.html index 7c458875..485bd68e 100644 --- a/doc/key.js.html +++ b/doc/key.js.html @@ -803,13 +803,13 @@ exports.generate = generate;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/keyid-Keyid.html b/doc/keyid-Keyid.html index 807fb94c..1d173b1f 100644 --- a/doc/keyid-Keyid.html +++ b/doc/keyid-Keyid.html @@ -254,13 +254,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/keyid.html b/doc/keyid.html index 7f979f8a..370f27f0 100644 --- a/doc/keyid.html +++ b/doc/keyid.html @@ -125,13 +125,13 @@ formed.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/keyid.js.html b/doc/keyid.js.html index 713e2d17..c88d8ffd 100644 --- a/doc/keyid.js.html +++ b/doc/keyid.js.html @@ -102,13 +102,13 @@ module.exports.mapToHex = function (keyId) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/keyring-Keyring.html b/doc/keyring-Keyring.html index 2e54ebf2..b6c7f599 100644 --- a/doc/keyring-Keyring.html +++ b/doc/keyring-Keyring.html @@ -1291,13 +1291,13 @@ keyring from HTML5 local storage and initializes this instance.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST)
diff --git a/doc/keyring.html b/doc/keyring.html index 064036f6..be72c4d5 100644 --- a/doc/keyring.html +++ b/doc/keyring.html @@ -822,13 +822,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST)
diff --git a/doc/keyring.js.html b/doc/keyring.js.html index 0658d26c..bef1ee84 100644 --- a/doc/keyring.js.html +++ b/doc/keyring.js.html @@ -224,13 +224,13 @@ Keyring.prototype.exportPublicKey = function (index) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/literal-Literal.html b/doc/literal-Literal.html index 6ad79fbf..795a3e8d 100644 --- a/doc/literal-Literal.html +++ b/doc/literal-Literal.html @@ -909,13 +909,13 @@ will be normalized to \r\n and by default text is converted to UTF8
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/literal.html b/doc/literal.html index a934494e..8cd96199 100644 --- a/doc/literal.html +++ b/doc/literal.html @@ -125,13 +125,13 @@ is not to be further interpreted.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/literal.js.html b/doc/literal.js.html index 27807408..87b2248c 100644 --- a/doc/literal.js.html +++ b/doc/literal.js.html @@ -165,13 +165,13 @@ Literal.prototype.write = function () {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/localStorage-LocalStorage.html b/doc/localStorage-LocalStorage.html index 65ad7272..8b22c8e0 100644 --- a/doc/localStorage-LocalStorage.html +++ b/doc/localStorage-LocalStorage.html @@ -277,13 +277,13 @@ if config is null the default config will be used
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/localStorage.html b/doc/localStorage.html index f7ff9c56..06aca0e8 100644 --- a/doc/localStorage.html +++ b/doc/localStorage.html @@ -114,13 +114,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/localStorage.js.html b/doc/localStorage.js.html index 9d6be675..0cf92892 100644 --- a/doc/localStorage.js.html +++ b/doc/localStorage.js.html @@ -68,13 +68,13 @@ LocalStorage.prototype.write = function () {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/localstore.html b/doc/localstore.html index 2d55529e..2c7a3d64 100644 --- a/doc/localstore.html +++ b/doc/localstore.html @@ -113,13 +113,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST)
diff --git a/doc/localstore.js.html b/doc/localstore.js.html index 18c9e837..895a4526 100644 --- a/doc/localstore.js.html +++ b/doc/localstore.js.html @@ -93,13 +93,13 @@ LocalStore.prototype.store = function (keys) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/marker-Marker.html b/doc/marker-Marker.html index 77a3138b..b5116492 100644 --- a/doc/marker-Marker.html +++ b/doc/marker-Marker.html @@ -323,13 +323,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/marker.html b/doc/marker.html index 2208f53b..5b46bc54 100644 --- a/doc/marker.html +++ b/doc/marker.html @@ -121,13 +121,13 @@ Such a packet MUST be ignored when received.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/marker.js.html b/doc/marker.js.html index 89d67669..037112e0 100644 --- a/doc/marker.js.html +++ b/doc/marker.js.html @@ -92,13 +92,13 @@ Marker.prototype.read = function (bytes) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/md5.html b/doc/md5.html index 80aa0b38..3ddb9f7c 100644 --- a/doc/md5.html +++ b/doc/md5.html @@ -229,13 +229,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/md5.js.html b/doc/md5.js.html index 2fef87d0..4193382f 100644 --- a/doc/md5.js.html +++ b/doc/md5.js.html @@ -252,13 +252,13 @@ if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/message.js.html b/doc/message.js.html index d79160d7..7f7b985d 100644 --- a/doc/message.js.html +++ b/doc/message.js.html @@ -351,13 +351,13 @@ exports.fromBinary = fromBinary;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/module-armor.html b/doc/module-armor.html index 8dedb041..524c15c8 100644 --- a/doc/module-armor.html +++ b/doc/module-armor.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/module-cleartext-CleartextMessage.html b/doc/module-cleartext-CleartextMessage.html index 04795f31..d04c39de 100644 --- a/doc/module-cleartext-CleartextMessage.html +++ b/doc/module-cleartext-CleartextMessage.html @@ -741,13 +741,13 @@ See http://tools.ietf.org/html/rfc4880#section-7
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/module-cleartext.html b/doc/module-cleartext.html index 8186a3fd..29e3df0a 100644 --- a/doc/module-cleartext.html +++ b/doc/module-cleartext.html @@ -267,13 +267,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/module-config.html b/doc/module-config.html index 0fd7f548..edcec2ab 100644 --- a/doc/module-config.html +++ b/doc/module-config.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/module-crypto.html b/doc/module-crypto.html index fae66fe9..a747a9c1 100644 --- a/doc/module-crypto.html +++ b/doc/module-crypto.html @@ -515,13 +515,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/module-enums.html b/doc/module-enums.html index a141cdce..d62d740c 100644 --- a/doc/module-enums.html +++ b/doc/module-enums.html @@ -4527,13 +4527,13 @@ document) that cannot include a target subpacket.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/module-key-Key.html b/doc/module-key-Key.html index 4c49f135..2ec2cec1 100644 --- a/doc/module-key-Key.html +++ b/doc/module-key-Key.html @@ -2252,13 +2252,13 @@ and valid self signature
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST)
diff --git a/doc/module-key-SubKey.html b/doc/module-key-SubKey.html index 891957a6..95e18f4e 100644 --- a/doc/module-key-SubKey.html +++ b/doc/module-key-SubKey.html @@ -594,13 +594,13 @@ and valid binding signature
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST)
diff --git a/doc/module-key-User.html b/doc/module-key-User.html index 9727a170..9627c9e3 100644 --- a/doc/module-key-User.html +++ b/doc/module-key-User.html @@ -676,13 +676,13 @@ and validity of self signature
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/module-key.html b/doc/module-key.html index c0b816ba..8a58ad87 100644 --- a/doc/module-key.html +++ b/doc/module-key.html @@ -479,13 +479,13 @@ Primary and subkey will be of same type.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST)
diff --git a/doc/module-keyid.html b/doc/module-keyid.html index 01d1baba..21771ad6 100644 --- a/doc/module-keyid.html +++ b/doc/module-keyid.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST)
diff --git a/doc/module-message-Message.html b/doc/module-message-Message.html index 99367b60..cc223196 100644 --- a/doc/module-message-Message.html +++ b/doc/module-message-Message.html @@ -1297,13 +1297,13 @@ See http://tools.ietf.org/html/rfc4880#section-11.3
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/module-message.html b/doc/module-message.html index a8a360cd..181df3c7 100644 --- a/doc/module-message.html +++ b/doc/module-message.html @@ -547,13 +547,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/module-mpi.html b/doc/module-mpi.html index f055805d..ce51cb60 100644 --- a/doc/module-mpi.html +++ b/doc/module-mpi.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/module-openpgp.html b/doc/module-openpgp.html index f0ba52c7..6bcaf0e4 100644 --- a/doc/module-openpgp.html +++ b/doc/module-openpgp.html @@ -1358,13 +1358,13 @@ Primary and subkey will be of same type.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/module-packet.html b/doc/module-packet.html index a4097997..de5d1e00 100644 --- a/doc/module-packet.html +++ b/doc/module-packet.html @@ -1027,13 +1027,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/module-s2k.html b/doc/module-s2k.html index e5c44c09..b48009e3 100644 --- a/doc/module-s2k.html +++ b/doc/module-s2k.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/module-util.html b/doc/module-util.html index e017d883..81a7c223 100644 --- a/doc/module-util.html +++ b/doc/module-util.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/mpi-Mpi.html b/doc/mpi-Mpi.html index 4f0c4be1..4dfcd177 100644 --- a/doc/mpi-Mpi.html +++ b/doc/mpi-Mpi.html @@ -425,13 +425,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/mpi.html b/doc/mpi.html index 055b1ba5..a4091a7b 100644 --- a/doc/mpi.html +++ b/doc/mpi.html @@ -129,13 +129,13 @@ actual integer.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/mpi.js.html b/doc/mpi.js.html index 7fee6825..bd80004b 100644 --- a/doc/mpi.js.html +++ b/doc/mpi.js.html @@ -137,13 +137,13 @@ Mpi.prototype.fromBigInteger = function (bn) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/one_pass_signature-OnePassSignature.html b/doc/one_pass_signature-OnePassSignature.html index b9f6b4ab..19d72aa6 100644 --- a/doc/one_pass_signature-OnePassSignature.html +++ b/doc/one_pass_signature-OnePassSignature.html @@ -367,13 +367,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/one_pass_signature.html b/doc/one_pass_signature.html index 894eb651..791b023f 100644 --- a/doc/one_pass_signature.html +++ b/doc/one_pass_signature.html @@ -129,13 +129,13 @@ can compute the entire signed message in one pass.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/one_pass_signature.js.html b/doc/one_pass_signature.js.html index cd60f882..c3bbfa22 100644 --- a/doc/one_pass_signature.js.html +++ b/doc/one_pass_signature.js.html @@ -132,13 +132,13 @@ OnePassSignature.prototype.write = function () {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/openpgp.js.html b/doc/openpgp.js.html index f2449430..56afc290 100644 --- a/doc/openpgp.js.html +++ b/doc/openpgp.js.html @@ -199,13 +199,13 @@ exports.generateKeyPair = generateKeyPair;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/packet.html b/doc/packet.html index 646a90c2..bbec64d3 100644 --- a/doc/packet.html +++ b/doc/packet.html @@ -768,13 +768,13 @@ string
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST)
diff --git a/doc/packet.js.html b/doc/packet.js.html index 6cef4c28..1fc690bd 100644 --- a/doc/packet.js.html +++ b/doc/packet.js.html @@ -298,13 +298,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/packetlist-Packetlist.html b/doc/packetlist-Packetlist.html index 66ba0666..c11398ec 100644 --- a/doc/packetlist-Packetlist.html +++ b/doc/packetlist-Packetlist.html @@ -1036,13 +1036,13 @@ class instance.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/packetlist.html b/doc/packetlist.html index bda441ba..52785214 100644 --- a/doc/packetlist.html +++ b/doc/packetlist.html @@ -126,13 +126,13 @@ are stored as numerical indices.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/packetlist.js.html b/doc/packetlist.js.html index b2a0c965..ce46da62 100644 --- a/doc/packetlist.js.html +++ b/doc/packetlist.js.html @@ -212,13 +212,13 @@ Packetlist.prototype.concat = function (packetlist) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/pkcs1.html b/doc/pkcs1.html index 289807a4..3f64e995 100644 --- a/doc/pkcs1.html +++ b/doc/pkcs1.html @@ -179,13 +179,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/pkcs1.js.html b/doc/pkcs1.js.html index 5b35af67..b9ef35af 100644 --- a/doc/pkcs1.js.html +++ b/doc/pkcs1.js.html @@ -180,13 +180,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/public_key-PublicKey.html b/doc/public_key-PublicKey.html index 45b26c2d..fad04a50 100644 --- a/doc/public_key-PublicKey.html +++ b/doc/public_key-PublicKey.html @@ -818,13 +818,13 @@ header: [string] OpenPGP packet header, string: [string] header+body}
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/public_key.html b/doc/public_key.html index 0082fb3d..161c219d 100644 --- a/doc/public_key.html +++ b/doc/public_key.html @@ -290,13 +290,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/public_key.js.html b/doc/public_key.js.html index e318a777..89dbdf6d 100644 --- a/doc/public_key.js.html +++ b/doc/public_key.js.html @@ -223,13 +223,13 @@ PublicKey.prototype.getFingerprint = function () {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/public_key_.html b/doc/public_key_.html index c5b7eaa1..aa0c1d9b 100644 --- a/doc/public_key_.html +++ b/doc/public_key_.html @@ -289,13 +289,13 @@ major versions. Consequently, this section is complex.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html b/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html index b8143456..c15e508c 100644 --- a/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html +++ b/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html @@ -761,13 +761,13 @@ packets (tag 1)
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/public_key_encrypted_session_key.html b/doc/public_key_encrypted_session_key.html index 4acc8d27..448a71be 100644 --- a/doc/public_key_encrypted_session_key.html +++ b/doc/public_key_encrypted_session_key.html @@ -140,13 +140,13 @@ decrypt the message.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/public_key_encrypted_session_key.js.html b/doc/public_key_encrypted_session_key.js.html index 68da00c6..84a3754d 100644 --- a/doc/public_key_encrypted_session_key.js.html +++ b/doc/public_key_encrypted_session_key.js.html @@ -219,13 +219,13 @@ PublicKeyEncryptedSessionKey.prototype.decrypt = function (key) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/public_subkey-PublicSubkey.html b/doc/public_subkey-PublicSubkey.html index 56c22403..5b29e1f7 100644 --- a/doc/public_subkey-PublicSubkey.html +++ b/doc/public_subkey-PublicSubkey.html @@ -305,13 +305,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/public_subkey.html b/doc/public_subkey.html index 4c9795d7..843a15a5 100644 --- a/doc/public_subkey.html +++ b/doc/public_subkey.html @@ -118,13 +118,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/public_subkey.js.html b/doc/public_subkey.js.html index 5722a340..9f863d5f 100644 --- a/doc/public_subkey.js.html +++ b/doc/public_subkey.js.html @@ -71,13 +71,13 @@ PublicSubkey.prototype.constructor = PublicSubkey();
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/random.html b/doc/random.html index 167737a2..bef958de 100644 --- a/doc/random.html +++ b/doc/random.html @@ -717,13 +717,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/random.js.html b/doc/random.js.html index a352888a..2d181a29 100644 --- a/doc/random.js.html +++ b/doc/random.js.html @@ -144,13 +144,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/ripe-md.html b/doc/ripe-md.html index fa61d092..dd2d3b20 100644 --- a/doc/ripe-md.html +++ b/doc/ripe-md.html @@ -105,13 +105,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/ripe-md.js.html b/doc/ripe-md.js.html index f4e8d93f..3a2faf5c 100644 --- a/doc/ripe-md.js.html +++ b/doc/ripe-md.js.html @@ -332,13 +332,13 @@ module.exports = RMDstring;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/rsa.html b/doc/rsa.html index 8aa90457..ecb87a23 100644 --- a/doc/rsa.html +++ b/doc/rsa.html @@ -115,13 +115,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/rsa.js.html b/doc/rsa.js.html index d0858ff0..29a993aa 100644 --- a/doc/rsa.js.html +++ b/doc/rsa.js.html @@ -187,13 +187,13 @@ module.exports = RSA;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/s2k-S2k.html b/doc/s2k-S2k.html index b8c79db5..065d213d 100644 --- a/doc/s2k-S2k.html +++ b/doc/s2k-S2k.html @@ -696,13 +696,13 @@ hashAlgorithm hash length
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/s2k.html b/doc/s2k.html index c67351b0..d6a47590 100644 --- a/doc/s2k.html +++ b/doc/s2k.html @@ -130,13 +130,13 @@ symmetrically encrypted messages.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/s2k.js.html b/doc/s2k.js.html index abc9bb21..67de5de1 100644 --- a/doc/s2k.js.html +++ b/doc/s2k.js.html @@ -215,13 +215,13 @@ S2k.prototype.produce_key = function (passphrase, numBytes) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/secret_key.html b/doc/secret_key.html index 92f28910..08126c73 100644 --- a/doc/secret_key.html +++ b/doc/secret_key.html @@ -360,13 +360,13 @@ major versions. Consequently, this section is complex.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/secret_key.js.html b/doc/secret_key.js.html index 0e0e924d..2adff1a8 100644 --- a/doc/secret_key.js.html +++ b/doc/secret_key.js.html @@ -302,13 +302,13 @@ SecretKey.prototype.generate = function (bits) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/secret_subkey-SecretSubkey.html b/doc/secret_subkey-SecretSubkey.html index 37342f36..361f45ed 100644 --- a/doc/secret_subkey-SecretSubkey.html +++ b/doc/secret_subkey-SecretSubkey.html @@ -305,13 +305,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/secret_subkey.html b/doc/secret_subkey.html index c6a4c538..39badac9 100644 --- a/doc/secret_subkey.html +++ b/doc/secret_subkey.html @@ -118,13 +118,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/secret_subkey.js.html b/doc/secret_subkey.js.html index 2f9f0146..870092aa 100644 --- a/doc/secret_subkey.js.html +++ b/doc/secret_subkey.js.html @@ -71,13 +71,13 @@ SecretSubkey.prototype.constructor = SecretSubkey;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/sha.html b/doc/sha.html index d78343ec..5201169c 100644 --- a/doc/sha.html +++ b/doc/sha.html @@ -454,13 +454,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/sha.js.html b/doc/sha.js.html index da56128f..93756caf 100644 --- a/doc/sha.js.html +++ b/doc/sha.js.html @@ -1160,13 +1160,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/signature-Signature.html b/doc/signature-Signature.html index cb609bcb..4c69ffc5 100644 --- a/doc/signature-Signature.html +++ b/doc/signature-Signature.html @@ -812,13 +812,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/signature.html b/doc/signature.html index 65599a0b..cc880dfa 100644 --- a/doc/signature.html +++ b/doc/signature.html @@ -575,13 +575,13 @@ integers which is used to sign the data
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST)
diff --git a/doc/signature.js.html b/doc/signature.js.html index fe3c4a51..2af0695c 100644 --- a/doc/signature.js.html +++ b/doc/signature.js.html @@ -148,13 +148,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/signature.js_.html b/doc/signature.js_.html index 1a575373..4e5a7aa0 100644 --- a/doc/signature.js_.html +++ b/doc/signature.js_.html @@ -675,13 +675,13 @@ Signature.prototype.isExpired = function () {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/signature_.html b/doc/signature_.html index 56d41e0a..917e8717 100644 --- a/doc/signature_.html +++ b/doc/signature_.html @@ -302,13 +302,13 @@ in RFC4880 Section 5.2.3.2
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html b/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html index 4efa61e6..6686e458 100644 --- a/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html +++ b/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html @@ -424,13 +424,13 @@ have been called before
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_integrity_protected.html b/doc/sym_encrypted_integrity_protected.html index 8a3225d5..613fb3bc 100644 --- a/doc/sym_encrypted_integrity_protected.html +++ b/doc/sym_encrypted_integrity_protected.html @@ -129,13 +129,13 @@ packet.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_integrity_protected.js.html b/doc/sym_encrypted_integrity_protected.js.html index 4852f9e3..a373805f 100644 --- a/doc/sym_encrypted_integrity_protected.js.html +++ b/doc/sym_encrypted_integrity_protected.js.html @@ -157,13 +157,13 @@ SymEncryptedIntegrityProtected.prototype.decrypt = function (sessionKeyAlgorithm
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html b/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html index 509873b3..38254e0a 100644 --- a/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html +++ b/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html @@ -415,13 +415,13 @@ packets (tag 1)
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_session_key.html b/doc/sym_encrypted_session_key.html index 1dda29fd..4b0c86f6 100644 --- a/doc/sym_encrypted_session_key.html +++ b/doc/sym_encrypted_session_key.html @@ -136,13 +136,13 @@ decrypt the message.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/sym_encrypted_session_key.js.html b/doc/sym_encrypted_session_key.js.html index 54ab9e19..5472e3f0 100644 --- a/doc/sym_encrypted_session_key.js.html +++ b/doc/sym_encrypted_session_key.js.html @@ -177,13 +177,13 @@ SymEncryptedSessionKey.prototype.encrypt = function(passphrase) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/symmetrically_encrypted-SymmetricallyEncrypted.html b/doc/symmetrically_encrypted-SymmetricallyEncrypted.html index a25a0d7c..3a76d4ca 100644 --- a/doc/symmetrically_encrypted-SymmetricallyEncrypted.html +++ b/doc/symmetrically_encrypted-SymmetricallyEncrypted.html @@ -346,13 +346,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/symmetrically_encrypted.html b/doc/symmetrically_encrypted.html index de061a78..bd15c959 100644 --- a/doc/symmetrically_encrypted.html +++ b/doc/symmetrically_encrypted.html @@ -126,13 +126,13 @@ that form whole OpenPGP messages).
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST)
diff --git a/doc/symmetrically_encrypted.js.html b/doc/symmetrically_encrypted.js.html index b8b218b4..3299e661 100644 --- a/doc/symmetrically_encrypted.js.html +++ b/doc/symmetrically_encrypted.js.html @@ -108,13 +108,13 @@ SymmetricallyEncrypted.prototype.encrypt = function (algo, key) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/trust-Trust.html b/doc/trust-Trust.html index 6396a902..356ff365 100644 --- a/doc/trust-Trust.html +++ b/doc/trust-Trust.html @@ -133,13 +133,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/trust.html b/doc/trust.html index 94d672ac..91b95d0a 100644 --- a/doc/trust.html +++ b/doc/trust.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/trust.js.html b/doc/trust.js.html index 29582b84..58fe327b 100644 --- a/doc/trust.js.html +++ b/doc/trust.js.html @@ -46,13 +46,13 @@ function Trust() {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/twofish.html b/doc/twofish.html index 1b496f80..2251f994 100644 --- a/doc/twofish.html +++ b/doc/twofish.html @@ -105,13 +105,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:08 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST)
diff --git a/doc/twofish.js.html b/doc/twofish.js.html index c056e897..0990593f 100644 --- a/doc/twofish.js.html +++ b/doc/twofish.js.html @@ -417,13 +417,13 @@ module.exports.blockSize = TF.prototype.blockSize = 16;
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/user_attribute-UserAttribute.html b/doc/user_attribute-UserAttribute.html index b00ee713..9359634d 100644 --- a/doc/user_attribute-UserAttribute.html +++ b/doc/user_attribute-UserAttribute.html @@ -254,13 +254,13 @@
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/user_attribute.html b/doc/user_attribute.html index 92f93cc8..ac0dc217 100644 --- a/doc/user_attribute.html +++ b/doc/user_attribute.html @@ -129,13 +129,13 @@ module packet/user_attribute
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/user_attribute.js.html b/doc/user_attribute.js.html index e34f9681..d08ac87e 100644 --- a/doc/user_attribute.js.html +++ b/doc/user_attribute.js.html @@ -98,13 +98,13 @@ UserAttribute.prototype.read = function(bytes) {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/userid-Userid.html b/doc/userid-Userid.html index 13869573..f6e65104 100644 --- a/doc/userid-Userid.html +++ b/doc/userid-Userid.html @@ -414,13 +414,13 @@ John Doe
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/userid.html b/doc/userid.html index 2e8ae624..16e61556 100644 --- a/doc/userid.html +++ b/doc/userid.html @@ -126,13 +126,13 @@ specifies the length of the User ID.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/userid.js.html b/doc/userid.js.html index f625c5dc..546814c8 100644 --- a/doc/userid.js.html +++ b/doc/userid.js.html @@ -94,13 +94,13 @@ Userid.prototype.write = function () {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/doc/util.html b/doc/util.html index db143f10..7ed3dbba 100644 --- a/doc/util.html +++ b/doc/util.html @@ -2000,13 +2000,13 @@ the same as bin2str.
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST)
diff --git a/doc/util.js.html b/doc/util.js.html index 152fc6b5..42cb0bec 100644 --- a/doc/util.js.html +++ b/doc/util.js.html @@ -339,13 +339,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 10:08:07 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST)
diff --git a/jsdoc.template/publish.js b/jsdoc.template/publish.js index ad23b506..a2b66856 100644 --- a/jsdoc.template/publish.js +++ b/jsdoc.template/publish.js @@ -227,7 +227,7 @@ function buildNav(members) { if (members.classes.length) { members.classes.forEach(function(c) { if ( !hasOwnProp.call(seen, c.longname) ) { - classNav += '
  • '+linkto(c.longname, c.name)+'
  • '; + classNav += '
  • '+linkto(c.longname, c.longname.replace(/^module:/,''))+'
  • '; } seen[c.longname] = true; }); From f436c854828a8b0589a8f89a821f5ac03414982d Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Sun, 5 Jan 2014 23:10:19 -0800 Subject: [PATCH 3/3] Add a bunch of links to documentation --- doc/JXG.Util.html | 4 +- doc/aes.html | 4 +- doc/aes.js.html | 4 +- doc/all_packets.js.html | 22 +- doc/armor.html | 4 +- doc/armor.js.html | 4 +- doc/base64.html | 4 +- doc/base64.js.html | 4 +- doc/blowfish.html | 4 +- doc/blowfish.js.html | 4 +- doc/cast5.html | 4 +- doc/cast5.js.html | 4 +- doc/cfb.html | 8 +- doc/cfb.js.html | 8 +- doc/cipher.html | 4 +- doc/cleartext.js.html | 6 +- doc/compressed-Compressed.html | 4 +- doc/compressed.html | 6 +- doc/compressed.js.html | 6 +- doc/config.html | 4 +- doc/config.js.html | 4 +- doc/crypto.html | 20 +- doc/crypto.js.html | 12 +- doc/des.html | 4 +- doc/des.js.html | 4 +- doc/dsa.html | 4 +- doc/dsa.js.html | 4 +- doc/elgamal.html | 4 +- doc/elgamal.js.html | 4 +- doc/enums.js.html | 12 +- doc/hash.html | 12 +- doc/index.html | 4 +- doc/index.js.html | 4 +- doc/index.js_.html | 4 +- doc/index.js__.html | 4 +- doc/index.js___.html | 8 +- doc/index.js____.html | 4 +- doc/index.js_____.html | 64 ++ doc/jsbn.html | 4 +- doc/jsbn.js.html | 4 +- doc/jxg.js.html | 4 +- doc/key.js.html | 10 +- doc/keyid-Keyid.html | 4 +- doc/keyid.html | 6 +- doc/keyid.js.html | 6 +- doc/keyring-Keyring.html | 4 +- doc/keyring.html | 4 +- doc/keyring.js.html | 4 +- doc/literal-Literal.html | 4 +- doc/literal.html | 6 +- doc/literal.js.html | 6 +- doc/localStorage-LocalStorage.html | 4 +- doc/localStorage.html | 4 +- doc/localStorage.js.html | 4 +- doc/localstore.html | 4 +- doc/localstore.js.html | 4 +- doc/marker-Marker.html | 4 +- doc/marker.html | 6 +- doc/marker.js.html | 6 +- doc/md5.html | 4 +- doc/md5.js.html | 4 +- doc/message.js.html | 6 +- doc/module-armor.html | 4 +- doc/module-cleartext-CleartextMessage.html | 6 +- doc/module-cleartext.html | 4 +- doc/module-config.html | 4 +- doc/module-crypto.html | 4 +- doc/module-enums.html | 12 +- doc/module-key-Key.html | 4 +- doc/module-key-SubKey.html | 4 +- doc/module-key-User.html | 4 +- doc/module-key.html | 10 +- doc/module-keyid.html | 4 +- doc/module-message-Message.html | 6 +- doc/module-message.html | 4 +- doc/module-mpi.html | 4 +- doc/module-openpgp.html | 10 +- doc/module-packet.html | 339 +++++++++- doc/module-s2k.html | 4 +- doc/module-util.html | 4 +- doc/mpi-Mpi.html | 8 +- doc/mpi.html | 6 +- doc/mpi.js.html | 10 +- doc/one_pass_signature-OnePassSignature.html | 10 +- doc/one_pass_signature.html | 7 +- doc/one_pass_signature.js.html | 13 +- doc/openpgp.js.html | 8 +- doc/packet.html | 4 +- doc/packet.js.html | 4 +- doc/packetlist-Packetlist.html | 4 +- doc/packetlist.html | 4 +- doc/packetlist.js.html | 4 +- doc/pkcs1.html | 6 +- doc/pkcs1.js.html | 16 +- doc/public_key-PublicKey.html | 139 +++- doc/public_key.html | 4 +- doc/public_key.js.html | 15 +- doc/public_key_.html | 162 +---- ...sion_key-PublicKeyEncryptedSessionKey.html | 12 +- doc/public_key_encrypted_session_key.html | 6 +- doc/public_key_encrypted_session_key.js.html | 14 +- doc/public_subkey-PublicSubkey.html | 170 +---- doc/public_subkey.html | 4 +- doc/public_subkey.js.html | 4 +- doc/random.html | 4 +- doc/random.js.html | 4 +- doc/ripe-md.html | 4 +- doc/ripe-md.js.html | 4 +- doc/rsa.html | 4 +- doc/rsa.js.html | 4 +- doc/s2k-S2k.html | 6 +- doc/s2k.html | 6 +- doc/s2k.js.html | 8 +- doc/secret_key-SecretKey.html | 625 ++++++++++++++++++ doc/secret_key.html | 253 +------ doc/secret_key.js.html | 12 +- doc/secret_subkey-SecretSubkey.html | 170 +---- doc/secret_subkey.html | 4 +- doc/secret_subkey.js.html | 4 +- doc/sha.html | 4 +- doc/sha.js.html | 4 +- doc/signature-Signature.html | 4 +- doc/signature.html | 16 +- doc/signature.js.html | 12 +- doc/signature.js_.html | 12 +- doc/signature_.html | 12 +- ...tected-SymEncryptedIntegrityProtected.html | 14 +- doc/sym_encrypted_integrity_protected.html | 7 +- doc/sym_encrypted_integrity_protected.js.html | 9 +- ...ed_session_key-SymEncryptedSessionKey.html | 4 +- doc/sym_encrypted_session_key.html | 6 +- doc/sym_encrypted_session_key.js.html | 6 +- ...ally_encrypted-SymmetricallyEncrypted.html | 8 +- doc/symmetrically_encrypted.html | 6 +- doc/symmetrically_encrypted.js.html | 10 +- doc/trust-Trust.html | 4 +- doc/trust.html | 4 +- doc/trust.js.html | 4 +- doc/twofish.html | 4 +- doc/twofish.js.html | 4 +- doc/user_attribute-UserAttribute.html | 4 +- doc/user_attribute.html | 4 +- doc/user_attribute.js.html | 4 +- doc/userid-Userid.html | 4 +- doc/userid.html | 4 +- doc/userid.js.html | 4 +- doc/util.html | 4 +- doc/util.js.html | 4 +- src/cleartext.js | 2 +- src/crypto/cfb.js | 4 +- src/crypto/crypto.js | 8 +- src/crypto/hash/index.js | 4 +- src/crypto/pkcs1.js | 12 +- src/crypto/signature.js | 8 +- src/enums.js | 8 +- src/key.js | 6 +- src/message.js | 2 +- src/openpgp.js | 4 +- src/packet/all_packets.js | 18 +- src/packet/compressed.js | 2 +- src/packet/index.js | 4 + src/packet/literal.js | 2 +- src/packet/marker.js | 2 +- src/packet/one_pass_signature.js | 9 +- src/packet/public_key.js | 11 +- .../public_key_encrypted_session_key.js | 10 +- src/packet/secret_key.js | 8 +- src/packet/signature.js | 8 +- .../sym_encrypted_integrity_protected.js | 5 +- src/packet/sym_encrypted_session_key.js | 2 +- src/packet/symmetrically_encrypted.js | 6 +- src/type/keyid.js | 2 +- src/type/mpi.js | 6 +- src/type/s2k.js | 4 +- 174 files changed, 1687 insertions(+), 1237 deletions(-) create mode 100644 doc/index.js_____.html create mode 100644 doc/secret_key-SecretKey.html diff --git a/doc/JXG.Util.html b/doc/JXG.Util.html index 6a1eb63c..79787762 100644 --- a/doc/JXG.Util.html +++ b/doc/JXG.Util.html @@ -554,13 +554,13 @@ EXAMPLES:
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/aes.html b/doc/aes.html index 59ee6484..79e76c16 100644 --- a/doc/aes.html +++ b/doc/aes.html @@ -111,13 +111,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/aes.js.html b/doc/aes.js.html index 394dfb9b..6ad3345e 100644 --- a/doc/aes.js.html +++ b/doc/aes.js.html @@ -546,13 +546,13 @@ for (var i in types) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/all_packets.js.html b/doc/all_packets.js.html index 36ccfd48..2a0ad087 100644 --- a/doc/all_packets.js.html +++ b/doc/all_packets.js.html @@ -66,17 +66,27 @@ module.exports = { Signature: require('./signature.js'), /** @see module:packet/trust */ Trust: require('./trust.js'), - + /** + * Allocate a new packet + * @param {String} tag property name from {@link module:enums.packet} + * @returns {Object} new packet object with type based on tag + */ newPacketFromTag: function (tag) { - return new this[packetClassFromTag(tag)](); + return new this[packetClassFromTagName(tag)](); } }; -function packetClassFromTag(tag) { +/** + * Convert tag name to class name + * @param {String} tag property name from {@link module:enums.packet} + * @returns {String} + */ +function packetClassFromTagName(tag) { return tag.substr(0, 1).toUpperCase() + tag.substr(1); } + for (var i in enums.packet) { - var packetClass = module.exports[packetClassFromTag(i)]; + var packetClass = module.exports[packetClassFromTagName(i)]; if (packetClass !== undefined) packetClass.prototype.tag = enums.packet[i]; @@ -91,13 +101,13 @@ for (var i in enums.packet) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/armor.html b/doc/armor.html index e8b4107c..9545418e 100644 --- a/doc/armor.html +++ b/doc/armor.html @@ -1358,13 +1358,13 @@ given base64 encoded checksum
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:45 GMT-0800 (PST)
    diff --git a/doc/armor.js.html b/doc/armor.js.html index 5f8f97b0..05213549 100644 --- a/doc/armor.js.html +++ b/doc/armor.js.html @@ -413,13 +413,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/base64.html b/doc/base64.html index 73d80009..252f73ce 100644 --- a/doc/base64.html +++ b/doc/base64.html @@ -387,13 +387,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:45 GMT-0800 (PST)
    diff --git a/doc/base64.js.html b/doc/base64.js.html index 92f2fd83..a37e32f4 100644 --- a/doc/base64.js.html +++ b/doc/base64.js.html @@ -136,13 +136,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/blowfish.html b/doc/blowfish.html index 54ead50b..47383f36 100644 --- a/doc/blowfish.html +++ b/doc/blowfish.html @@ -105,13 +105,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/blowfish.js.html b/doc/blowfish.js.html index 72c370ac..73f18bb2 100644 --- a/doc/blowfish.js.html +++ b/doc/blowfish.js.html @@ -451,13 +451,13 @@ module.exports.blockSize = BF.prototype.blockSize = 16;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/cast5.html b/doc/cast5.html index 2dd7d523..c6de4314 100644 --- a/doc/cast5.html +++ b/doc/cast5.html @@ -105,13 +105,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/cast5.js.html b/doc/cast5.js.html index 9d9bc7f8..920d8284 100644 --- a/doc/cast5.js.html +++ b/doc/cast5.js.html @@ -642,13 +642,13 @@ module.exports.keySize = cast5.prototype.keySize = 16;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/cfb.html b/doc/cfb.html index a6a7ebc1..9ea2a11c 100644 --- a/doc/cfb.html +++ b/doc/cfb.html @@ -164,7 +164,7 @@ blockcipher to decrypt a message the algorithm cipher class to decrypt - data in one block_size encryption, @see module:crypto/cipher. + data in one block_size encryption, module:crypto/cipher. @@ -402,7 +402,7 @@ using the specified blockcipher to encrypt a message the algorithm cipher class to encrypt - data in one block_size encryption, @see module:crypto/cipher. + data in one block_size encryption, module:crypto/cipher. @@ -762,13 +762,13 @@ This will be passed to the cipherfn
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/cfb.js.html b/doc/cfb.js.html index 0ce6b808..2662fa0f 100644 --- a/doc/cfb.js.html +++ b/doc/cfb.js.html @@ -59,7 +59,7 @@ module.exports = { * @param {String} prefixrandom random bytes of block_size length provided * as a string to be used in prefixing the data * @param {String} cipherfn the algorithm cipher class to encrypt - * data in one block_size encryption, @see module:crypto/cipher. + * data in one block_size encryption, {@link module:crypto/cipher}. * @param {String} plaintext data to be encrypted provided as a string * @param {String} key binary string representation of key to be used to encrypt the plaintext. * This will be passed to the cipherfn @@ -201,7 +201,7 @@ module.exports = { * This function decrypts a given plaintext using the specified * blockcipher to decrypt a message * @param {String} cipherfn the algorithm cipher class to decrypt - * data in one block_size encryption, @see module:crypto/cipher. + * data in one block_size encryption, {@link 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 @@ -335,13 +335,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/cipher.html b/doc/cipher.html index 9a15e5e3..77ee5b53 100644 --- a/doc/cipher.html +++ b/doc/cipher.html @@ -406,13 +406,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/cleartext.js.html b/doc/cleartext.js.html index 60a981b7..3347600d 100644 --- a/doc/cleartext.js.html +++ b/doc/cleartext.js.html @@ -58,7 +58,7 @@ var config = require('./config'), /** * @class * @classdesc Class that represents an OpenPGP cleartext signed message. - * See http://tools.ietf.org/html/rfc4880#section-7 + * See {@link http://tools.ietf.org/html/rfc4880#section-7} * @param {String} text The cleartext of the signed message * @param {module:packet/packetlist} packetlist The packetlist with signature packets or undefined * if message not yet signed @@ -185,13 +185,13 @@ exports.readArmored = readArmored;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/compressed-Compressed.html b/doc/compressed-Compressed.html index 2f053989..0727fe45 100644 --- a/doc/compressed-Compressed.html +++ b/doc/compressed-Compressed.html @@ -680,13 +680,13 @@ read by read_packet
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/compressed.html b/doc/compressed.html index d38dd089..216d2de4 100644 --- a/doc/compressed.html +++ b/doc/compressed.html @@ -40,7 +40,7 @@
    Implementation of the Compressed Data Packet (Tag 8)

    -RFC4880 5.6: The Compressed Data packet contains compressed data. Typically, +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.
    @@ -128,13 +128,13 @@ a Signature or One-Pass Signature packet, and contains a literal data packet.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/compressed.js.html b/doc/compressed.js.html index 8478a89a..a97dbf41 100644 --- a/doc/compressed.js.html +++ b/doc/compressed.js.html @@ -45,7 +45,7 @@ /** * Implementation of the Compressed Data Packet (Tag 8)<br/> * <br/> - * RFC4880 5.6: The Compressed Data packet contains compressed data. Typically, + * {@link http://tools.ietf.org/html/rfc4880#section-5.6|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 @@ -204,13 +204,13 @@ Compressed.prototype.compress = function () {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/config.html b/doc/config.html index 20fded96..d04f488e 100644 --- a/doc/config.html +++ b/doc/config.html @@ -325,13 +325,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/config.js.html b/doc/config.js.html index bf0b0928..01d3ec6d 100644 --- a/doc/config.js.html +++ b/doc/config.js.html @@ -82,13 +82,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/crypto.html b/doc/crypto.html index 148c59ab..b3e3363f 100644 --- a/doc/crypto.html +++ b/doc/crypto.html @@ -156,7 +156,7 @@ -Integer +module:enums.symmetric @@ -166,7 +166,7 @@ - Algorithm to use (see RFC4880 9.2) + Algorithm to use (see RFC 4880 9.2) @@ -295,7 +295,7 @@ -Integer +module:enums.symmetric @@ -305,7 +305,7 @@ - Algorithm to use (see RFC4880 9.2) + Algorithm to use (see RFC 4880 9.2) @@ -575,7 +575,7 @@ the specified secretMPIs of the private key and the specified algorithm. -Integer +module:enums.publicKey @@ -585,7 +585,7 @@ the specified secretMPIs of the private key and the specified algorithm. - Algorithm to be used (See RFC4880 9.1) + Algorithm to be used (See RFC 4880 9.1) @@ -786,7 +786,7 @@ and the specified algorithm. -Integer +module:enums.publicKey @@ -796,7 +796,7 @@ and the specified algorithm. - Algorithm to be used (See RFC4880 9.1) + Algorithm to be used (See RFC 4880 9.1) @@ -937,13 +937,13 @@ if elgamal encryption an array of two module:type/mpi is returned; otherwise nul
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/crypto.js.html b/doc/crypto.js.html index 5a1c815d..15b12084 100644 --- a/doc/crypto.js.html +++ b/doc/crypto.js.html @@ -61,7 +61,7 @@ module.exports = { /** * Encrypts data using the specified public key multiprecision integers * and the specified algorithm. - * @param {Integer} algo Algorithm to be used (See RFC4880 9.1) + * @param {module:enums.publicKey} algo Algorithm to be used (See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1}) * @param {Array<module:type/mpi>} publicMPIs Algorithm dependent multiprecision integers * @param {module:type/mpi} data Data to be encrypted as MPI * @return {Array<module:type/mpi>} if RSA an module:type/mpi; @@ -102,7 +102,7 @@ module.exports = { /** * Decrypts data using the specified public key multiprecision integers of the private key, * the specified secretMPIs of the private key and the specified algorithm. - * @param {Integer} algo Algorithm to be used (See RFC4880 9.1) + * @param {module:enums.publicKey} algo Algorithm to be used (See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1}) * @param {Array<module:type/mpi>} publicMPIs Algorithm dependent multiprecision integers * of the public key part of the private key * @param {Array<module:type/mpi>} secretMPIs Algorithm dependent multiprecision integers @@ -234,7 +234,7 @@ module.exports = { /** * generate random byte prefix as string for the specified algorithm - * @param {Integer} algo Algorithm to use (see RFC4880 9.2) + * @param {module:enums.symmetric} algo Algorithm to use (see {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC 4880 9.2}) * @return {String} Random bytes with length equal to the block * size of the cipher */ @@ -244,7 +244,7 @@ module.exports = { /** * Generating a session key for the specified symmetric algorithm - * @param {Integer} algo Algorithm to use (see RFC4880 9.2) + * @param {module:enums.symmetric} algo Algorithm to use (see {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC 4880 9.2}) * @return {String} Random bytes as a string to be used as a key */ generateSessionKey: function(algo) { @@ -261,13 +261,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/des.html b/doc/des.html index 0dfac5e4..719fdf07 100644 --- a/doc/des.html +++ b/doc/des.html @@ -209,13 +209,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/des.js.html b/doc/des.js.html index d3837411..f219fed3 100644 --- a/doc/des.js.html +++ b/doc/des.js.html @@ -444,13 +444,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/dsa.html b/doc/dsa.html index 2b2e077b..423d2349 100644 --- a/doc/dsa.html +++ b/doc/dsa.html @@ -117,13 +117,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:45 GMT-0800 (PST)
    diff --git a/doc/dsa.js.html b/doc/dsa.js.html index 9e33e53a..ac7de924 100644 --- a/doc/dsa.js.html +++ b/doc/dsa.js.html @@ -206,13 +206,13 @@ module.exports = DSA;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/elgamal.html b/doc/elgamal.html index f3f1e27d..26f9f983 100644 --- a/doc/elgamal.html +++ b/doc/elgamal.html @@ -115,13 +115,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:45 GMT-0800 (PST)
    diff --git a/doc/elgamal.js.html b/doc/elgamal.js.html index 34173463..de0ed195 100644 --- a/doc/elgamal.js.html +++ b/doc/elgamal.js.html @@ -95,13 +95,13 @@ module.exports = Elgamal;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/enums.js.html b/doc/enums.js.html index e459df97..d00ca3c9 100644 --- a/doc/enums.js.html +++ b/doc/enums.js.html @@ -42,7 +42,7 @@ module.exports = { gnu: 101 }, - /** RFC4880, section 9.1 + /** {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC4880, section 9.1} * @enum {Integer} * @readonly */ @@ -54,7 +54,7 @@ module.exports = { dsa: 17 }, - /** RFC4880, section 9.2 + /** {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2} * @enum {Integer} * @readonly */ @@ -71,7 +71,7 @@ module.exports = { twofish: 10 }, - /** RFC4880, section 9.3 + /** {@link http://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3} * @enum {Integer} * @readonly */ @@ -84,7 +84,7 @@ module.exports = { bzip2: 3 }, - /** RFC4880, section 9.4 + /** {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4} * @enum {Integer} * @readonly */ @@ -352,13 +352,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/hash.html b/doc/hash.html index 7c3d6bec..fa7ba8c7 100644 --- a/doc/hash.html +++ b/doc/hash.html @@ -553,7 +553,7 @@ -Integer +module:enums.hash @@ -563,7 +563,7 @@ - Hash algorithm type (see RFC4880 9.4) + Hash algorithm type (see RFC 4880 9.4) @@ -715,7 +715,7 @@ -Integer +module:enums.hash @@ -725,7 +725,7 @@ - Hash algorithm type (See RFC4880 9.4) + Hash algorithm type (See RFC 4880 9.4) @@ -819,13 +819,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/index.html b/doc/index.html index e89d0881..f4ae0812 100644 --- a/doc/index.html +++ b/doc/index.html @@ -180,13 +180,13 @@ for extending and developing on top of the base library.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/index.js.html b/doc/index.js.html index 68870032..75605fc7 100644 --- a/doc/index.js.html +++ b/doc/index.js.html @@ -74,13 +74,13 @@ module.exports.crypto = require('./crypto');
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/index.js_.html b/doc/index.js_.html index 842bd1b0..61e571cc 100644 --- a/doc/index.js_.html +++ b/doc/index.js_.html @@ -60,13 +60,13 @@ for (var i in crypto)
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/index.js__.html b/doc/index.js__.html index 6fd9ad4c..64238e1a 100644 --- a/doc/index.js__.html +++ b/doc/index.js__.html @@ -63,13 +63,13 @@ for (var i in aes) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/index.js___.html b/doc/index.js___.html index 515a5ae0..6c072888 100644 --- a/doc/index.js___.html +++ b/doc/index.js___.html @@ -49,7 +49,7 @@ module.exports = { /** * Create a hash on the specified data using the specified algorithm - * @param {Integer} algo Hash algorithm type (see RFC4880 9.4) + * @param {module:enums.hash} algo Hash algorithm type (see {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}) * @param {String} data Data to be hashed * @return {String} hash value */ @@ -83,7 +83,7 @@ module.exports = { /** * Returns the hash size in bytes of the specified hash algorithm type - * @param {Integer} algo Hash algorithm type (See RFC4880 9.4) + * @param {module:enums.hash} algo Hash algorithm type (See {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}) * @return {Integer} Size in bytes of the resulting hash */ getHashByteLength: function(algo) { @@ -123,13 +123,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/index.js____.html b/doc/index.js____.html index d3df77ee..0a3dde33 100644 --- a/doc/index.js____.html +++ b/doc/index.js____.html @@ -49,13 +49,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/index.js_____.html b/doc/index.js_____.html new file mode 100644 index 00000000..3c70e935 --- /dev/null +++ b/doc/index.js_____.html @@ -0,0 +1,64 @@ + + + + + JSDoc: Source: packet/index.js + + + + + + + + + + +
    + +

    Source: packet/index.js

    + + + + + +
    +
    +
    var enums = require('../enums.js');
    +
    +module.exports = {
    +  /**
    +   * @name module:packet.List
    +   * @see module:packet/packetlist
    +   */
    +  List: require('./packetlist.js')
    +};
    +
    +var packets = require('./all_packets.js');
    +
    +for (var i in packets)
    +  module.exports[i] = packets[i];
    +
    +
    +
    + + + + +
    + + + +
    + +
    + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST) +
    + + + + + diff --git a/doc/jsbn.html b/doc/jsbn.html index 3035335a..d829b5d5 100644 --- a/doc/jsbn.html +++ b/doc/jsbn.html @@ -111,13 +111,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:45 GMT-0800 (PST)
    diff --git a/doc/jsbn.js.html b/doc/jsbn.js.html index 21c4d235..9199233d 100644 --- a/doc/jsbn.js.html +++ b/doc/jsbn.js.html @@ -1745,13 +1745,13 @@ BigInteger.prototype.square = bnSquare;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/jxg.js.html b/doc/jxg.js.html index 41d49338..885b88e0 100644 --- a/doc/jxg.js.html +++ b/doc/jxg.js.html @@ -1297,13 +1297,13 @@ module.exports = JXG;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/key.js.html b/doc/key.js.html index 485bd68e..2667c07e 100644 --- a/doc/key.js.html +++ b/doc/key.js.html @@ -450,7 +450,7 @@ Key.prototype.verifyPrimaryKey = function() { return enums.keyStatus.expired; } // check for at least one self signature. Self signature of user ID not mandatory - // See http://tools.ietf.org/html/rfc4880#section-11.1 + // See {@link 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) { @@ -735,8 +735,8 @@ function readArmored(armoredText) { /** * Generates a new OpenPGP key. Currently only supports RSA keys. * Primary and subkey will be of same type. - * @param {Integer} keyType to indicate what type of key to make. - * RSA is 1. See http://tools.ietf.org/html/rfc4880#section-9.1 + * @param {module:enums.publicKey} keyType to indicate what type of key to make. + * RSA is 1. See {@link http://tools.ietf.org/html/rfc4880#section-9.1} * @param {Integer} numBits number of bits for the key creation. * @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 @@ -803,13 +803,13 @@ exports.generate = generate;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/keyid-Keyid.html b/doc/keyid-Keyid.html index 1d173b1f..d9cccf15 100644 --- a/doc/keyid-Keyid.html +++ b/doc/keyid-Keyid.html @@ -254,13 +254,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/keyid.html b/doc/keyid.html index 370f27f0..b06e027d 100644 --- a/doc/keyid.html +++ b/doc/keyid.html @@ -38,7 +38,7 @@ -
    Implementation of type key id (RFC4880 3.3)
    +
    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 @@ -125,13 +125,13 @@ formed.

    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/keyid.js.html b/doc/keyid.js.html index c88d8ffd..f446c21b 100644 --- a/doc/keyid.js.html +++ b/doc/keyid.js.html @@ -43,7 +43,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /** - * Implementation of type key id (RFC4880 3.3)<br/> + * Implementation of type key id ({@link http://tools.ietf.org/html/rfc4880#section-3.3|RFC4880 3.3})<br/> * <br/> * A Key ID is an eight-octet scalar that identifies a key. * Implementations SHOULD NOT assume that Key IDs are unique. The @@ -102,13 +102,13 @@ module.exports.mapToHex = function (keyId) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/keyring-Keyring.html b/doc/keyring-Keyring.html index b6c7f599..7a7c5275 100644 --- a/doc/keyring-Keyring.html +++ b/doc/keyring-Keyring.html @@ -1291,13 +1291,13 @@ keyring from HTML5 local storage and initializes this instance.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/keyring.html b/doc/keyring.html index be72c4d5..6b563140 100644 --- a/doc/keyring.html +++ b/doc/keyring.html @@ -822,13 +822,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/keyring.js.html b/doc/keyring.js.html index bef1ee84..eaecfc1f 100644 --- a/doc/keyring.js.html +++ b/doc/keyring.js.html @@ -224,13 +224,13 @@ Keyring.prototype.exportPublicKey = function (index) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/literal-Literal.html b/doc/literal-Literal.html index 795a3e8d..981744c3 100644 --- a/doc/literal-Literal.html +++ b/doc/literal-Literal.html @@ -909,13 +909,13 @@ will be normalized to \r\n and by default text is converted to UTF8
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/literal.html b/doc/literal.html index 8cd96199..97542f0f 100644 --- a/doc/literal.html +++ b/doc/literal.html @@ -40,7 +40,7 @@
    Implementation of the Literal Data Packet (Tag 11)

    -RFC4880 5.9: A Literal Data packet contains the body of a message; data that +RFC4880 5.9: A Literal Data packet contains the body of a message; data that is not to be further interpreted.
    @@ -125,13 +125,13 @@ is not to be further interpreted.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/literal.js.html b/doc/literal.js.html index 87b2248c..588cfed5 100644 --- a/doc/literal.js.html +++ b/doc/literal.js.html @@ -45,7 +45,7 @@ /** * 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 + * {@link http://tools.ietf.org/html/rfc4880#section-5.9|RFC4880 5.9}: A Literal Data packet contains the body of a message; data that * is not to be further interpreted. * @requires enums * @requires util @@ -165,13 +165,13 @@ Literal.prototype.write = function () {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/localStorage-LocalStorage.html b/doc/localStorage-LocalStorage.html index 8b22c8e0..eac2232e 100644 --- a/doc/localStorage-LocalStorage.html +++ b/doc/localStorage-LocalStorage.html @@ -277,13 +277,13 @@ if config is null the default config will be used
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/localStorage.html b/doc/localStorage.html index 06aca0e8..8f68a7b0 100644 --- a/doc/localStorage.html +++ b/doc/localStorage.html @@ -114,13 +114,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/localStorage.js.html b/doc/localStorage.js.html index 0cf92892..568f984e 100644 --- a/doc/localStorage.js.html +++ b/doc/localStorage.js.html @@ -68,13 +68,13 @@ LocalStorage.prototype.write = function () {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/localstore.html b/doc/localstore.html index 2c7a3d64..e5c13992 100644 --- a/doc/localstore.html +++ b/doc/localstore.html @@ -113,13 +113,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/localstore.js.html b/doc/localstore.js.html index 895a4526..821c809d 100644 --- a/doc/localstore.js.html +++ b/doc/localstore.js.html @@ -93,13 +93,13 @@ LocalStore.prototype.store = function (keys) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/marker-Marker.html b/doc/marker-Marker.html index b5116492..422c9d90 100644 --- a/doc/marker-Marker.html +++ b/doc/marker-Marker.html @@ -323,13 +323,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/marker.html b/doc/marker.html index 5b46bc54..d4b35d69 100644 --- a/doc/marker.html +++ b/doc/marker.html @@ -40,7 +40,7 @@
    Implementation of the strange "Marker packet" (Tag 10)

    -RFC4880 5.8: An experimental version of PGP used this packet as the Literal +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.
    @@ -121,13 +121,13 @@ Such a packet MUST be ignored when received.

    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/marker.js.html b/doc/marker.js.html index 037112e0..0adf20a3 100644 --- a/doc/marker.js.html +++ b/doc/marker.js.html @@ -46,7 +46,7 @@ /** * Implementation of the strange "Marker packet" (Tag 10)<br/> * <br/> - * RFC4880 5.8: An experimental version of PGP used this packet as the Literal + * {@link http://tools.ietf.org/html/rfc4880#section-5.8|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.<br/> @@ -92,13 +92,13 @@ Marker.prototype.read = function (bytes) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/md5.html b/doc/md5.html index 3ddb9f7c..82f04806 100644 --- a/doc/md5.html +++ b/doc/md5.html @@ -229,13 +229,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:45 GMT-0800 (PST)
    diff --git a/doc/md5.js.html b/doc/md5.js.html index 4193382f..2315dc19 100644 --- a/doc/md5.js.html +++ b/doc/md5.js.html @@ -252,13 +252,13 @@ if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/message.js.html b/doc/message.js.html index 7f7b985d..be228262 100644 --- a/doc/message.js.html +++ b/doc/message.js.html @@ -62,7 +62,7 @@ var packet = require('./packet'), * @classdesc Class that represents an OpenPGP message. * Can be an encrypted message, signed message, compressed message or literal message * @param {module:packet/packetlist} packetlist The packets that form this message - * See http://tools.ietf.org/html/rfc4880#section-11.3 + * See {@link http://tools.ietf.org/html/rfc4880#section-11.3} */ function Message(packetlist) { @@ -351,13 +351,13 @@ exports.fromBinary = fromBinary;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/module-armor.html b/doc/module-armor.html index 524c15c8..9a9c5943 100644 --- a/doc/module-armor.html +++ b/doc/module-armor.html @@ -112,13 +112,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/module-cleartext-CleartextMessage.html b/doc/module-cleartext-CleartextMessage.html index d04c39de..c18a8586 100644 --- a/doc/module-cleartext-CleartextMessage.html +++ b/doc/module-cleartext-CleartextMessage.html @@ -33,7 +33,7 @@
    Class that represents an OpenPGP cleartext signed message. -See http://tools.ietf.org/html/rfc4880#section-7
    +See http://tools.ietf.org/html/rfc4880#section-7 @@ -741,13 +741,13 @@ See http://tools.ietf.org/html/rfc4880#section-7
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/module-cleartext.html b/doc/module-cleartext.html index 29e3df0a..a5338209 100644 --- a/doc/module-cleartext.html +++ b/doc/module-cleartext.html @@ -267,13 +267,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/module-config.html b/doc/module-config.html index edcec2ab..81294689 100644 --- a/doc/module-config.html +++ b/doc/module-config.html @@ -112,13 +112,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/module-crypto.html b/doc/module-crypto.html index a747a9c1..ff77a6f9 100644 --- a/doc/module-crypto.html +++ b/doc/module-crypto.html @@ -515,13 +515,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:44 GMT-0800 (PST)
    diff --git a/doc/module-enums.html b/doc/module-enums.html index d62d740c..6a9669b9 100644 --- a/doc/module-enums.html +++ b/doc/module-enums.html @@ -369,7 +369,7 @@
    - RFC4880, section 9.3 + RFC4880, section 9.3
    @@ -579,7 +579,7 @@
    - RFC4880, section 9.4 + RFC4880, section 9.4
    @@ -2182,7 +2182,7 @@
    - RFC4880, section 9.1 + RFC4880, section 9.1
    @@ -4022,7 +4022,7 @@ document) that cannot include a target subpacket.
    - RFC4880, section 9.2 + RFC4880, section 9.2
    @@ -4527,13 +4527,13 @@ document) that cannot include a target subpacket.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:45 GMT-0800 (PST)
    diff --git a/doc/module-key-Key.html b/doc/module-key-Key.html index 2ec2cec1..0143b82e 100644 --- a/doc/module-key-Key.html +++ b/doc/module-key-Key.html @@ -2252,13 +2252,13 @@ and valid self signature
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/module-key-SubKey.html b/doc/module-key-SubKey.html index 95e18f4e..b6887c07 100644 --- a/doc/module-key-SubKey.html +++ b/doc/module-key-SubKey.html @@ -594,13 +594,13 @@ and valid binding signature
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/module-key-User.html b/doc/module-key-User.html index 9627c9e3..77a216d5 100644 --- a/doc/module-key-User.html +++ b/doc/module-key-User.html @@ -676,13 +676,13 @@ and validity of self signature
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/module-key.html b/doc/module-key.html index 8a58ad87..7b31ecab 100644 --- a/doc/module-key.html +++ b/doc/module-key.html @@ -170,7 +170,7 @@ Primary and subkey will be of same type. -Integer +module:enums.publicKey @@ -180,8 +180,8 @@ Primary and subkey will be of same type. - to indicate what type of key to make. - RSA is 1. See http://tools.ietf.org/html/rfc4880#section-9.1 + to indicate what type of key to make. + RSA is 1. See http://tools.ietf.org/html/rfc4880#section-9.1 @@ -479,13 +479,13 @@ Primary and subkey will be of same type.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/module-keyid.html b/doc/module-keyid.html index 21771ad6..c42069d5 100644 --- a/doc/module-keyid.html +++ b/doc/module-keyid.html @@ -112,13 +112,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:16 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/module-message-Message.html b/doc/module-message-Message.html index cc223196..7792c8e6 100644 --- a/doc/module-message-Message.html +++ b/doc/module-message-Message.html @@ -99,7 +99,7 @@ Can be an encrypted message, signed message, compressed message or literal messa The packets that form this message -See http://tools.ietf.org/html/rfc4880#section-11.3 +See http://tools.ietf.org/html/rfc4880#section-11.3 @@ -1297,13 +1297,13 @@ See http://tools.ietf.org/html/rfc4880#section-11.3
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/module-message.html b/doc/module-message.html index 181df3c7..3bc04e06 100644 --- a/doc/module-message.html +++ b/doc/module-message.html @@ -547,13 +547,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:46 GMT-0800 (PST)
    diff --git a/doc/module-mpi.html b/doc/module-mpi.html index ce51cb60..d1f45b62 100644 --- a/doc/module-mpi.html +++ b/doc/module-mpi.html @@ -112,13 +112,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/module-openpgp.html b/doc/module-openpgp.html index 6bcaf0e4..f2c004bd 100644 --- a/doc/module-openpgp.html +++ b/doc/module-openpgp.html @@ -675,7 +675,7 @@ Primary and subkey will be of same type. -Integer +module:enums.publicKey @@ -685,8 +685,8 @@ Primary and subkey will be of same type. - to indicate what type of key to make. - RSA is 1. See http://tools.ietf.org/html/rfc4880#section-9.1 + to indicate what type of key to make. + RSA is 1. See http://tools.ietf.org/html/rfc4880#section-9.1 @@ -1358,13 +1358,13 @@ Primary and subkey will be of same type.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/module-packet.html b/doc/module-packet.html index de5d1e00..33eb590e 100644 --- a/doc/module-packet.html +++ b/doc/module-packet.html @@ -156,6 +156,63 @@ +
    +

    <static> List

    + + +
    +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + +
    See:
    +
    + +
    + + + +
    + + + +
    + + +

    <static> Literal

    @@ -1013,6 +1070,284 @@ +

    Methods

    + +
    + +
    +

    <static> newPacketFromTag(tag) → {Object}

    + + +
    +
    + + +
    + Allocate a new packet +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tag + + +String + + + + property name from module:enums.packet
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    + new packet object with type based on tag +
    + + + +
    +
    + Type +
    +
    + +Object + + +
    +
    + + + + +
    + + + +
    +

    <inner> packetClassFromTagName(tag) → {String}

    + + +
    +
    + + +
    + Convert tag name to class name +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tag + + +String + + + + property name from module:enums.packet
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +String + + +
    +
    + + + + +
    + +
    + @@ -1027,13 +1362,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/module-s2k.html b/doc/module-s2k.html index b48009e3..da0381f1 100644 --- a/doc/module-s2k.html +++ b/doc/module-s2k.html @@ -112,13 +112,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/module-util.html b/doc/module-util.html index 81a7c223..a7c67290 100644 --- a/doc/module-util.html +++ b/doc/module-util.html @@ -112,13 +112,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/mpi-Mpi.html b/doc/mpi-Mpi.html index 4dfcd177..e77ad0da 100644 --- a/doc/mpi-Mpi.html +++ b/doc/mpi-Mpi.html @@ -190,7 +190,7 @@
    - Parsing function for a mpi (RFC 4880 3.2). + Parsing function for a mpi (RFC 4880 3.2).
    @@ -329,7 +329,7 @@
    - Converts the mpi object to a string as specified in RFC4880 3.2 + Converts the mpi object to a string as specified in RFC4880 3.2
    @@ -425,13 +425,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/mpi.html b/doc/mpi.html index a4091a7b..c10404c6 100644 --- a/doc/mpi.html +++ b/doc/mpi.html @@ -38,7 +38,7 @@ -
    Implementation of type MPI (RFC4880 3.2)
    +
    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 @@ -129,13 +129,13 @@ actual integer.

    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/mpi.js.html b/doc/mpi.js.html index bd80004b..154b3f5b 100644 --- a/doc/mpi.js.html +++ b/doc/mpi.js.html @@ -48,7 +48,7 @@ // - MPI = c | d << 8 | e << ((MPI.length -2)*8) | f ((MPI.length -2)*8) /** - * Implementation of type MPI (RFC4880 3.2)<br/> + * Implementation of type MPI ({@link http://tools.ietf.org/html/rfc4880#section-3.2|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 @@ -75,7 +75,7 @@ function Mpi() { } /** - * Parsing function for a mpi (RFC 4880 3.2). + * Parsing function for a mpi ({@link http://tools.ietf.org/html/rfc4880#section3.2|RFC 4880 3.2}). * @param {String} input Payload of mpi data * @return {Integer} Length of data read */ @@ -113,7 +113,7 @@ Mpi.prototype.byteLength = function () { }; /** - * Converts the mpi object to a string as specified in RFC4880 3.2 + * Converts the mpi object to a string as specified in {@link http://tools.ietf.org/html/rfc4880#section-3.2|RFC4880 3.2} * @return {String} mpi Byte representation */ Mpi.prototype.write = function () { @@ -137,13 +137,13 @@ Mpi.prototype.fromBigInteger = function (bn) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/one_pass_signature-OnePassSignature.html b/doc/one_pass_signature-OnePassSignature.html index 19d72aa6..9112cea3 100644 --- a/doc/one_pass_signature-OnePassSignature.html +++ b/doc/one_pass_signature-OnePassSignature.html @@ -78,7 +78,7 @@
    Source:
    @@ -213,7 +213,7 @@
    Source:
    @@ -304,7 +304,7 @@
    Source:
    @@ -367,13 +367,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/one_pass_signature.html b/doc/one_pass_signature.html index 791b023f..ae724103 100644 --- a/doc/one_pass_signature.html +++ b/doc/one_pass_signature.html @@ -40,8 +40,7 @@
    Implementation of the One-Pass Signature Packets (Tag 4)

    -RFC4880 5.4: -The One-Pass Signature packet precedes the signed data and contains +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 @@ -129,13 +128,13 @@ can compute the entire signed message in one pass.

    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/one_pass_signature.js.html b/doc/one_pass_signature.js.html index c3bbfa22..abccca5d 100644 --- a/doc/one_pass_signature.js.html +++ b/doc/one_pass_signature.js.html @@ -45,8 +45,7 @@ /** * Implementation of the One-Pass Signature Packets (Tag 4)<br/> * <br/> - * RFC4880 5.4: - * The One-Pass Signature packet precedes the signed data and contains + * {@link http://tools.ietf.org/html/rfc4880#section-5.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 @@ -66,9 +65,9 @@ var enums = require('../enums.js'), */ function OnePassSignature() { this.version = null; // A one-octet version number. The current version is 3. - this.type = null; // A one-octet signature type. Signature types are described in RFC4880 Section 5.2.1. - this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See RFC4880 9.4) - this.publicKeyAlgorithm = null; // A one-octet number describing the public-key algorithm used. (See RFC4880 9.1) + this.type = null; // A one-octet signature type. Signature types are described in {@link http://tools.ietf.org/html/rfc4880#section-5.2.1|RFC4880 Section 5.2.1}. + this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC4880 9.4}) + this.publicKeyAlgorithm = null; // A one-octet number describing the public-key algorithm used. (See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC4880 9.1}) this.signingKeyId = null; // An eight-octet number holding the Key ID of the signing key. this.flags = null; // A one-octet number holding a flag showing whether the signature is nested. A zero value indicates that the next packet is another One-Pass Signature packet that describes another signature to be applied to the same message data. } @@ -132,13 +131,13 @@ OnePassSignature.prototype.write = function () {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/openpgp.js.html b/doc/openpgp.js.html index 56afc290..735f5879 100644 --- a/doc/openpgp.js.html +++ b/doc/openpgp.js.html @@ -165,8 +165,8 @@ function verifyClearSignedMessage(publicKeys, message) { /** * Generates a new OpenPGP key pair. Currently only supports RSA keys. * Primary and subkey will be of same type. - * @param {Integer} keyType to indicate what type of key to make. - * RSA is 1. See http://tools.ietf.org/html/rfc4880#section-9.1 + * @param {module:enums.publicKey} keyType to indicate what type of key to make. + * RSA is 1. See {@link http://tools.ietf.org/html/rfc4880#section-9.1} * @param {Integer} numBits number of bits for the key creation. (should be 1024+, generally) * @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 @@ -199,13 +199,13 @@ exports.generateKeyPair = generateKeyPair;
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/packet.html b/doc/packet.html index bbec64d3..0880a926 100644 --- a/doc/packet.html +++ b/doc/packet.html @@ -768,13 +768,13 @@ string
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:17 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/packet.js.html b/doc/packet.js.html index 1fc690bd..eadc8b2d 100644 --- a/doc/packet.js.html +++ b/doc/packet.js.html @@ -298,13 +298,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/packetlist-Packetlist.html b/doc/packetlist-Packetlist.html index c11398ec..8185476f 100644 --- a/doc/packetlist-Packetlist.html +++ b/doc/packetlist-Packetlist.html @@ -1036,13 +1036,13 @@ class instance.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/packetlist.html b/doc/packetlist.html index 52785214..d803303d 100644 --- a/doc/packetlist.html +++ b/doc/packetlist.html @@ -126,13 +126,13 @@ are stored as numerical indices.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:18 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:47 GMT-0800 (PST)
    diff --git a/doc/packetlist.js.html b/doc/packetlist.js.html index ce46da62..cb166725 100644 --- a/doc/packetlist.js.html +++ b/doc/packetlist.js.html @@ -212,13 +212,13 @@ Packetlist.prototype.concat = function (packetlist) {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/pkcs1.html b/doc/pkcs1.html index 3f64e995..778fac63 100644 --- a/doc/pkcs1.html +++ b/doc/pkcs1.html @@ -117,7 +117,7 @@
    - ASN1 object identifiers for hashes (See RFC4880 5.2.2) + ASN1 object identifiers for hashes (See http://tools.ietf.org/html/rfc4880#section-5.2.2)
    @@ -179,13 +179,13 @@
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:15 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:45 GMT-0800 (PST)
    diff --git a/doc/pkcs1.js.html b/doc/pkcs1.js.html index b9ef35af..efd12d09 100644 --- a/doc/pkcs1.js.html +++ b/doc/pkcs1.js.html @@ -53,7 +53,7 @@ */ /** - * ASN1 object identifiers for hashes (See RFC4880 5.2.2) + * ASN1 object identifiers for hashes (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.2}) */ hash_headers = []; hash_headers[1] = [0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, @@ -83,7 +83,7 @@ var crypto = require('./crypto.js'), module.exports = { eme: { /** - * create a EME-PKCS1-v1_5 padding (See RFC4880 13.1.1) + * create a EME-PKCS1-v1_5 padding (See {@link http://tools.ietf.org/html/rfc4880#section-13.1.1|RFC 4880 13.1.1}) * @param {String} message message to be padded * @param {Integer} length Length to the resulting message * @return {String} EME-PKCS1 padded message @@ -103,9 +103,9 @@ module.exports = { }, /** - * decodes a EME-PKCS1-v1_5 padding (See RFC4880 13.1.2) + * decodes a EME-PKCS1-v1_5 padding (See {@link http://tools.ietf.org/html/rfc4880#section-13.1.2|RFC 4880 13.1.2}) * @param {String} message EME-PKCS1 padded message - * @return {String} decoded message + * @return {String} decoded message */ decode: function(message, len) { if (message.length < len) @@ -122,7 +122,7 @@ module.exports = { emsa: { /** - * create a EMSA-PKCS1-v1_5 padding (See RFC4880 13.1.3) + * create a EMSA-PKCS1-v1_5 padding (See {@link http://tools.ietf.org/html/rfc4880#section-13.1.3|RFC 4880 13.1.3}) * @param {Integer} algo Hash algorithm type used * @param {String} data Data to be hashed * @param {Integer} keylength Key size of the public mpi in bytes @@ -148,7 +148,7 @@ module.exports = { }, /** - * extract the hash out of an EMSA-PKCS1-v1.5 padding (See RFC4880 13.1.3) + * extract the hash out of an EMSA-PKCS1-v1.5 padding (See {@link http://tools.ietf.org/html/rfc4880#section-13.1.3|RFC 4880 13.1.3}) * @param {String} data Hash in pkcs1 encoding * @returns {String} The hash as string */ @@ -180,13 +180,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/public_key-PublicKey.html b/doc/public_key-PublicKey.html index fad04a50..085c79b7 100644 --- a/doc/public_key-PublicKey.html +++ b/doc/public_key-PublicKey.html @@ -305,6 +305,128 @@ +
    + + + + + + + +
    +

    readPublicKey

    + + +
    +
    + +
    + Alias of read() +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + +
    See:
    +
    + +
    + + + +
    + + + +
    + + + +
    +

    writePublicKey

    + + +
    +
    + +
    + Alias of write() +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + +
    See:
    +
    + +
    + + +
    @@ -361,7 +483,7 @@
    Source:
    @@ -452,7 +574,7 @@
    Source:
    @@ -510,8 +632,7 @@
    - Internal Parser for public keys as specified in RFC 4880 section -5.5.2 Public-Key Packet Formats + Internal Parser for public keys as specified in RFC 4880 section 5.5.2 Public-Key Packet Formats called by read_tag<num>
    @@ -593,7 +714,7 @@ called by read_tag<num>
    Source:
    @@ -685,7 +806,7 @@ public key.
    Source:
    @@ -777,7 +898,7 @@ header: [string] OpenPGP packet header, string: [string] header+body}
    Source:
    @@ -818,13 +939,13 @@ header: [string] OpenPGP packet header, string: [string] header+body}
    diff --git a/doc/public_key.html b/doc/public_key.html index 161c219d..d002bfe3 100644 --- a/doc/public_key.html +++ b/doc/public_key.html @@ -290,13 +290,13 @@
    diff --git a/doc/public_key.js.html b/doc/public_key.js.html index 89dbdf6d..41e32051 100644 --- a/doc/public_key.js.html +++ b/doc/public_key.js.html @@ -45,7 +45,7 @@ /** * Implementation of the Key Material Packet (Tag 5,6,7,14)<br/> * <br/> - * RFC4480 5.5: + * {@link http://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}: * A key material packet contains all the information about a public or * private key. There are four variants of this packet type, and two * major versions. Consequently, this section is complex. @@ -84,8 +84,7 @@ function PublicKey() { } /** - * Internal Parser for public keys as specified in RFC 4880 section - * 5.5.2 Public-Key Packet Formats + * Internal Parser for public keys as specified in {@link http://tools.ietf.org/html/rfc4880#section-5.5.2|RFC 4880 section 5.5.2 Public-Key Packet Formats} * called by read_tag<num> * @param {String} input Input string to read the packet from * @return {Object} This object with attributes set by the parser @@ -135,8 +134,7 @@ PublicKey.prototype.read = function (bytes) { /** * Alias of read() - * @function module:packet/public_key#readPublicKey - * @see module:packet/public_key#read + * @see module:packet/public_key~PublicKey#read */ PublicKey.prototype.readPublicKey = PublicKey.prototype.read; @@ -166,8 +164,7 @@ PublicKey.prototype.write = function () { /** * Alias of write() - * @function module:packet/public_key#writePublicKey - * @see module:packet/public_key#write + * @see module:packet/public_key~PublicKey#write */ PublicKey.prototype.writePublicKey = PublicKey.prototype.write; @@ -223,13 +220,13 @@ PublicKey.prototype.getFingerprint = function () {
    diff --git a/doc/public_key_.html b/doc/public_key_.html index aa0c1d9b..4e70794a 100644 --- a/doc/public_key_.html +++ b/doc/public_key_.html @@ -40,7 +40,7 @@
    Implementation of the Key Material Packet (Tag 5,6,7,14)

    -RFC4480 5.5: +RFC4480 5.5: A key material packet contains all the information about a public or private key. There are four variants of this packet type, and two major versions. Consequently, this section is complex.
    @@ -119,162 +119,6 @@ major versions. Consequently, this section is complex. -

    Methods

    - -
    - -
    -

    readPublicKey()

    - - -
    -
    - - -
    - Alias of read() -
    - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    Source:
    -
    - - - - - -
    See:
    -
    -
      -
    • module:packet/public_key#read
    • -
    -
    - - - -
    - - - - - - - - - - - - - -
    - - - -
    -

    writePublicKey()

    - - -
    -
    - - -
    - Alias of write() -
    - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    Source:
    -
    - - - - - -
    See:
    -
    -
      -
    • module:packet/public_key#write
    • -
    -
    - - - -
    - - - - - - - - - - - - - -
    - -
    - @@ -289,13 +133,13 @@ major versions. Consequently, this section is complex.
    diff --git a/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html b/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html index c15e508c..e62dd9de 100644 --- a/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html +++ b/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html @@ -608,7 +608,7 @@ packets (tag 1) -Integer +module:enums.publicKey @@ -618,7 +618,7 @@ packets (tag 1) - The corresponding public key algorithm // See RFC4880 9.1 + The corresponding public key algorithm // See RFC4880 9.1 @@ -631,7 +631,7 @@ packets (tag 1) -Integer +module:enums.symmetric @@ -644,7 +644,7 @@ packets (tag 1) The symmetric cipher algorithm used to encrypt the data within an encrypteddatapacket or encryptedintegrity- protecteddatapacket - following this packet //See RFC4880 9.2 + following this packet //See RFC4880 9.2 @@ -761,13 +761,13 @@ packets (tag 1)
    diff --git a/doc/public_key_encrypted_session_key.html b/doc/public_key_encrypted_session_key.html index 448a71be..48daa951 100644 --- a/doc/public_key_encrypted_session_key.html +++ b/doc/public_key_encrypted_session_key.html @@ -40,7 +40,7 @@
    Public-Key Encrypted Session Key Packets (Tag 1)

    -RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key +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 @@ -140,13 +140,13 @@ decrypt the message.

    diff --git a/doc/public_key_encrypted_session_key.js.html b/doc/public_key_encrypted_session_key.js.html index 84a3754d..44b68f7f 100644 --- a/doc/public_key_encrypted_session_key.js.html +++ b/doc/public_key_encrypted_session_key.js.html @@ -45,7 +45,7 @@ /** * Public-Key Encrypted Session Key Packets (Tag 1)<br/> * <br/> - * RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key + * {@link http://tools.ietf.org/html/rfc4880#section-5.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 @@ -135,13 +135,13 @@ PublicKeyEncryptedSessionKey.prototype.read = function (bytes) { * The public key id corresponding to publicMPIs key as string * @param {Array<module:type/mpi>} publicMPIs * Multiprecision integer objects describing the public key - * @param {Integer} pubalgo - * The corresponding public key algorithm // See RFC4880 9.1 - * @param {Integer} symmalgo + * @param {module:enums.publicKey} pubalgo + * The corresponding public key algorithm // See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC4880 9.1} + * @param {module:enums.symmetric} symmalgo * The symmetric cipher algorithm used to encrypt the data * within an encrypteddatapacket or encryptedintegrity- * protecteddatapacket - * following this packet //See RFC4880 9.2 + * following this packet //See {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC4880 9.2} * @param {String} sessionkey * A string of randombytes representing the session key * @return {String} The string representation @@ -219,13 +219,13 @@ PublicKeyEncryptedSessionKey.prototype.decrypt = function (key) {
    diff --git a/doc/public_subkey-PublicSubkey.html b/doc/public_subkey-PublicSubkey.html index 5b29e1f7..01eb9800 100644 --- a/doc/public_subkey-PublicSubkey.html +++ b/doc/public_subkey-PublicSubkey.html @@ -125,172 +125,6 @@ -

    Methods

    - -
    - -
    -

    readPublicKey()

    - - -
    -
    - - -
    - Alias of read() -
    - - - - - - - - - -
    - - - - - - - -
    Inherited From:
    -
    - - - - - - - - - - - - - -
    Source:
    -
    - - - - - -
    See:
    -
    -
      -
    • module:packet/public_key#read
    • -
    -
    - - - -
    - - - - - - - - - - - - - -
    - - - -
    -

    writePublicKey()

    - - -
    -
    - - -
    - Alias of write() -
    - - - - - - - - - -
    - - - - - - - -
    Inherited From:
    -
    - - - - - - - - - - - - - -
    Source:
    -
    - - - - - -
    See:
    -
    -
      -
    • module:packet/public_key#write
    • -
    -
    - - - -
    - - - - - - - - - - - - - -
    - -
    - @@ -305,13 +139,13 @@
    diff --git a/doc/public_subkey.html b/doc/public_subkey.html index 843a15a5..c6ef9b44 100644 --- a/doc/public_subkey.html +++ b/doc/public_subkey.html @@ -118,13 +118,13 @@
    diff --git a/doc/public_subkey.js.html b/doc/public_subkey.js.html index 9f863d5f..5ce5a263 100644 --- a/doc/public_subkey.js.html +++ b/doc/public_subkey.js.html @@ -71,13 +71,13 @@ PublicSubkey.prototype.constructor = PublicSubkey();
    diff --git a/doc/random.html b/doc/random.html index bef958de..8597d562 100644 --- a/doc/random.html +++ b/doc/random.html @@ -717,13 +717,13 @@
    diff --git a/doc/random.js.html b/doc/random.js.html index 2d181a29..fe188662 100644 --- a/doc/random.js.html +++ b/doc/random.js.html @@ -144,13 +144,13 @@ module.exports = {
    diff --git a/doc/ripe-md.html b/doc/ripe-md.html index dd2d3b20..cd4fae90 100644 --- a/doc/ripe-md.html +++ b/doc/ripe-md.html @@ -105,13 +105,13 @@
    diff --git a/doc/ripe-md.js.html b/doc/ripe-md.js.html index 3a2faf5c..89a344ae 100644 --- a/doc/ripe-md.js.html +++ b/doc/ripe-md.js.html @@ -332,13 +332,13 @@ module.exports = RMDstring;
    diff --git a/doc/rsa.html b/doc/rsa.html index ecb87a23..948d9854 100644 --- a/doc/rsa.html +++ b/doc/rsa.html @@ -115,13 +115,13 @@
    diff --git a/doc/rsa.js.html b/doc/rsa.js.html index 29a993aa..fe13f16e 100644 --- a/doc/rsa.js.html +++ b/doc/rsa.js.html @@ -187,13 +187,13 @@ module.exports = RSA;
    diff --git a/doc/s2k-S2k.html b/doc/s2k-S2k.html index 065d213d..003c8bee 100644 --- a/doc/s2k-S2k.html +++ b/doc/s2k-S2k.html @@ -461,7 +461,7 @@ hashAlgorithm hash length
    - Parsing function for a string-to-key specifier (RFC 4880 3.7). + Parsing function for a string-to-key specifier (RFC 4880 3.7).
    @@ -696,13 +696,13 @@ hashAlgorithm hash length
    diff --git a/doc/s2k.html b/doc/s2k.html index d6a47590..8dbf2285 100644 --- a/doc/s2k.html +++ b/doc/s2k.html @@ -38,7 +38,7 @@ -
    Implementation of the String-to-key specifier (RFC4880 3.7)
    +
    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 @@ -130,13 +130,13 @@ symmetrically encrypted messages.

    diff --git a/doc/s2k.js.html b/doc/s2k.js.html index 67de5de1..50f412da 100644 --- a/doc/s2k.js.html +++ b/doc/s2k.js.html @@ -43,7 +43,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /** - * Implementation of the String-to-key specifier (RFC4880 3.7)<br/> + * Implementation of the String-to-key specifier ({@link http://tools.ietf.org/html/rfc4880#section-3.7|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 @@ -85,7 +85,7 @@ S2k.prototype.get_count = function () { }; /** - * Parsing function for a string-to-key specifier (RFC 4880 3.7). + * Parsing function for a string-to-key specifier ({@link http://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}). * @param {String} input Payload of string-to-key specifier * @return {Integer} Actual length of the object */ @@ -215,13 +215,13 @@ S2k.prototype.produce_key = function (passphrase, numBytes) {
    diff --git a/doc/secret_key-SecretKey.html b/doc/secret_key-SecretKey.html new file mode 100644 index 00000000..aa7066ef --- /dev/null +++ b/doc/secret_key-SecretKey.html @@ -0,0 +1,625 @@ + + + + + JSDoc: Class: SecretKey + + + + + + + + + + +
    + +

    Class: SecretKey

    + + + + + +
    + +
    +

    + packet/secret_key~ + + SecretKey +

    + +
    + +
    +
    + + + + +
    +

    new SecretKey()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + +

    Extends

    + + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    decrypt(str_passphrase) → {Boolean}

    + + +
    +
    + + +
    + Decrypts the private key MPIs which are needed to use the key. +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    str_passphrase + + +String + + + + The passphrase for this private key +as string
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    + True if the passphrase was correct or MPI already + decrypted; false if not +
    + + + +
    +
    + Type +
    +
    + +Boolean + + +
    +
    + + + + +
    + + + +
    +

    encrypt(passphrase)

    + + +
    +
    + + +
    + Encrypt the payload. By default, we use aes256 and iterated, salted string +to key specifier +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    passphrase + + +String + + + +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    read(bytes)

    + + +
    +
    + + +
    + Internal parser for private keys as specified in RFC 4880 section 5.5.3 +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bytes + + +String + + + + Input string to read the packet from
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    write() → {String}

    + + +
    +
    + + +
    + Creates an OpenPGP key packet for the given key. +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    + A string of bytes containing the secret key OpenPGP packet +
    + + + +
    +
    + Type +
    +
    + +String + + +
    +
    + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + + + +
    + + + + + + + \ No newline at end of file diff --git a/doc/secret_key.html b/doc/secret_key.html index 08126c73..29b0017c 100644 --- a/doc/secret_key.html +++ b/doc/secret_key.html @@ -35,83 +35,17 @@
    + +
    Implementation of the Key Material Packet (Tag 5,6,7,14)

    -RFC4480 5.5: +RFC4480 5.5: A key material packet contains all the information about a public or private key. There are four variants of this packet type, and two major versions. Consequently, this section is complex.
    -
    -

    new (require("packet/secret_key"))()

    - - -
    -
    - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    Source:
    -
    - - - - - - - -
    - - - - - - - - - - - - - -
    - - - - - -
    @@ -174,182 +108,23 @@ major versions. Consequently, this section is complex.
    - - - - - - -

    Methods

    +

    Classes

    - -
    -

    readPublicKey()

    - - -
    -
    - - -
    - Alias of read() -
    - - - - - - - - - -
    - - - - - - - -
    Inherited From:
    -
    - - - - - - - - - - - - - -
    Source:
    -
    - - - - - -
    See:
    -
    -
      -
    • module:packet/public_key#read
    • -
    -
    - - - -
    - - - - - - - - - - - - - -
    - - - -
    -

    writePublicKey()

    - - -
    -
    - - -
    - Alias of write() -
    - - - - - - - - - -
    - - - - - - - -
    Inherited From:
    -
    - - - - - - - - - - - - - -
    Source:
    -
    - - - - - -
    See:
    -
    -
      -
    • module:packet/public_key#write
    • -
    -
    - - - -
    - - - - - - - - - - - - - -
    - +
    SecretKey
    +
    + + + + + +
    @@ -360,13 +135,13 @@ major versions. Consequently, this section is complex.
    diff --git a/doc/secret_key.js.html b/doc/secret_key.js.html index 2adff1a8..c33b622f 100644 --- a/doc/secret_key.js.html +++ b/doc/secret_key.js.html @@ -45,7 +45,7 @@ /** * Implementation of the Key Material Packet (Tag 5,6,7,14)<br/> * <br/> - * RFC4480 5.5: + * {@link http://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}: * A key material packet contains all the information about a public or * private key. There are four variants of this packet type, and two * major versions. Consequently, this section is complex. @@ -58,6 +58,8 @@ * @module packet/secret_key */ +module.exports = SecretKey; + var publicKey = require('./public_key.js'), enums = require('../enums.js'), util = require('../util'), @@ -69,8 +71,6 @@ var publicKey = require('./public_key.js'), * @constructor * @extends module:packet/public_key */ -module.exports = SecretKey; - function SecretKey() { publicKey.call(this); // encrypted secret-key data @@ -143,7 +143,7 @@ function write_cleartext_mpi(hash_algorithm, algorithm, mpi) { // 5.5.3. Secret-Key Packet Formats /** - * Internal parser for private keys as specified in RFC 4880 section 5.5.3 + * Internal parser for private keys as specified in {@link http://tools.ietf.org/html/rfc4880#section-5.5.3|RFC 4880 section 5.5.3} * @param {String} bytes Input string to read the packet from */ SecretKey.prototype.read = function (bytes) { @@ -302,13 +302,13 @@ SecretKey.prototype.generate = function (bits) {
    diff --git a/doc/secret_subkey-SecretSubkey.html b/doc/secret_subkey-SecretSubkey.html index 361f45ed..3a185410 100644 --- a/doc/secret_subkey-SecretSubkey.html +++ b/doc/secret_subkey-SecretSubkey.html @@ -125,172 +125,6 @@ -

    Methods

    - -
    - -
    -

    readPublicKey()

    - - -
    -
    - - -
    - Alias of read() -
    - - - - - - - - - -
    - - - - - - - -
    Inherited From:
    -
    - - - - - - - - - - - - - -
    Source:
    -
    - - - - - -
    See:
    -
    -
      -
    • module:packet/public_key#read
    • -
    -
    - - - -
    - - - - - - - - - - - - - -
    - - - -
    -

    writePublicKey()

    - - -
    -
    - - -
    - Alias of write() -
    - - - - - - - - - -
    - - - - - - - -
    Inherited From:
    -
    - - - - - - - - - - - - - -
    Source:
    -
    - - - - - -
    See:
    -
    -
      -
    • module:packet/public_key#write
    • -
    -
    - - - -
    - - - - - - - - - - - - - -
    - -
    - @@ -305,13 +139,13 @@
    diff --git a/doc/secret_subkey.html b/doc/secret_subkey.html index 39badac9..d3402af0 100644 --- a/doc/secret_subkey.html +++ b/doc/secret_subkey.html @@ -118,13 +118,13 @@
    diff --git a/doc/secret_subkey.js.html b/doc/secret_subkey.js.html index 870092aa..078c475f 100644 --- a/doc/secret_subkey.js.html +++ b/doc/secret_subkey.js.html @@ -71,13 +71,13 @@ SecretSubkey.prototype.constructor = SecretSubkey;
    diff --git a/doc/sha.html b/doc/sha.html index 5201169c..a28efe2e 100644 --- a/doc/sha.html +++ b/doc/sha.html @@ -454,13 +454,13 @@
    diff --git a/doc/sha.js.html b/doc/sha.js.html index 93756caf..2562a03c 100644 --- a/doc/sha.js.html +++ b/doc/sha.js.html @@ -1160,13 +1160,13 @@ module.exports = {
    diff --git a/doc/signature-Signature.html b/doc/signature-Signature.html index 4c69ffc5..c02ae4c8 100644 --- a/doc/signature-Signature.html +++ b/doc/signature-Signature.html @@ -812,13 +812,13 @@
    diff --git a/doc/signature.html b/doc/signature.html index cc880dfa..cf2596a9 100644 --- a/doc/signature.html +++ b/doc/signature.html @@ -154,7 +154,7 @@ -Integer +module:enums.hash @@ -164,7 +164,7 @@ - hash Algorithm to use (See RFC4880 9.4) + hash Algorithm to use (See RFC 4880 9.4) @@ -177,7 +177,7 @@ -Integer +module:enums.publicKey @@ -187,7 +187,7 @@ - Asymmetric cipher algorithm to use (See RFC4880 9.1) + Asymmetric cipher algorithm to use (See RFC 4880 9.1) @@ -379,7 +379,7 @@ integers which is used to sign the data -Integer +module:enums.publicKey @@ -402,7 +402,7 @@ integers which is used to sign the data -Integer +module:enums.hash @@ -575,13 +575,13 @@ integers which is used to sign the data
    diff --git a/doc/signature.js.html b/doc/signature.js.html index 2af0695c..03677875 100644 --- a/doc/signature.js.html +++ b/doc/signature.js.html @@ -38,8 +38,8 @@ var publicKey = require('./public_key'), module.exports = { /** * - * @param {Integer} algo public Key algorithm - * @param {Integer} hash_algo Hash algorithm + * @param {module:enums.publicKey} algo public Key algorithm + * @param {module:enums.hash} hash_algo Hash algorithm * @param {Array<module:type/mpi>} msg_MPIs Signature multiprecision integers * @param {Array<module:type/mpi>} publickey_MPIs Public key multiprecision integers * @param {String} data Data on where the signature was computed on. @@ -89,8 +89,8 @@ module.exports = { /** * Create a signature on data using the specified algorithm - * @param {Integer} hash_algo hash Algorithm to use (See RFC4880 9.4) - * @param {Integer} algo Asymmetric cipher algorithm to use (See RFC4880 9.1) + * @param {module:enums.hash} hash_algo hash Algorithm to use (See {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}) + * @param {module:enums.publicKey} algo Asymmetric cipher algorithm to use (See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1}) * @param {Array<module:type/mpi>} publicMPIs Public key multiprecision integers * of the private key * @param {Array<module:type/mpi>} secretMPIs Private key multiprecision @@ -148,13 +148,13 @@ module.exports = {
    diff --git a/doc/signature.js_.html b/doc/signature.js_.html index 4e5a7aa0..0111595b 100644 --- a/doc/signature.js_.html +++ b/doc/signature.js_.html @@ -45,7 +45,7 @@ /** * Implementation of the Signature Packet (Tag 2)<br/> * <br/> - * RFC4480 5.2: + * {@link http://tools.ietf.org/html/rfc4880#section-5.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. @@ -363,11 +363,11 @@ Signature.prototype.write_all_sub_packets = function () { }; /** - * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) + * creates a string representation of a sub signature packet (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.3.1|RFC 4880 5.2.3.1}) * @param {Integer} type subpacket signature type. Signature types as described - * in RFC4880 Section 5.2.3.2 + * in {@link http://tools.ietf.org/html/rfc4880#section-5.2.3.2|RFC4880 Section 5.2.3.2} * @param {String} data data to be included - * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) + * @return {String} a string-representation of a sub signature packet (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.3.1|RFC 4880 5.2.3.1}) */ function write_sub_packet(type, data) { var result = ""; @@ -675,13 +675,13 @@ Signature.prototype.isExpired = function () {
    diff --git a/doc/signature_.html b/doc/signature_.html index 917e8717..929a055a 100644 --- a/doc/signature_.html +++ b/doc/signature_.html @@ -40,7 +40,7 @@
    Implementation of the Signature Packet (Tag 2)

    -RFC4480 5.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.
    @@ -134,7 +134,7 @@ block of text, and a signature that is a certification of a User ID.
    - creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) + creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1)
    @@ -185,7 +185,7 @@ block of text, and a signature that is a certification of a User ID. subpacket signature type. Signature types as described -in RFC4880 Section 5.2.3.2 +in RFC4880 Section 5.2.3.2 @@ -264,7 +264,7 @@ in RFC4880 Section 5.2.3.2
    - a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) + a string-representation of a sub signature packet (See RFC 4880 5.2.3.1)
    @@ -302,13 +302,13 @@ in RFC4880 Section 5.2.3.2
    diff --git a/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html b/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html index 6686e458..083fc01f 100644 --- a/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html +++ b/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html @@ -78,7 +78,7 @@
    Source:
    @@ -158,7 +158,7 @@
    Source:
    @@ -224,7 +224,7 @@ should be discarded.
    Source:
    @@ -297,7 +297,7 @@ have been called before -Integer +module:enums.symmetric @@ -361,7 +361,7 @@ have been called before
    Source:
    @@ -424,13 +424,13 @@ have been called before
    diff --git a/doc/sym_encrypted_integrity_protected.html b/doc/sym_encrypted_integrity_protected.html index 613fb3bc..b1752a2d 100644 --- a/doc/sym_encrypted_integrity_protected.html +++ b/doc/sym_encrypted_integrity_protected.html @@ -41,7 +41,8 @@
    Implementation of the Sym. Encrypted Integrity Protected Data Packet (Tag 18)

    -RFC4880 5.13: The Symmetrically Encrypted Integrity Protected Data packet is +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 @@ -129,13 +130,13 @@ packet.

    diff --git a/doc/sym_encrypted_integrity_protected.js.html b/doc/sym_encrypted_integrity_protected.js.html index a373805f..e4f083ae 100644 --- a/doc/sym_encrypted_integrity_protected.js.html +++ b/doc/sym_encrypted_integrity_protected.js.html @@ -46,7 +46,8 @@ * Implementation of the Sym. Encrypted Integrity Protected Data * Packet (Tag 18)<br/> * <br/> - * RFC4880 5.13: The Symmetrically Encrypted Integrity Protected Data packet is + * {@link http://tools.ietf.org/html/rfc4880#section-5.13|RFC4880 5.13}: + * The Symmetrically Encrypted Integrity Protected Data packet is * a variant of the Symmetrically Encrypted Data packet. It is a new feature * created for OpenPGP that addresses the problem of detecting a modification to * encrypted data. It is used in combination with a Modification Detection Code @@ -124,7 +125,7 @@ SymEncryptedIntegrityProtected.prototype.encrypt = function (sessionKeyAlgorithm * Decrypts the encrypted data contained in this object read_packet must * have been called before * - * @param {Integer} sessionKeyAlgorithm + * @param {module:enums.symmetric} sessionKeyAlgorithm * The selected symmetric encryption algorithm to be used * @param {String} key The key of cipher blocksize length to be used * @return {String} The decrypted data of this packet @@ -157,13 +158,13 @@ SymEncryptedIntegrityProtected.prototype.decrypt = function (sessionKeyAlgorithm
    diff --git a/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html b/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html index 38254e0a..d52f4b7b 100644 --- a/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html +++ b/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html @@ -415,13 +415,13 @@ packets (tag 1)
    diff --git a/doc/sym_encrypted_session_key.html b/doc/sym_encrypted_session_key.html index 4b0c86f6..0e6aba3c 100644 --- a/doc/sym_encrypted_session_key.html +++ b/doc/sym_encrypted_session_key.html @@ -40,7 +40,7 @@
    Public-Key Encrypted Session Key Packets (Tag 1)

    -RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key +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 @@ -136,13 +136,13 @@ decrypt the message.

    diff --git a/doc/sym_encrypted_session_key.js.html b/doc/sym_encrypted_session_key.js.html index 5472e3f0..43f0be8d 100644 --- a/doc/sym_encrypted_session_key.js.html +++ b/doc/sym_encrypted_session_key.js.html @@ -45,7 +45,7 @@ /** * Public-Key Encrypted Session Key Packets (Tag 1)<br/> * <br/> - * RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key + * {@link http://tools.ietf.org/html/rfc4880#section-5.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 @@ -177,13 +177,13 @@ SymEncryptedSessionKey.prototype.encrypt = function(passphrase) {
    diff --git a/doc/symmetrically_encrypted-SymmetricallyEncrypted.html b/doc/symmetrically_encrypted-SymmetricallyEncrypted.html index 3a76d4ca..6ac393f9 100644 --- a/doc/symmetrically_encrypted-SymmetricallyEncrypted.html +++ b/doc/symmetrically_encrypted-SymmetricallyEncrypted.html @@ -240,7 +240,7 @@ -Integer +module:enums.symmetric @@ -250,7 +250,7 @@ - Symmetric key algorithm to use // See RFC4880 9.2 + Symmetric key algorithm to use // See RFC4880 9.2 @@ -346,13 +346,13 @@
    diff --git a/doc/symmetrically_encrypted.html b/doc/symmetrically_encrypted.html index bd15c959..a2e811ad 100644 --- a/doc/symmetrically_encrypted.html +++ b/doc/symmetrically_encrypted.html @@ -40,7 +40,7 @@
    Implementation of the Symmetrically Encrypted Data Packet (Tag 9)

    -RFC4880 5.7: The Symmetrically Encrypted Data packet contains data encrypted +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 @@ -126,13 +126,13 @@ that form whole OpenPGP messages).

    diff --git a/doc/symmetrically_encrypted.js.html b/doc/symmetrically_encrypted.js.html index 3299e661..c7c2ac5a 100644 --- a/doc/symmetrically_encrypted.js.html +++ b/doc/symmetrically_encrypted.js.html @@ -45,7 +45,7 @@ /** * Implementation of the Symmetrically Encrypted Data Packet (Tag 9)<br/> * <br/> - * RFC4880 5.7: The Symmetrically Encrypted Data packet contains data encrypted + * {@link http://tools.ietf.org/html/rfc4880#section-5.7|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 @@ -79,8 +79,8 @@ SymmetricallyEncrypted.prototype.write = function () { /** * Symmetrically decrypt the packet data * - * @param {Integer} sessionKeyAlgorithm - * Symmetric key algorithm to use // See RFC4880 9.2 + * @param {module:enums.symmetric} sessionKeyAlgorithm + * Symmetric key algorithm to use // See {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC4880 9.2} * @param {String} key * Key as string with the corresponding length to the * algorithm @@ -108,13 +108,13 @@ SymmetricallyEncrypted.prototype.encrypt = function (algo, key) {
    diff --git a/doc/trust-Trust.html b/doc/trust-Trust.html index 356ff365..ae7d8bba 100644 --- a/doc/trust-Trust.html +++ b/doc/trust-Trust.html @@ -133,13 +133,13 @@
    diff --git a/doc/trust.html b/doc/trust.html index 91b95d0a..8203a7d5 100644 --- a/doc/trust.html +++ b/doc/trust.html @@ -112,13 +112,13 @@
    diff --git a/doc/trust.js.html b/doc/trust.js.html index 58fe327b..80bed661 100644 --- a/doc/trust.js.html +++ b/doc/trust.js.html @@ -46,13 +46,13 @@ function Trust() {
    diff --git a/doc/twofish.html b/doc/twofish.html index 2251f994..55b7aeff 100644 --- a/doc/twofish.html +++ b/doc/twofish.html @@ -105,13 +105,13 @@
    diff --git a/doc/twofish.js.html b/doc/twofish.js.html index 0990593f..4ecdb7e8 100644 --- a/doc/twofish.js.html +++ b/doc/twofish.js.html @@ -417,13 +417,13 @@ module.exports.blockSize = TF.prototype.blockSize = 16;
    diff --git a/doc/user_attribute-UserAttribute.html b/doc/user_attribute-UserAttribute.html index 9359634d..bed1b121 100644 --- a/doc/user_attribute-UserAttribute.html +++ b/doc/user_attribute-UserAttribute.html @@ -254,13 +254,13 @@
    diff --git a/doc/user_attribute.html b/doc/user_attribute.html index ac0dc217..38cabb6b 100644 --- a/doc/user_attribute.html +++ b/doc/user_attribute.html @@ -129,13 +129,13 @@ module packet/user_attribute
    diff --git a/doc/user_attribute.js.html b/doc/user_attribute.js.html index d08ac87e..8b6d573e 100644 --- a/doc/user_attribute.js.html +++ b/doc/user_attribute.js.html @@ -98,13 +98,13 @@ UserAttribute.prototype.read = function(bytes) {
    diff --git a/doc/userid-Userid.html b/doc/userid-Userid.html index f6e65104..1d7b2974 100644 --- a/doc/userid-Userid.html +++ b/doc/userid-Userid.html @@ -414,13 +414,13 @@ John Doe
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/userid.html b/doc/userid.html index 16e61556..8df5bc2d 100644 --- a/doc/userid.html +++ b/doc/userid.html @@ -126,13 +126,13 @@ specifies the length of the User ID.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/userid.js.html b/doc/userid.js.html index 546814c8..159e63df 100644 --- a/doc/userid.js.html +++ b/doc/userid.js.html @@ -94,13 +94,13 @@ Userid.prototype.write = function () {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/doc/util.html b/doc/util.html index 7ed3dbba..d3d58dc7 100644 --- a/doc/util.html +++ b/doc/util.html @@ -2000,13 +2000,13 @@ the same as bin2str.
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:19 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:49 GMT-0800 (PST)
    diff --git a/doc/util.js.html b/doc/util.js.html index 42cb0bec..ca36f424 100644 --- a/doc/util.js.html +++ b/doc/util.js.html @@ -339,13 +339,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 13:32:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.0 on Sun Jan 05 2014 23:07:43 GMT-0800 (PST)
    diff --git a/src/cleartext.js b/src/cleartext.js index 4d9a4c95..4c1604ae 100644 --- a/src/cleartext.js +++ b/src/cleartext.js @@ -31,7 +31,7 @@ var config = require('./config'), /** * @class * @classdesc Class that represents an OpenPGP cleartext signed message. - * See http://tools.ietf.org/html/rfc4880#section-7 + * See {@link http://tools.ietf.org/html/rfc4880#section-7} * @param {String} text The cleartext of the signed message * @param {module:packet/packetlist} packetlist The packetlist with signature packets or undefined * if message not yet signed diff --git a/src/crypto/cfb.js b/src/crypto/cfb.js index 939d7d24..f28218bf 100644 --- a/src/crypto/cfb.js +++ b/src/crypto/cfb.js @@ -32,7 +32,7 @@ module.exports = { * @param {String} prefixrandom random bytes of block_size length provided * as a string to be used in prefixing the data * @param {String} cipherfn the algorithm cipher class to encrypt - * data in one block_size encryption, @see module:crypto/cipher. + * data in one block_size encryption, {@link module:crypto/cipher}. * @param {String} plaintext data to be encrypted provided as a string * @param {String} key binary string representation of key to be used to encrypt the plaintext. * This will be passed to the cipherfn @@ -174,7 +174,7 @@ module.exports = { * This function decrypts a given plaintext using the specified * blockcipher to decrypt a message * @param {String} cipherfn the algorithm cipher class to decrypt - * data in one block_size encryption, @see module:crypto/cipher. + * data in one block_size encryption, {@link 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 diff --git a/src/crypto/crypto.js b/src/crypto/crypto.js index d6760ba7..8537123e 100644 --- a/src/crypto/crypto.js +++ b/src/crypto/crypto.js @@ -34,7 +34,7 @@ module.exports = { /** * Encrypts data using the specified public key multiprecision integers * and the specified algorithm. - * @param {Integer} algo Algorithm to be used (See RFC4880 9.1) + * @param {module:enums.publicKey} algo Algorithm to be used (See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1}) * @param {Array} publicMPIs Algorithm dependent multiprecision integers * @param {module:type/mpi} data Data to be encrypted as MPI * @return {Array} if RSA an module:type/mpi; @@ -75,7 +75,7 @@ module.exports = { /** * Decrypts data using the specified public key multiprecision integers of the private key, * the specified secretMPIs of the private key and the specified algorithm. - * @param {Integer} algo Algorithm to be used (See RFC4880 9.1) + * @param {module:enums.publicKey} algo Algorithm to be used (See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1}) * @param {Array} publicMPIs Algorithm dependent multiprecision integers * of the public key part of the private key * @param {Array} secretMPIs Algorithm dependent multiprecision integers @@ -207,7 +207,7 @@ module.exports = { /** * generate random byte prefix as string for the specified algorithm - * @param {Integer} algo Algorithm to use (see RFC4880 9.2) + * @param {module:enums.symmetric} algo Algorithm to use (see {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC 4880 9.2}) * @return {String} Random bytes with length equal to the block * size of the cipher */ @@ -217,7 +217,7 @@ module.exports = { /** * Generating a session key for the specified symmetric algorithm - * @param {Integer} algo Algorithm to use (see RFC4880 9.2) + * @param {module:enums.symmetric} algo Algorithm to use (see {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC 4880 9.2}) * @return {String} Random bytes as a string to be used as a key */ generateSessionKey: function(algo) { diff --git a/src/crypto/hash/index.js b/src/crypto/hash/index.js index 7086e037..9dcd6a99 100644 --- a/src/crypto/hash/index.js +++ b/src/crypto/hash/index.js @@ -22,7 +22,7 @@ module.exports = { /** * Create a hash on the specified data using the specified algorithm - * @param {Integer} algo Hash algorithm type (see RFC4880 9.4) + * @param {module:enums.hash} algo Hash algorithm type (see {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}) * @param {String} data Data to be hashed * @return {String} hash value */ @@ -56,7 +56,7 @@ module.exports = { /** * Returns the hash size in bytes of the specified hash algorithm type - * @param {Integer} algo Hash algorithm type (See RFC4880 9.4) + * @param {module:enums.hash} algo Hash algorithm type (See {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}) * @return {Integer} Size in bytes of the resulting hash */ getHashByteLength: function(algo) { diff --git a/src/crypto/pkcs1.js b/src/crypto/pkcs1.js index 330da878..3d70ebe7 100644 --- a/src/crypto/pkcs1.js +++ b/src/crypto/pkcs1.js @@ -26,7 +26,7 @@ */ /** - * ASN1 object identifiers for hashes (See RFC4880 5.2.2) + * ASN1 object identifiers for hashes (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.2}) */ hash_headers = []; hash_headers[1] = [0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, @@ -56,7 +56,7 @@ var crypto = require('./crypto.js'), module.exports = { eme: { /** - * create a EME-PKCS1-v1_5 padding (See RFC4880 13.1.1) + * create a EME-PKCS1-v1_5 padding (See {@link http://tools.ietf.org/html/rfc4880#section-13.1.1|RFC 4880 13.1.1}) * @param {String} message message to be padded * @param {Integer} length Length to the resulting message * @return {String} EME-PKCS1 padded message @@ -76,9 +76,9 @@ module.exports = { }, /** - * decodes a EME-PKCS1-v1_5 padding (See RFC4880 13.1.2) + * decodes a EME-PKCS1-v1_5 padding (See {@link http://tools.ietf.org/html/rfc4880#section-13.1.2|RFC 4880 13.1.2}) * @param {String} message EME-PKCS1 padded message - * @return {String} decoded message + * @return {String} decoded message */ decode: function(message, len) { if (message.length < len) @@ -95,7 +95,7 @@ module.exports = { emsa: { /** - * create a EMSA-PKCS1-v1_5 padding (See RFC4880 13.1.3) + * create a EMSA-PKCS1-v1_5 padding (See {@link http://tools.ietf.org/html/rfc4880#section-13.1.3|RFC 4880 13.1.3}) * @param {Integer} algo Hash algorithm type used * @param {String} data Data to be hashed * @param {Integer} keylength Key size of the public mpi in bytes @@ -121,7 +121,7 @@ module.exports = { }, /** - * extract the hash out of an EMSA-PKCS1-v1.5 padding (See RFC4880 13.1.3) + * extract the hash out of an EMSA-PKCS1-v1.5 padding (See {@link http://tools.ietf.org/html/rfc4880#section-13.1.3|RFC 4880 13.1.3}) * @param {String} data Hash in pkcs1 encoding * @returns {String} The hash as string */ diff --git a/src/crypto/signature.js b/src/crypto/signature.js index 930d7baa..664329be 100644 --- a/src/crypto/signature.js +++ b/src/crypto/signature.js @@ -11,8 +11,8 @@ var publicKey = require('./public_key'), module.exports = { /** * - * @param {Integer} algo public Key algorithm - * @param {Integer} hash_algo Hash algorithm + * @param {module:enums.publicKey} algo public Key algorithm + * @param {module:enums.hash} hash_algo Hash algorithm * @param {Array} msg_MPIs Signature multiprecision integers * @param {Array} publickey_MPIs Public key multiprecision integers * @param {String} data Data on where the signature was computed on. @@ -62,8 +62,8 @@ module.exports = { /** * Create a signature on data using the specified algorithm - * @param {Integer} hash_algo hash Algorithm to use (See RFC4880 9.4) - * @param {Integer} algo Asymmetric cipher algorithm to use (See RFC4880 9.1) + * @param {module:enums.hash} hash_algo hash Algorithm to use (See {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}) + * @param {module:enums.publicKey} algo Asymmetric cipher algorithm to use (See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1}) * @param {Array} publicMPIs Public key multiprecision integers * of the private key * @param {Array} secretMPIs Private key multiprecision diff --git a/src/enums.js b/src/enums.js index b41ca639..f1eb61b1 100644 --- a/src/enums.js +++ b/src/enums.js @@ -15,7 +15,7 @@ module.exports = { gnu: 101 }, - /** RFC4880, section 9.1 + /** {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC4880, section 9.1} * @enum {Integer} * @readonly */ @@ -27,7 +27,7 @@ module.exports = { dsa: 17 }, - /** RFC4880, section 9.2 + /** {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2} * @enum {Integer} * @readonly */ @@ -44,7 +44,7 @@ module.exports = { twofish: 10 }, - /** RFC4880, section 9.3 + /** {@link http://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3} * @enum {Integer} * @readonly */ @@ -57,7 +57,7 @@ module.exports = { bzip2: 3 }, - /** RFC4880, section 9.4 + /** {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4} * @enum {Integer} * @readonly */ diff --git a/src/key.js b/src/key.js index cb9b32f4..9bf95f89 100644 --- a/src/key.js +++ b/src/key.js @@ -423,7 +423,7 @@ Key.prototype.verifyPrimaryKey = function() { return enums.keyStatus.expired; } // check for at least one self signature. Self signature of user ID not mandatory - // See http://tools.ietf.org/html/rfc4880#section-11.1 + // See {@link 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) { @@ -708,8 +708,8 @@ function readArmored(armoredText) { /** * Generates a new OpenPGP key. Currently only supports RSA keys. * Primary and subkey will be of same type. - * @param {Integer} keyType to indicate what type of key to make. - * RSA is 1. See http://tools.ietf.org/html/rfc4880#section-9.1 + * @param {module:enums.publicKey} keyType to indicate what type of key to make. + * RSA is 1. See {@link http://tools.ietf.org/html/rfc4880#section-9.1} * @param {Integer} numBits number of bits for the key creation. * @param {String} userId assumes already in form of "User Name " * @param {String} passphrase The passphrase used to encrypt the resulting private key diff --git a/src/message.js b/src/message.js index 111c04a2..7fee348c 100644 --- a/src/message.js +++ b/src/message.js @@ -35,7 +35,7 @@ var packet = require('./packet'), * @classdesc Class that represents an OpenPGP message. * Can be an encrypted message, signed message, compressed message or literal message * @param {module:packet/packetlist} packetlist The packets that form this message - * See http://tools.ietf.org/html/rfc4880#section-11.3 + * See {@link http://tools.ietf.org/html/rfc4880#section-11.3} */ function Message(packetlist) { diff --git a/src/openpgp.js b/src/openpgp.js index a3308eac..8fa44259 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -138,8 +138,8 @@ function verifyClearSignedMessage(publicKeys, message) { /** * Generates a new OpenPGP key pair. Currently only supports RSA keys. * Primary and subkey will be of same type. - * @param {Integer} keyType to indicate what type of key to make. - * RSA is 1. See http://tools.ietf.org/html/rfc4880#section-9.1 + * @param {module:enums.publicKey} keyType to indicate what type of key to make. + * RSA is 1. See {@link http://tools.ietf.org/html/rfc4880#section-9.1} * @param {Integer} numBits number of bits for the key creation. (should be 1024+, generally) * @param {String} userId assumes already in form of "User Name " * @param {String} passphrase The passphrase used to encrypt the resulting private key diff --git a/src/packet/all_packets.js b/src/packet/all_packets.js index 48ed71f3..9f743830 100644 --- a/src/packet/all_packets.js +++ b/src/packet/all_packets.js @@ -39,17 +39,27 @@ module.exports = { Signature: require('./signature.js'), /** @see module:packet/trust */ Trust: require('./trust.js'), - + /** + * Allocate a new packet + * @param {String} tag property name from {@link module:enums.packet} + * @returns {Object} new packet object with type based on tag + */ newPacketFromTag: function (tag) { - return new this[packetClassFromTag(tag)](); + return new this[packetClassFromTagName(tag)](); } }; -function packetClassFromTag(tag) { +/** + * Convert tag name to class name + * @param {String} tag property name from {@link module:enums.packet} + * @returns {String} + */ +function packetClassFromTagName(tag) { return tag.substr(0, 1).toUpperCase() + tag.substr(1); } + for (var i in enums.packet) { - var packetClass = module.exports[packetClassFromTag(i)]; + var packetClass = module.exports[packetClassFromTagName(i)]; if (packetClass !== undefined) packetClass.prototype.tag = enums.packet[i]; diff --git a/src/packet/compressed.js b/src/packet/compressed.js index f0687ed9..3b80e9ba 100644 --- a/src/packet/compressed.js +++ b/src/packet/compressed.js @@ -18,7 +18,7 @@ /** * Implementation of the Compressed Data Packet (Tag 8)
    *
    - * RFC4880 5.6: The Compressed Data packet contains compressed data. Typically, + * {@link http://tools.ietf.org/html/rfc4880#section-5.6|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 diff --git a/src/packet/index.js b/src/packet/index.js index 2e62eba6..be4e31f2 100644 --- a/src/packet/index.js +++ b/src/packet/index.js @@ -1,6 +1,10 @@ var enums = require('../enums.js'); module.exports = { + /** + * @name module:packet.List + * @see module:packet/packetlist + */ List: require('./packetlist.js') }; diff --git a/src/packet/literal.js b/src/packet/literal.js index 17e76ca6..130f2162 100644 --- a/src/packet/literal.js +++ b/src/packet/literal.js @@ -18,7 +18,7 @@ /** * Implementation of the Literal Data Packet (Tag 11)
    *
    - * RFC4880 5.9: A Literal Data packet contains the body of a message; data that + * {@link http://tools.ietf.org/html/rfc4880#section-5.9|RFC4880 5.9}: A Literal Data packet contains the body of a message; data that * is not to be further interpreted. * @requires enums * @requires util diff --git a/src/packet/marker.js b/src/packet/marker.js index fd38986e..75ee8a77 100644 --- a/src/packet/marker.js +++ b/src/packet/marker.js @@ -19,7 +19,7 @@ /** * Implementation of the strange "Marker packet" (Tag 10)
    *
    - * RFC4880 5.8: An experimental version of PGP used this packet as the Literal + * {@link http://tools.ietf.org/html/rfc4880#section-5.8|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.
    diff --git a/src/packet/one_pass_signature.js b/src/packet/one_pass_signature.js index 33781f07..d5f53a9d 100644 --- a/src/packet/one_pass_signature.js +++ b/src/packet/one_pass_signature.js @@ -18,8 +18,7 @@ /** * Implementation of the One-Pass Signature Packets (Tag 4)
    *
    - * RFC4880 5.4: - * The One-Pass Signature packet precedes the signed data and contains + * {@link http://tools.ietf.org/html/rfc4880#section-5.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 @@ -39,9 +38,9 @@ var enums = require('../enums.js'), */ function OnePassSignature() { this.version = null; // A one-octet version number. The current version is 3. - this.type = null; // A one-octet signature type. Signature types are described in RFC4880 Section 5.2.1. - this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See RFC4880 9.4) - this.publicKeyAlgorithm = null; // A one-octet number describing the public-key algorithm used. (See RFC4880 9.1) + this.type = null; // A one-octet signature type. Signature types are described in {@link http://tools.ietf.org/html/rfc4880#section-5.2.1|RFC4880 Section 5.2.1}. + this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See {@link http://tools.ietf.org/html/rfc4880#section-9.4|RFC4880 9.4}) + this.publicKeyAlgorithm = null; // A one-octet number describing the public-key algorithm used. (See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC4880 9.1}) this.signingKeyId = null; // An eight-octet number holding the Key ID of the signing key. this.flags = null; // A one-octet number holding a flag showing whether the signature is nested. A zero value indicates that the next packet is another One-Pass Signature packet that describes another signature to be applied to the same message data. } diff --git a/src/packet/public_key.js b/src/packet/public_key.js index 1be16ce2..5fa835af 100644 --- a/src/packet/public_key.js +++ b/src/packet/public_key.js @@ -18,7 +18,7 @@ /** * Implementation of the Key Material Packet (Tag 5,6,7,14)
    *
    - * RFC4480 5.5: + * {@link http://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}: * A key material packet contains all the information about a public or * private key. There are four variants of this packet type, and two * major versions. Consequently, this section is complex. @@ -57,8 +57,7 @@ function PublicKey() { } /** - * Internal Parser for public keys as specified in RFC 4880 section - * 5.5.2 Public-Key Packet Formats + * Internal Parser for public keys as specified in {@link http://tools.ietf.org/html/rfc4880#section-5.5.2|RFC 4880 section 5.5.2 Public-Key Packet Formats} * called by read_tag<num> * @param {String} input Input string to read the packet from * @return {Object} This object with attributes set by the parser @@ -108,8 +107,7 @@ PublicKey.prototype.read = function (bytes) { /** * Alias of read() - * @function module:packet/public_key#readPublicKey - * @see module:packet/public_key#read + * @see module:packet/public_key~PublicKey#read */ PublicKey.prototype.readPublicKey = PublicKey.prototype.read; @@ -139,8 +137,7 @@ PublicKey.prototype.write = function () { /** * Alias of write() - * @function module:packet/public_key#writePublicKey - * @see module:packet/public_key#write + * @see module:packet/public_key~PublicKey#write */ PublicKey.prototype.writePublicKey = PublicKey.prototype.write; diff --git a/src/packet/public_key_encrypted_session_key.js b/src/packet/public_key_encrypted_session_key.js index 5fc27097..bac2168b 100644 --- a/src/packet/public_key_encrypted_session_key.js +++ b/src/packet/public_key_encrypted_session_key.js @@ -18,7 +18,7 @@ /** * Public-Key Encrypted Session Key Packets (Tag 1)
    *
    - * RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key + * {@link http://tools.ietf.org/html/rfc4880#section-5.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 @@ -108,13 +108,13 @@ PublicKeyEncryptedSessionKey.prototype.read = function (bytes) { * The public key id corresponding to publicMPIs key as string * @param {Array} publicMPIs * Multiprecision integer objects describing the public key - * @param {Integer} pubalgo - * The corresponding public key algorithm // See RFC4880 9.1 - * @param {Integer} symmalgo + * @param {module:enums.publicKey} pubalgo + * The corresponding public key algorithm // See {@link http://tools.ietf.org/html/rfc4880#section-9.1|RFC4880 9.1} + * @param {module:enums.symmetric} symmalgo * The symmetric cipher algorithm used to encrypt the data * within an encrypteddatapacket or encryptedintegrity- * protecteddatapacket - * following this packet //See RFC4880 9.2 + * following this packet //See {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC4880 9.2} * @param {String} sessionkey * A string of randombytes representing the session key * @return {String} The string representation diff --git a/src/packet/secret_key.js b/src/packet/secret_key.js index 243e9baa..39b7e756 100644 --- a/src/packet/secret_key.js +++ b/src/packet/secret_key.js @@ -18,7 +18,7 @@ /** * Implementation of the Key Material Packet (Tag 5,6,7,14)
    *
    - * RFC4480 5.5: + * {@link http://tools.ietf.org/html/rfc4880#section-5.5|RFC4480 5.5}: * A key material packet contains all the information about a public or * private key. There are four variants of this packet type, and two * major versions. Consequently, this section is complex. @@ -31,6 +31,8 @@ * @module packet/secret_key */ +module.exports = SecretKey; + var publicKey = require('./public_key.js'), enums = require('../enums.js'), util = require('../util'), @@ -42,8 +44,6 @@ var publicKey = require('./public_key.js'), * @constructor * @extends module:packet/public_key */ -module.exports = SecretKey; - function SecretKey() { publicKey.call(this); // encrypted secret-key data @@ -116,7 +116,7 @@ function write_cleartext_mpi(hash_algorithm, algorithm, mpi) { // 5.5.3. Secret-Key Packet Formats /** - * Internal parser for private keys as specified in RFC 4880 section 5.5.3 + * Internal parser for private keys as specified in {@link http://tools.ietf.org/html/rfc4880#section-5.5.3|RFC 4880 section 5.5.3} * @param {String} bytes Input string to read the packet from */ SecretKey.prototype.read = function (bytes) { diff --git a/src/packet/signature.js b/src/packet/signature.js index c6f15df3..4c6abfc2 100644 --- a/src/packet/signature.js +++ b/src/packet/signature.js @@ -18,7 +18,7 @@ /** * Implementation of the Signature Packet (Tag 2)
    *
    - * RFC4480 5.2: + * {@link http://tools.ietf.org/html/rfc4880#section-5.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. @@ -336,11 +336,11 @@ Signature.prototype.write_all_sub_packets = function () { }; /** - * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) + * creates a string representation of a sub signature packet (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.3.1|RFC 4880 5.2.3.1}) * @param {Integer} type subpacket signature type. Signature types as described - * in RFC4880 Section 5.2.3.2 + * in {@link http://tools.ietf.org/html/rfc4880#section-5.2.3.2|RFC4880 Section 5.2.3.2} * @param {String} data data to be included - * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) + * @return {String} a string-representation of a sub signature packet (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.3.1|RFC 4880 5.2.3.1}) */ function write_sub_packet(type, data) { var result = ""; diff --git a/src/packet/sym_encrypted_integrity_protected.js b/src/packet/sym_encrypted_integrity_protected.js index 8ca0aa2b..6a6d8c1e 100644 --- a/src/packet/sym_encrypted_integrity_protected.js +++ b/src/packet/sym_encrypted_integrity_protected.js @@ -19,7 +19,8 @@ * Implementation of the Sym. Encrypted Integrity Protected Data * Packet (Tag 18)
    *
    - * RFC4880 5.13: The Symmetrically Encrypted Integrity Protected Data packet is + * {@link http://tools.ietf.org/html/rfc4880#section-5.13|RFC4880 5.13}: + * The Symmetrically Encrypted Integrity Protected Data packet is * a variant of the Symmetrically Encrypted Data packet. It is a new feature * created for OpenPGP that addresses the problem of detecting a modification to * encrypted data. It is used in combination with a Modification Detection Code @@ -97,7 +98,7 @@ SymEncryptedIntegrityProtected.prototype.encrypt = function (sessionKeyAlgorithm * Decrypts the encrypted data contained in this object read_packet must * have been called before * - * @param {Integer} sessionKeyAlgorithm + * @param {module:enums.symmetric} sessionKeyAlgorithm * The selected symmetric encryption algorithm to be used * @param {String} key The key of cipher blocksize length to be used * @return {String} The decrypted data of this packet diff --git a/src/packet/sym_encrypted_session_key.js b/src/packet/sym_encrypted_session_key.js index bc3686bd..d4ffe624 100644 --- a/src/packet/sym_encrypted_session_key.js +++ b/src/packet/sym_encrypted_session_key.js @@ -18,7 +18,7 @@ /** * Public-Key Encrypted Session Key Packets (Tag 1)
    *
    - * RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key + * {@link http://tools.ietf.org/html/rfc4880#section-5.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 diff --git a/src/packet/symmetrically_encrypted.js b/src/packet/symmetrically_encrypted.js index 873cdd5f..3c3020fe 100644 --- a/src/packet/symmetrically_encrypted.js +++ b/src/packet/symmetrically_encrypted.js @@ -18,7 +18,7 @@ /** * Implementation of the Symmetrically Encrypted Data Packet (Tag 9)
    *
    - * RFC4880 5.7: The Symmetrically Encrypted Data packet contains data encrypted + * {@link http://tools.ietf.org/html/rfc4880#section-5.7|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 @@ -52,8 +52,8 @@ SymmetricallyEncrypted.prototype.write = function () { /** * Symmetrically decrypt the packet data * - * @param {Integer} sessionKeyAlgorithm - * Symmetric key algorithm to use // See RFC4880 9.2 + * @param {module:enums.symmetric} sessionKeyAlgorithm + * Symmetric key algorithm to use // See {@link http://tools.ietf.org/html/rfc4880#section-9.2|RFC4880 9.2} * @param {String} key * Key as string with the corresponding length to the * algorithm diff --git a/src/type/keyid.js b/src/type/keyid.js index 40cb8d9e..84b3bcdc 100644 --- a/src/type/keyid.js +++ b/src/type/keyid.js @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /** - * Implementation of type key id (RFC4880 3.3)
    + * Implementation of type key id ({@link http://tools.ietf.org/html/rfc4880#section-3.3|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 diff --git a/src/type/mpi.js b/src/type/mpi.js index 43ddb0f5..fedeb211 100644 --- a/src/type/mpi.js +++ b/src/type/mpi.js @@ -21,7 +21,7 @@ // - MPI = c | d << 8 | e << ((MPI.length -2)*8) | f ((MPI.length -2)*8) /** - * Implementation of type MPI (RFC4880 3.2)
    + * Implementation of type MPI ({@link http://tools.ietf.org/html/rfc4880#section-3.2|RFC4880 3.2})
    *
    * Multiprecision integers (also called MPIs) are unsigned integers used * to hold large integers such as the ones used in cryptographic @@ -48,7 +48,7 @@ function Mpi() { } /** - * Parsing function for a mpi (RFC 4880 3.2). + * Parsing function for a mpi ({@link http://tools.ietf.org/html/rfc4880#section3.2|RFC 4880 3.2}). * @param {String} input Payload of mpi data * @return {Integer} Length of data read */ @@ -86,7 +86,7 @@ Mpi.prototype.byteLength = function () { }; /** - * Converts the mpi object to a string as specified in RFC4880 3.2 + * Converts the mpi object to a string as specified in {@link http://tools.ietf.org/html/rfc4880#section-3.2|RFC4880 3.2} * @return {String} mpi Byte representation */ Mpi.prototype.write = function () { diff --git a/src/type/s2k.js b/src/type/s2k.js index aa5f8379..53284fe6 100644 --- a/src/type/s2k.js +++ b/src/type/s2k.js @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /** - * Implementation of the String-to-key specifier (RFC4880 3.7)
    + * Implementation of the String-to-key specifier ({@link http://tools.ietf.org/html/rfc4880#section-3.7|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 @@ -58,7 +58,7 @@ S2k.prototype.get_count = function () { }; /** - * Parsing function for a string-to-key specifier (RFC 4880 3.7). + * Parsing function for a string-to-key specifier ({@link http://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}). * @param {String} input Payload of string-to-key specifier * @return {Integer} Actual length of the object */