diff --git a/doc/JXG.Util.html b/doc/JXG.Util.html index c402047a..f6fe09c2 100644 --- a/doc/JXG.Util.html +++ b/doc/JXG.Util.html @@ -554,13 +554,13 @@ EXAMPLES:
diff --git a/doc/aes.html b/doc/aes.html index b0cbd65f..4fb9c53f 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 c75e6843..e25b1894 100644 --- a/doc/aes.js.html +++ b/doc/aes.js.html @@ -546,13 +546,13 @@ for (var i in types) {
diff --git a/doc/all_packets.js.html b/doc/all_packets.js.html index 0534f8e3..bd970bc3 100644 --- a/doc/all_packets.js.html +++ b/doc/all_packets.js.html @@ -73,6 +73,25 @@ module.exports = { */ newPacketFromTag: function (tag) { return new this[packetClassFromTagName(tag)](); + }, + /** + * Allocate a new packet from structured packet clone + * See {@link http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#safe-passing-of-structured-data} + * @param {Object} packetClone packet clone + * @returns {Object} new packet object with data from packet clone + */ + fromStructuredClone: function(packetClone) { + var tagName = enums.read(enums.packet, packetClone.tag) + var packet = this.newPacketFromTag(tagName); + for (var attr in packetClone) { + if (packetClone.hasOwnProperty(attr)) { + packet[attr] = packetClone[attr]; + } + } + if (packet.postCloneTypeFix) { + packet.postCloneTypeFix(); + } + return packet; } }; @@ -84,13 +103,6 @@ module.exports = { function packetClassFromTagName(tag) { return tag.substr(0, 1).toUpperCase() + tag.substr(1); } - -for (var i in enums.packet) { - var packetClass = module.exports[packetClassFromTagName(i)]; - - if (packetClass !== undefined) - packetClass.prototype.tag = enums.packet[i]; -} @@ -101,13 +113,13 @@ for (var i in enums.packet) {
diff --git a/doc/armor.html b/doc/armor.html index 82c565d9..e4671fcf 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 ffd05bd4..6f97191b 100644 --- a/doc/armor.js.html +++ b/doc/armor.js.html @@ -413,13 +413,13 @@ module.exports = {
diff --git a/doc/async_proxy.js.html b/doc/async_proxy.js.html new file mode 100644 index 00000000..41fb7b10 --- /dev/null +++ b/doc/async_proxy.js.html @@ -0,0 +1,347 @@ + + + + + JSDoc: Source: worker/async_proxy.js + + + + + + + + + + +
+ +

Source: worker/async_proxy.js

+ + + + + +
+
+
// GPG4Browsers - An OpenPGP implementation in javascript
+// Copyright (C) 2011 Recurity Labs GmbH
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+/**
+ * @requires crypto
+ * @requires enums
+ * @requires packet
+ * @requires type_keyid
+ * @requires key
+ * @module async_proxy
+ */
+
+var crypto = require('../crypto'),
+  packet = require('../packet'),
+  key = require('../key.js'),
+  type_keyid = require('../type/keyid.js'),
+  enums = require('../enums.js');
+
+var INITIAL_RANDOM_SEED = 50000, // random bytes seeded to worker
+    RANDOM_SEED_REQUEST = 20000; // random bytes seeded after worker request
+
+/**
+ * Initializes a new proxy and loads the web worker
+ * @constructor
+ * @param {String} path The path to the worker or 'openpgp.worker.js' by default
+ */
+function AsyncProxy(path) {
+  this.worker = new Worker(path || 'openpgp.worker.js');
+  this.worker.onmessage = this.onMessage.bind(this);
+  this.seedRandom(INITIAL_RANDOM_SEED);
+  // FIFO
+  this.tasks = [];
+}
+
+/**
+ * Message handling
+ */
+AsyncProxy.prototype.onMessage = function(event) {
+  var msg = event.data; 
+  switch (msg.event) {
+    case 'method-return':
+      this.tasks.shift()(msg.err ? new Error(msg.err) : null, msg.data);
+      break;
+    case 'request-seed':
+      this.seedRandom(RANDOM_SEED_REQUEST);
+      break;
+    default:
+      throw new Error('Unknown Worker Event.');
+  }
+};
+
+/**
+ * Send message to worker with random data
+ * @param  {Integer} size Number of bytes to send
+ */
+AsyncProxy.prototype.seedRandom = function(size) {
+  var buf = this.getRandomBuffer(size);
+  this.worker.postMessage({event: 'seed-random', buf: buf});
+};
+
+/**
+ * Get Uint8Array with random numbers
+ * @param  {Integer} size Length of buffer
+ * @return {Uint8Array}
+ */
+AsyncProxy.prototype.getRandomBuffer = function(size) {
+  if (!size) return null;
+  var buf = new Uint8Array(size);
+  crypto.random.getRandomValues(buf);
+  return buf;
+};
+
+/**
+ * Terminates the worker
+ */
+AsyncProxy.prototype.terminate = function() {
+  this.worker.terminate();
+};
+
+/**
+ * Encrypts message text with keys
+ * @param  {Array<module:key~Key>}  keys array of keys, used to encrypt the message
+ * @param  {String} text message as native JavaScript string
+ * @param  {Function} callback receives encrypted ASCII armored message
+ */
+AsyncProxy.prototype.encryptMessage = function(keys, text, callback) {
+  keys = keys.map(function(key) {
+    return key.toPacketlist();
+  });
+  this.worker.postMessage({
+    event: 'encrypt-message', 
+    keys: keys,
+    text: text
+  });
+  this.tasks.push(callback);
+};
+
+/**
+ * Signs message text and encrypts it
+ * @param  {Array<module:key~Key>}  publicKeys array of keys, used to encrypt the message
+ * @param  {module:key~Key}    privateKey private key with decrypted secret key data for signing
+ * @param  {String} text       message as native JavaScript string
+ * @param  {Function} callback receives encrypted ASCII armored message
+ */
+AsyncProxy.prototype.signAndEncryptMessage = function(publicKeys, privateKey, text, callback) {
+  publicKeys = publicKeys.map(function(key) {
+    return key.toPacketlist();
+  });
+  privateKey = privateKey.toPacketlist();
+  this.worker.postMessage({
+    event: 'sign-and-encrypt-message', 
+    publicKeys: publicKeys,
+    privateKey: privateKey,
+    text: text
+  });
+  this.tasks.push(callback);
+};
+
+/**
+ * Decrypts message
+ * @param  {module:key~Key}     privateKey private key with decrypted secret key data
+ * @param  {module:message~Message} message    the message object with the encrypted data
+ * @param  {Function} callback   receives decrypted message as as native JavaScript string
+ *                              or null if no literal data found
+ */
+AsyncProxy.prototype.decryptMessage = function(privateKey, message, callback) {
+  privateKey = privateKey.toPacketlist();
+  this.worker.postMessage({
+    event: 'decrypt-message', 
+    privateKey: privateKey,
+    message: message
+  });
+  this.tasks.push(callback);
+};
+
+/**
+ * Decrypts message and verifies signatures
+ * @param  {module:key~Key}     privateKey private key with decrypted secret key data
+ * @param  {Array<module:key~Key>}   publicKeys public keys to verify signatures
+ * @param  {module:message~Message} message    the message object with signed and encrypted data
+ * @param  {Function} callback   receives decrypted message as as native JavaScript string
+ *                               with verified signatures or null if no literal data found
+ */
+AsyncProxy.prototype.decryptAndVerifyMessage = function(privateKey, publicKeys, message, callback) {
+  privateKey = privateKey.toPacketlist();
+  publicKeys = publicKeys.map(function(key) {
+    return key.toPacketlist();
+  });
+  this.worker.postMessage({
+    event: 'decrypt-and-verify-message', 
+    privateKey: privateKey,
+    publicKeys: publicKeys,
+    message: message
+  });
+  this.tasks.push(function(err, data) {
+    if (data) {
+      data.signatures = data.signatures.map(function(sig) {
+        sig.keyid = type_keyid.fromClone(sig.keyid);
+        return sig;
+      });
+    }
+    callback(err, data);
+  });
+};
+
+/**
+ * Signs a cleartext message
+ * @param  {Array<module:key~Key>}  privateKeys private key with decrypted secret key data to sign cleartext
+ * @param  {String} text        cleartext
+ * @param  {Function} callback       receives ASCII armored message
+ */
+AsyncProxy.prototype.signClearMessage = function(privateKeys, text, callback) {
+  privateKeys = privateKeys.map(function(key) {
+    return key.toPacketlist();
+  });
+  this.worker.postMessage({
+    event: 'sign-clear-message', 
+    privateKeys: privateKeys,
+    text: text
+  });
+  this.tasks.push(callback);
+};
+
+/**
+ * Verifies signatures of cleartext signed message
+ * @param  {Array<module:key~Key>}            publicKeys public keys to verify signatures
+ * @param  {module:cleartext~CleartextMessage} message    cleartext message object with signatures
+ * @param  {Function} callback   receives cleartext with status of verified signatures
+ */
+AsyncProxy.prototype.verifyClearSignedMessage = function(publicKeys, message, callback) {
+  publicKeys = publicKeys.map(function(key) {
+    return key.toPacketlist();
+  });
+  this.worker.postMessage({
+    event: 'verify-clear-signed-message', 
+    publicKeys: publicKeys,
+    message: message
+  });
+  this.tasks.push(function(err, data) {
+    if (data) {
+      data.signatures = data.signatures.map(function(sig) {
+        sig.keyid = type_keyid.fromClone(sig.keyid);
+        return sig;
+      });
+    }
+    callback(err, data);
+  });
+};
+
+/**
+ * Generates a new OpenPGP key pair. Currently only supports RSA keys.
+ * Primary and subkey will be of same type.
+ * @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
+ * @param {Function} callback receives object with key and public and private armored texts
+ */
+AsyncProxy.prototype.generateKeyPair = function(keyType, numBits, userId, passphrase, callback) {
+  this.worker.postMessage({
+    event: 'generate-key-pair', 
+    keyType: keyType, 
+    numBits: numBits, 
+    userId: userId, 
+    passphrase: passphrase
+  });
+  this.tasks.push(function(err, data) {
+    if (data) {
+      var packetlist = packet.List.fromStructuredClone(data.key);
+      data.key = new key.Key(packetlist);
+    }
+    callback(err, data);
+  });
+};
+
+/**
+ * Decrypts secret part of all secret key packets of key.
+ * @param  {module:key~Key}     privateKey private key with encrypted secret key data
+ * @param  {String} password    password to unlock the key
+ * @param  {Function} callback   receives decrypted key
+ */
+AsyncProxy.prototype.decryptKey = function(privateKey, password, callback) {
+  privateKey = privateKey.toPacketlist();
+  this.worker.postMessage({
+    event: 'decrypt-key',
+    privateKey: privateKey,
+    password: password
+  });
+  this.tasks.push(function(err, data) {
+    if (data) {
+      var packetlist = packet.List.fromStructuredClone(data);
+      data = new key.Key(packetlist);
+    }
+    callback(err, data);
+  });
+};
+
+/**
+ * Decrypts secret part of key packets matching array of keyids.
+ * @param  {module:key~Key}     privateKey private key with encrypted secret key data
+ * @param  {Array<module:type/keyid>} keyIds
+ * @param  {String} password    password to unlock the key
+ * @param  {Function} callback   receives decrypted key
+ */
+AsyncProxy.prototype.decryptKeyPacket = function(privateKey, keyIds, password, callback) {
+  privateKey = privateKey.toPacketlist();
+  this.worker.postMessage({
+    event: 'decrypt-key-packet',
+    privateKey: privateKey,
+    keyIds: keyIds,
+    password: password
+  });
+  this.tasks.push(function(err, data) {
+    if (data) {
+      var packetlist = packet.List.fromStructuredClone(data);
+      data = new key.Key(packetlist);
+    }
+    callback(err, data);
+  });
+};
+
+module.exports = AsyncProxy;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/doc/base64.html b/doc/base64.html index c82006eb..ff8a7b70 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 40417491..1df3d8e5 100644 --- a/doc/base64.js.html +++ b/doc/base64.js.html @@ -136,13 +136,13 @@ module.exports = {
diff --git a/doc/blowfish.html b/doc/blowfish.html index 68f66143..cccb9797 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 d949d2cf..be778247 100644 --- a/doc/blowfish.js.html +++ b/doc/blowfish.js.html @@ -451,13 +451,13 @@ module.exports.blockSize = BF.prototype.blockSize = 16;
diff --git a/doc/cast5.html b/doc/cast5.html index 369794db..6ac0583d 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 2ce55406..b46ee07d 100644 --- a/doc/cast5.js.html +++ b/doc/cast5.js.html @@ -642,13 +642,13 @@ module.exports.keySize = cast5.prototype.keySize = 16;
diff --git a/doc/cfb.html b/doc/cfb.html index e1040f27..c7725c43 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 3a2a0c6e..5c69736f 100644 --- a/doc/cfb.js.html +++ b/doc/cfb.js.html @@ -335,13 +335,13 @@ module.exports = {
diff --git a/doc/cipher.html b/doc/cipher.html index ae030fb0..94c848c7 100644 --- a/doc/cipher.html +++ b/doc/cipher.html @@ -262,7 +262,7 @@
See:
@@ -277,7 +277,7 @@
-

<static> originalDes

+

<static> tripledes

@@ -319,7 +319,7 @@
See:
@@ -406,13 +406,13 @@
diff --git a/doc/cleartext.js.html b/doc/cleartext.js.html index dc2967e6..cdd0bc75 100644 --- a/doc/cleartext.js.html +++ b/doc/cleartext.js.html @@ -185,13 +185,13 @@ exports.readArmored = readArmored;
diff --git a/doc/compressed-Compressed.html b/doc/compressed-Compressed.html index ec1e3c1e..4f34a708 100644 --- a/doc/compressed-Compressed.html +++ b/doc/compressed-Compressed.html @@ -168,7 +168,7 @@
Source:
@@ -232,7 +232,7 @@
Source:
@@ -294,6 +294,70 @@ +
Source:
+
+ + + + + + + + + + + + + + + +
+

tag :module:enums.packet

+ + +
+
+ +
+ Packet type +
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + +
Source:
+ + + +
+

getExpirationTime() → {Date|null}

+ + +
+
+ + +
+ Returns the expiration time of the primary key or null if key does not expire +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Date +| + +null + + +
+
+ + + +
@@ -1067,7 +1157,7 @@ Can contain additional subkeys, signatures, user ids, user attributes.
Source:
@@ -2252,13 +2342,13 @@ and valid self signature
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:04 GMT+0100 (MEZ)
diff --git a/doc/module-key-SubKey.html b/doc/module-key-SubKey.html index 5cdce363..4c37e2b3 100644 --- a/doc/module-key-SubKey.html +++ b/doc/module-key-SubKey.html @@ -80,7 +80,7 @@
Source:
@@ -125,6 +125,96 @@
+
+

getExpirationTime() → {Date|null}

+ + +
+
+ + +
+ Returns the expiration time of the subkey or null if key does not expire +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Date +| + +null + + +
+
+ + + + +
+ + +

isValidEncryptionKey(primaryKey) → {Boolean}

@@ -218,7 +308,7 @@
Source:
@@ -356,7 +446,7 @@
Source:
@@ -443,7 +533,7 @@
Source:
@@ -531,7 +621,7 @@ and valid binding signature
Source:
@@ -594,13 +684,13 @@ and valid binding signature
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/module-key-User.html b/doc/module-key-User.html index 074a59bb..789c76bb 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
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/module-key.html b/doc/module-key.html index d5947c6a..f2c4b831 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.
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:04 GMT+0100 (MEZ)
diff --git a/doc/module-keyring.html b/doc/module-keyring.html index 5766cee1..b361ee69 100644 --- a/doc/module-keyring.html +++ b/doc/module-keyring.html @@ -112,13 +112,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:04 GMT+0100 (MEZ)
diff --git a/doc/module-message-Message.html b/doc/module-message-Message.html index 359a780c..7da08525 100644 --- a/doc/module-message-Message.html +++ b/doc/module-message-Message.html @@ -217,7 +217,7 @@ See http://tools.ietf.
Source:
@@ -1004,7 +1004,7 @@ See http://tools.ietf.
Source:
@@ -1095,7 +1095,7 @@ See http://tools.ietf.
Source:
@@ -1234,7 +1234,7 @@ See http://tools.ietf.
Source:
@@ -1297,13 +1297,13 @@ See http://tools.ietf.
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/module-message.html b/doc/module-message.html index 355cff31..b924a451 100644 --- a/doc/module-message.html +++ b/doc/module-message.html @@ -206,7 +206,7 @@
Source:
@@ -345,7 +345,7 @@
Source:
@@ -484,7 +484,7 @@
Source:
@@ -547,13 +547,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:12 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/module-openpgp.html b/doc/module-openpgp.html index a56beb5a..9baab72a 100644 --- a/doc/module-openpgp.html +++ b/doc/module-openpgp.html @@ -857,7 +857,7 @@
-

<static> decryptAndVerifyMessage(privateKey, publicKeys, message) → {Object}

+

<static> decryptAndVerifyMessage(privateKey, publicKeys, msg, callback) → {Object}

@@ -945,7 +945,7 @@ - message + msg @@ -965,6 +965,29 @@ + + + + callback + + + + + +function + + + + + + + + + + (optional) callback(error, result) for async style + + + @@ -992,7 +1015,7 @@
Source:
@@ -1043,7 +1066,7 @@
-

<static> decryptMessage(privateKey, message) → {String|null}

+

<static> decryptMessage(privateKey, msg, callback) → {String|null}

@@ -1108,7 +1131,7 @@ - message + msg @@ -1128,6 +1151,29 @@ + + + + callback + + + + + +function + + + + + + + + + + (optional) callback(error, result) for async style + + + @@ -1155,7 +1201,7 @@
Source:
@@ -1209,7 +1255,7 @@
-

<static> encryptMessage(keys, text) → {String}

+

<static> encryptMessage(keys, text, callback) → {String}

@@ -1294,6 +1340,29 @@ + + + + callback + + + + + +function + + + + + + + + + + (optional) callback(error, result) for async style + + + @@ -1321,7 +1390,7 @@
Source:
@@ -1371,7 +1440,7 @@
-

<static> generateKeyPair(keyType, numBits, userId, passphrase) → {Object}

+

<static> generateKeyPair(keyType, numBits, userId, passphrase, callback) → {Object}

@@ -1504,6 +1573,29 @@ Primary and subkey will be of same type. + + + + callback + + + + + +function + + + + + + + + + + (optional) callback(error, result) for async style + + + @@ -1531,7 +1623,7 @@ Primary and subkey will be of same type.
Source:
@@ -1581,7 +1673,7 @@ Primary and subkey will be of same type.
-

<static> signAndEncryptMessage(publicKeys, privateKey, text) → {String}

+

<static> signAndEncryptMessage(publicKeys, privateKey, text, callback) → {String}

@@ -1689,6 +1781,29 @@ Primary and subkey will be of same type. + + + + callback + + + + + +function + + + + + + + + + + (optional) callback(error, result) for async style + + + @@ -1716,7 +1831,7 @@ Primary and subkey will be of same type.
Source:
@@ -1766,7 +1881,7 @@ Primary and subkey will be of same type.
-

<static> signClearMessage(privateKeys, text) → {String}

+

<static> signClearMessage(privateKeys, text, callback) → {String}

@@ -1851,6 +1966,29 @@ Primary and subkey will be of same type. + + + + callback + + + + + +function + + + + + + + + + + (optional) callback(error, result) for async style + + + @@ -1878,7 +2016,7 @@ Primary and subkey will be of same type.
Source:
@@ -1928,7 +2066,7 @@ Primary and subkey will be of same type.
-

<static> verifyClearSignedMessage(publicKeys, message) → {Object}

+

<static> verifyClearSignedMessage(publicKeys, msg, callback) → {Object}

@@ -1993,7 +2131,7 @@ Primary and subkey will be of same type. - message + msg @@ -2013,6 +2151,29 @@ Primary and subkey will be of same type. + + + + callback + + + + + +function + + + + + + + + + + (optional) callback(error, result) for async style + + + @@ -2040,7 +2201,7 @@ Primary and subkey will be of same type.
Source:
@@ -2085,6 +2246,261 @@ Primary and subkey will be of same type. +
+ + + +
+

<inner> execute()

+ + +
+
+ + +
+ Command pattern that handles async calls gracefully +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<inner> initWorker(path)

+ + +
+
+ + +
+ Set the path for the web worker script and create an instance of the async proxy +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
path + + +String + + + + relative path to the worker scripts
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<inner> useWorker()

+ + +
+
+ + +
+ Are we in a browser and do we support worker? +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + +
@@ -2103,13 +2519,13 @@ Primary and subkey will be of same type.
diff --git a/doc/module-packet.html b/doc/module-packet.html index 0fd117b3..1e21aeba 100644 --- a/doc/module-packet.html +++ b/doc/module-packet.html @@ -1074,6 +1074,146 @@
+
+

<static> fromStructuredClone(packetClone) → {Object}

+ + +
+
+ + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
packetClone + + +Object + + + + packet clone
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ new packet object with data from packet clone +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + +
+ + +

<static> newPacketFromTag(tag) → {Object}

@@ -1303,7 +1443,7 @@
Source:
@@ -1362,13 +1502,13 @@
diff --git a/doc/module-util.html b/doc/module-util.html index 0568f341..e210706b 100644 --- a/doc/module-util.html +++ b/doc/module-util.html @@ -2000,13 +2000,13 @@ the same as bin2str.
diff --git a/doc/mpi-MPI.html b/doc/mpi-MPI.html index cf8c8a53..8cec4958 100644 --- a/doc/mpi-MPI.html +++ b/doc/mpi-MPI.html @@ -425,13 +425,13 @@
diff --git a/doc/mpi.html b/doc/mpi.html index 3c8a486b..ef579de1 100644 --- a/doc/mpi.html +++ b/doc/mpi.html @@ -129,13 +129,13 @@ actual integer.
diff --git a/doc/mpi.js.html b/doc/mpi.js.html index 01911f70..a18c8274 100644 --- a/doc/mpi.js.html +++ b/doc/mpi.js.html @@ -127,6 +127,15 @@ MPI.prototype.toBigInteger = function () { MPI.prototype.fromBigInteger = function (bn) { this.data = bn.clone(); }; + +module.exports.fromClone = function (clone) { + clone.data.copyTo = BigInteger.prototype.copyTo; + var bn = new BigInteger(); + clone.data.copyTo(bn); + var mpi = new MPI(); + mpi.data = bn; + return mpi; +}; @@ -137,13 +146,13 @@ MPI.prototype.fromBigInteger = function (bn) {
diff --git a/doc/one_pass_signature-OnePassSignature.html b/doc/one_pass_signature-OnePassSignature.html index 25fd7e6d..a6331df5 100644 --- a/doc/one_pass_signature-OnePassSignature.html +++ b/doc/one_pass_signature-OnePassSignature.html @@ -123,6 +123,75 @@
+
+

postCloneTypeFix()

+ + +
+
+ + +
+ Fix custom types after cloning +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +

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

@@ -213,7 +282,7 @@
Source:
@@ -304,7 +373,7 @@
Source:
@@ -367,13 +436,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/one_pass_signature.html b/doc/one_pass_signature.html index f8c04df6..a9817200 100644 --- a/doc/one_pass_signature.html +++ b/doc/one_pass_signature.html @@ -128,13 +128,13 @@ can compute the entire signed message in one pass.
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/one_pass_signature.js.html b/doc/one_pass_signature.js.html index 60f60ac9..a537c6b9 100644 --- a/doc/one_pass_signature.js.html +++ b/doc/one_pass_signature.js.html @@ -64,6 +64,7 @@ var enums = require('../enums.js'), * @constructor */ function OnePassSignature() { + this.tag = enums.packet.onePassSignature; // The packet type 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 {@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}) @@ -121,6 +122,13 @@ OnePassSignature.prototype.write = function () { return result; }; + +/** + * Fix custom types after cloning + */ +OnePassSignature.prototype.postCloneTypeFix = function() { + this.signingKeyId = type_keyid.fromClone(this.signingKeyId); +}; @@ -131,13 +139,13 @@ OnePassSignature.prototype.write = function () {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/openpgp.js.html b/doc/openpgp.js.html index 877e6d57..00a4968a 100644 --- a/doc/openpgp.js.html +++ b/doc/openpgp.js.html @@ -64,21 +64,40 @@ var armor = require('./encoding/armor.js'), config = require('./config'), message = require('./message.js'), cleartext = require('./cleartext.js'), - key = require('./key.js'); + key = require('./key.js'), + AsyncProxy = require('./worker/async_proxy.js'); +var asyncProxy; // instance of the asyncproxy + +/** + * Set the path for the web worker script and create an instance of the async proxy + * @param {String} path relative path to the worker scripts + */ +function initWorker(path) { + asyncProxy = new AsyncProxy(path); +} /** * Encrypts message text with keys * @param {Array<module:key~Key>} keys array of keys, used to encrypt the message * @param {String} text message as native JavaScript string + * @param {function} callback (optional) callback(error, result) for async style * @return {String} encrypted ASCII armored message * @static */ -function encryptMessage(keys, text) { - var msg = message.fromText(text); - msg = msg.encrypt(keys); - var armored = armor.encode(enums.armor.message, msg.packets.write()); - return armored; +function encryptMessage(keys, text, callback) { + if (useWorker(callback)) { + asyncProxy.encryptMessage(keys, text, callback); + return; + } + + return execute(function() { + var msg, armored; + msg = message.fromText(text); + msg = msg.encrypt(keys); + armored = armor.encode(enums.armor.message, msg.packets.write()); + return armored; + }, callback); } /** @@ -86,80 +105,121 @@ function encryptMessage(keys, text) { * @param {Array<module:key~Key>} publicKeys array of keys, used to encrypt the message * @param {module:key~Key} privateKey private key with decrypted secret key data for signing * @param {String} text message as native JavaScript string + * @param {function} callback (optional) callback(error, result) for async style * @return {String} encrypted ASCII armored message * @static */ -function signAndEncryptMessage(publicKeys, privateKey, text) { - var msg = message.fromText(text); - msg = msg.sign([privateKey]); - msg = msg.encrypt(publicKeys); - var armored = armor.encode(enums.armor.message, msg.packets.write()); - return armored; +function signAndEncryptMessage(publicKeys, privateKey, text, callback) { + if (useWorker(callback)) { + asyncProxy.signAndEncryptMessage(publicKeys, privateKey, text, callback); + return; + } + + return execute(function() { + var msg, armored; + msg = message.fromText(text); + msg = msg.sign([privateKey]); + msg = msg.encrypt(publicKeys); + armored = armor.encode(enums.armor.message, msg.packets.write()); + return armored; + }, callback); } /** * Decrypts message * @param {module:key~Key} privateKey private key with decrypted secret key data - * @param {module:message~Message} message the message object with the encrypted data + * @param {module:message~Message} msg the message object with the encrypted data + * @param {function} callback (optional) callback(error, result) for async style * @return {(String|null)} decrypted message as as native JavaScript string * or null if no literal data found * @static */ -function decryptMessage(privateKey, message) { - message = message.decrypt(privateKey); - return message.getText(); +function decryptMessage(privateKey, msg, callback) { + if (useWorker(callback)) { + asyncProxy.decryptMessage(privateKey, msg, callback); + return; + } + + return execute(function() { + msg = msg.decrypt(privateKey); + return msg.getText(); + }, callback); } /** * Decrypts message and verifies signatures * @param {module:key~Key} privateKey private key with decrypted secret key data * @param {Array<module:key~Key>} publicKeys public keys to verify signatures - * @param {module:message~Message} message the message object with signed and encrypted data + * @param {module:message~Message} msg the message object with signed and encrypted data + * @param {function} callback (optional) callback(error, result) for async style * @return {{text: String, signatures: Array<{keyid: module:type/keyid, valid: Boolean}>}} * decrypted message as as native JavaScript string * with verified signatures or null if no literal data found * @static */ -function decryptAndVerifyMessage(privateKey, publicKeys, message) { - var result = {}; - message = message.decrypt(privateKey); - result.text = message.getText(); - if (result.text) { - result.signatures = message.verify(publicKeys); - return result; +function decryptAndVerifyMessage(privateKey, publicKeys, msg, callback) { + if (useWorker(callback)) { + asyncProxy.decryptAndVerifyMessage(privateKey, publicKeys, msg, callback); + return; } - return null; + + return execute(function() { + var result = {}; + msg = msg.decrypt(privateKey); + result.text = msg.getText(); + if (result.text) { + result.signatures = msg.verify(publicKeys); + return result; + } + return null; + }, callback); } /** * Signs a cleartext message * @param {Array<module:key~Key>} privateKeys private key with decrypted secret key data to sign cleartext * @param {String} text cleartext + * @param {function} callback (optional) callback(error, result) for async style * @return {String} ASCII armored message * @static */ -function signClearMessage(privateKeys, text) { - var cleartextMessage = new cleartext.CleartextMessage(text); - cleartextMessage.sign(privateKeys); - return cleartextMessage.armor(); +function signClearMessage(privateKeys, text, callback) { + if (useWorker(callback)) { + asyncProxy.signClearMessage(privateKeys, text, callback); + return; + } + + return execute(function() { + var cleartextMessage = new cleartext.CleartextMessage(text); + cleartextMessage.sign(privateKeys); + return cleartextMessage.armor(); + }, callback); } /** * Verifies signatures of cleartext signed message * @param {Array<module:key~Key>} publicKeys public keys to verify signatures - * @param {module:cleartext~CleartextMessage} message cleartext message object with signatures + * @param {module:cleartext~CleartextMessage} msg cleartext message object with signatures + * @param {function} callback (optional) callback(error, result) for async style * @return {{text: String, signatures: Array<{keyid: module:type/keyid, valid: Boolean}>}} * cleartext with status of verified signatures * @static */ -function verifyClearSignedMessage(publicKeys, message) { - var result = {}; - if (!(message instanceof cleartext.CleartextMessage)) { - throw new Error('Parameter [message] needs to be of type CleartextMessage.'); +function verifyClearSignedMessage(publicKeys, msg, callback) { + if (useWorker(callback)) { + asyncProxy.verifyClearSignedMessage(publicKeys, msg, callback); + return; } - result.text = message.getText(); - result.signatures = message.verify(publicKeys); - return result; + + return execute(function() { + var result = {}; + if (!(msg instanceof cleartext.CleartextMessage)) { + throw new Error('Parameter [message] needs to be of type CleartextMessage.'); + } + result.text = msg.getText(); + result.signatures = msg.verify(publicKeys); + return result; + }, callback); } /** @@ -170,18 +230,71 @@ function verifyClearSignedMessage(publicKeys, message) { * @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 + * @param {function} callback (optional) callback(error, result) for async style * @return {Object} {key: Array<module:key~Key>, privateKeyArmored: Array<String>, publicKeyArmored: Array<String>} * @static */ -function generateKeyPair(keyType, numBits, userId, passphrase) { - var result = {}; - var newKey = key.generate(keyType, numBits, userId, passphrase); - result.key = newKey; - result.privateKeyArmored = newKey.armor(); - result.publicKeyArmored = newKey.toPublic().armor(); +function generateKeyPair(keyType, numBits, userId, passphrase, callback) { + if (useWorker(callback)) { + asyncProxy.generateKeyPair(keyType, numBits, userId, passphrase, callback); + return; + } + + return execute(function() { + var result = {}; + var newKey = key.generate(keyType, numBits, userId, passphrase); + result.key = newKey; + result.privateKeyArmored = newKey.armor(); + result.publicKeyArmored = newKey.toPublic().armor(); + return result; + }, callback); +} + +// +// helper functions +// + +/** + * Are we in a browser and do we support worker? + */ +function useWorker(callback) { + if (typeof callback === 'undefined') { + return false; + } + + if (!asyncProxy) { + throw new Error('You need to set the worker path!'); + } + + return true; +} + +/** + * Command pattern that handles async calls gracefully + */ +function execute(cmd, callback) { + var result; + + try { + result = cmd(); + } catch (err) { + if (callback) { + callback(err); + return; + } + + throw err; + } + + if (callback) { + callback(null, result); + return; + } + return result; } +exports.initWorker = initWorker; exports.encryptMessage = encryptMessage; exports.signAndEncryptMessage = signAndEncryptMessage; exports.decryptMessage = decryptMessage; @@ -189,6 +302,7 @@ exports.decryptAndVerifyMessage = decryptAndVerifyMessage; exports.signClearMessage = signClearMessage; exports.verifyClearSignedMessage = verifyClearSignedMessage; exports.generateKeyPair = generateKeyPair; +exports.AsyncProxy = AsyncProxy; @@ -199,13 +313,13 @@ exports.generateKeyPair = generateKeyPair;
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/packet.html b/doc/packet.html index 2ea4f4eb..1602644e 100644 --- a/doc/packet.html +++ b/doc/packet.html @@ -768,13 +768,13 @@ string
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/packet.js.html b/doc/packet.js.html index d6f91f5d..b567f18d 100644 --- a/doc/packet.js.html +++ b/doc/packet.js.html @@ -298,13 +298,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/packetlist-Packetlist.html b/doc/packetlist-Packetlist.html index ce1f3aa3..0a817a22 100644 --- a/doc/packetlist-Packetlist.html +++ b/doc/packetlist-Packetlist.html @@ -1036,13 +1036,13 @@ class instance.
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/packetlist.html b/doc/packetlist.html index 4c67751b..eee102cf 100644 --- a/doc/packetlist.html +++ b/doc/packetlist.html @@ -126,13 +126,13 @@ are stored as numerical indices.
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/packetlist.js.html b/doc/packetlist.js.html index 9a82e270..145406b0 100644 --- a/doc/packetlist.js.html +++ b/doc/packetlist.js.html @@ -202,7 +202,25 @@ Packetlist.prototype.concat = function (packetlist) { } } }; - + +/** + * Allocate a new packetlist from structured packetlist clone + * See {@link http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#safe-passing-of-structured-data} + * @param {Object} packetClone packetlist clone + * @returns {Object} new packetlist object with data from packetlist clone + */ +module.exports.fromStructuredClone = function(packetlistClone) { + var packetlist = new Packetlist(); + for (var i = 0; i < packetlistClone.length; i++) { + packetlist.push(packets.fromStructuredClone(packetlistClone[i])); + if (packetlist[i].packets.length !== 0) { + packetlist[i].packets = this.fromStructuredClone(packetlist[i].packets); + } else { + packetlist[i].packets = new Packetlist(); + } + } + return packetlist; +}; @@ -212,13 +230,13 @@ Packetlist.prototype.concat = function (packetlist) {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/pkcs1.html b/doc/pkcs1.html index d47318d1..91ffdb2f 100644 --- a/doc/pkcs1.html +++ b/doc/pkcs1.html @@ -179,13 +179,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:03 GMT+0100 (MEZ)
diff --git a/doc/pkcs1.js.html b/doc/pkcs1.js.html index 399c11c0..4f8a95a1 100644 --- a/doc/pkcs1.js.html +++ b/doc/pkcs1.js.html @@ -180,13 +180,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/public_key-PublicKey.html b/doc/public_key-PublicKey.html index fdae6207..463be166 100644 --- a/doc/public_key-PublicKey.html +++ b/doc/public_key-PublicKey.html @@ -168,7 +168,7 @@
Source:
@@ -232,7 +232,7 @@
Source:
@@ -296,7 +296,7 @@
Source:
@@ -350,7 +350,7 @@
Source:
@@ -411,7 +411,7 @@
Source:
@@ -441,6 +441,97 @@
+
+

getBitSize() → {int}

+ + +
+
+ + +
+ Returns bit size of key +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ Number of bits +
+ + + +
+
+ Type +
+
+ +int + + +
+
+ + + + +
+ + +

getFingerprint() → {String}

@@ -483,7 +574,7 @@
Source:
@@ -574,7 +665,7 @@
Source:
@@ -619,6 +710,75 @@ + + + + +
+

postCloneTypeFix()

+ + +
+
+ + +
+ Fix custom types after cloning +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + +
@@ -714,7 +874,7 @@ called by read_tag<num>
Source:
@@ -806,7 +966,7 @@ public key.
Source:
@@ -898,7 +1058,7 @@ header: [string] OpenPGP packet header, string: [string] header+body}
Source:
@@ -939,13 +1099,13 @@ header: [string] OpenPGP packet header, string: [string] header+body}
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/public_key.html b/doc/public_key.html index 952116f5..8e7de082 100644 --- a/doc/public_key.html +++ b/doc/public_key.html @@ -290,13 +290,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:03 GMT+0100 (MEZ)
diff --git a/doc/public_key.js.html b/doc/public_key.js.html index 32cb6afb..35f4f433 100644 --- a/doc/public_key.js.html +++ b/doc/public_key.js.html @@ -69,6 +69,7 @@ var util = require('../util.js'), * @constructor */ function PublicKey() { + this.tag = enums.packet.publicKey; this.version = 4; /** Key creation date. * @type {Date} */ @@ -210,6 +211,23 @@ PublicKey.prototype.getFingerprint = function () { return crypto.hash.md5(toHash); } }; + +/** + * Returns bit size of key + * @return {int} Number of bits + */ +PublicKey.prototype.getBitSize = function () { + return this.mpi[0].byteLength() * 8; +}; + +/** + * Fix custom types after cloning + */ +PublicKey.prototype.postCloneTypeFix = function() { + for (var i = 0; i < this.mpi.length; i++) { + this.mpi[i] = type_mpi.fromClone(this.mpi[i]); + } +}; @@ -220,13 +238,13 @@ PublicKey.prototype.getFingerprint = function () {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
diff --git a/doc/public_key_.html b/doc/public_key_.html index 5ebfec44..9a47200d 100644 --- a/doc/public_key_.html +++ b/doc/public_key_.html @@ -133,13 +133,13 @@ major versions. Consequently, this section is complex.
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html b/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html index bfa99fe0..2dcc2b46 100644 --- a/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html +++ b/doc/public_key_encrypted_session_key-PublicKeyEncryptedSessionKey.html @@ -164,7 +164,7 @@
Source:
@@ -278,7 +278,7 @@ packets (tag 1)
Source:
@@ -323,6 +323,75 @@ packets (tag 1) + + + + +
+

postCloneTypeFix()

+ + +
+
+ + +
+ Fix custom types after cloning +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + +
@@ -464,7 +533,7 @@ packets (tag 1)
Source:
@@ -698,7 +767,7 @@ packets (tag 1)
Source:
@@ -761,13 +830,13 @@ packets (tag 1)
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/public_key_encrypted_session_key.html b/doc/public_key_encrypted_session_key.html index 74cad0ce..af874376 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.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:05 GMT+0100 (MEZ)
diff --git a/doc/public_key_encrypted_session_key.js.html b/doc/public_key_encrypted_session_key.js.html index 529aeffa..c34f60c5 100644 --- a/doc/public_key_encrypted_session_key.js.html +++ b/doc/public_key_encrypted_session_key.js.html @@ -76,6 +76,7 @@ var type_keyid = require('../type/keyid.js'), * @constructor */ function PublicKeyEncryptedSessionKey() { + this.tag = enums.packet.publicKeyEncryptedSessionKey; this.version = 3; this.publicKeyId = new type_keyid(); @@ -209,6 +210,16 @@ PublicKeyEncryptedSessionKey.prototype.decrypt = function (key) { enums.read(enums.symmetric, decoded.charCodeAt(0)); } }; + +/** + * Fix custom types after cloning + */ +PublicKeyEncryptedSessionKey.prototype.postCloneTypeFix = function() { + this.publicKeyId = type_keyid.fromClone(this.publicKeyId); + for (var i = 0; i < this.encrypted.length; i++) { + this.encrypted[i] = type_mpi.fromClone(this.encrypted[i]); + } +}; @@ -219,13 +230,13 @@ PublicKeyEncryptedSessionKey.prototype.decrypt = function (key) {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
diff --git a/doc/public_subkey-PublicSubkey.html b/doc/public_subkey-PublicSubkey.html index 44245907..04c5e7d1 100644 --- a/doc/public_subkey-PublicSubkey.html +++ b/doc/public_subkey-PublicSubkey.html @@ -78,7 +78,7 @@
Source:
@@ -139,13 +139,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/public_subkey.html b/doc/public_subkey.html index b4406d08..f9e89f09 100644 --- a/doc/public_subkey.html +++ b/doc/public_subkey.html @@ -87,6 +87,8 @@ @@ -118,13 +120,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/public_subkey.js.html b/doc/public_subkey.js.html index ce6e837e..58c8190e 100644 --- a/doc/public_subkey.js.html +++ b/doc/public_subkey.js.html @@ -44,12 +44,14 @@ /** * @requires packet/public_key + * @requires enums * @module packet/public_subkey */ module.exports = PublicSubkey; -var publicKey = require('./public_key.js'); +var publicKey = require('./public_key.js'), + enums = require('../enums.js'); /** * @constructor @@ -57,7 +59,8 @@ var publicKey = require('./public_key.js'); */ function PublicSubkey() { publicKey.call(this); -}; + this.tag = enums.packet.publicSubkey; +} PublicSubkey.prototype = new publicKey(); PublicSubkey.prototype.constructor = PublicSubkey; @@ -71,13 +74,13 @@ PublicSubkey.prototype.constructor = PublicSubkey;
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
diff --git a/doc/random.html b/doc/random.html index 6eeb9820..a69e967a 100644 --- a/doc/random.html +++ b/doc/random.html @@ -353,7 +353,7 @@
Source:
@@ -590,7 +590,7 @@ -Uint32Array +Uint8Array @@ -631,7 +631,7 @@
Source:
@@ -816,6 +816,75 @@ + + + + +
+

<inner> RandomBuffer()

+ + +
+
+ + +
+ Buffer for secure random numbers +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + +
@@ -834,13 +903,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:03 GMT+0100 (MEZ)
diff --git a/doc/random.js.html b/doc/random.js.html index 898e0a76..e2319e51 100644 --- a/doc/random.js.html +++ b/doc/random.js.html @@ -87,30 +87,41 @@ module.exports = { * @return {Integer} A secure random number */ getSecureRandom: function(from, to) { - var buf = new Uint32Array(1); - this.getRandomValues(buf); + var randUint = this.getSecureRandomUint(); var bits = ((to - from)).toString(2).length; - while ((buf[0] & (Math.pow(2, bits) - 1)) > (to - from)) - this.getRandomValues(buf); - return from + (Math.abs(buf[0] & (Math.pow(2, bits) - 1))); + while ((randUint & (Math.pow(2, bits) - 1)) > (to - from)) { + randUint = this.getSecureRandomUint(); + } + return from + (Math.abs(randUint & (Math.pow(2, bits) - 1))); }, getSecureRandomOctet: function() { - var buf = new Uint32Array(1); + var buf = new Uint8Array(1); this.getRandomValues(buf); - return buf[0] & 0xFF; + return buf[0]; + }, + + getSecureRandomUint: function() { + var buf = new Uint8Array(4); + var dv = new DataView(buf.buffer); + this.getRandomValues(buf); + return dv.getUint32(0); }, /** * Helper routine which calls platform specific crypto random generator - * @param {Uint32Array} buf + * @param {Uint8Array} buf */ getRandomValues: function(buf) { - if (nodeCrypto === null) { + if (typeof window !== 'undefined' && window.crypto) { window.crypto.getRandomValues(buf); + } else if (nodeCrypto) { + var bytes = nodeCrypto.randomBytes(buf.length); + buf.set(bytes); + } else if (this.randomBuffer.buffer) { + this.randomBuffer.get(buf); } else { - var bytes = nodeCrypto.randomBytes(4); - buf[0] = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; + throw new Error('No secure random number generator available.'); } }, @@ -149,8 +160,59 @@ module.exports = { r = this.getRandomBigInteger(range.bitLength()); } return min.add(r); - } + }, + randomBuffer: new RandomBuffer() + +}; + +/** + * Buffer for secure random numbers + */ +function RandomBuffer() { + this.buffer = null; + this.size = null; +} + +/** + * Initialize buffer + * @param {Integer} size size of buffer + */ +RandomBuffer.prototype.init = function(size) { + this.buffer = new Uint32Array(size); + this.size = 0; +}; + +/** + * Concat array of secure random numbers to buffer + * @param {Uint32Array} buf + */ +RandomBuffer.prototype.set = function(buf) { + if (!this.buffer) { + throw new Error('RandomBuffer is not initialized'); + } + var freeSpace = this.buffer.length - this.size; + if (buf.length > freeSpace) { + buf = buf.subarray(0, freeSpace); + } + this.buffer.set(buf, this.size); + this.size += buf.length; +}; + +/** + * Take numbers out of buffer and copy to array + * @param {Uint32Array} buf the destination array + */ +RandomBuffer.prototype.get = function(buf) { + if (!this.buffer) { + throw new Error('RandomBuffer is not initialized'); + } + if (this.size < buf.length) { + throw new Error('Random number buffer depleted.') + } + for (var i = 0; i < buf.length; i++) { + buf[i] = this.buffer[--this.size]; + } }; @@ -162,13 +224,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/ripe-md.html b/doc/ripe-md.html index 5ac8c7f5..66be3b42 100644 --- a/doc/ripe-md.html +++ b/doc/ripe-md.html @@ -105,13 +105,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:03 GMT+0100 (MEZ)
diff --git a/doc/ripe-md.js.html b/doc/ripe-md.js.html index b98d2b1f..2e424ee8 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.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/rsa.html b/doc/rsa.html index ad399bbe..5ecc7dba 100644 --- a/doc/rsa.html +++ b/doc/rsa.html @@ -115,13 +115,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:03 GMT+0100 (MEZ)
diff --git a/doc/rsa.js.html b/doc/rsa.js.html index abe1e8fe..0a68cace 100644 --- a/doc/rsa.js.html +++ b/doc/rsa.js.html @@ -187,13 +187,13 @@ module.exports = RSA;
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/s2k-S2K.html b/doc/s2k-S2K.html index 975ec997..f5c53fc9 100644 --- a/doc/s2k-S2K.html +++ b/doc/s2k-S2K.html @@ -696,13 +696,13 @@ hashAlgorithm hash length
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:15 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:07 GMT+0100 (MEZ)
diff --git a/doc/s2k.html b/doc/s2k.html index e88f6286..7b68775b 100644 --- a/doc/s2k.html +++ b/doc/s2k.html @@ -130,13 +130,13 @@ symmetrically encrypted messages.
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:07 GMT+0100 (MEZ)
diff --git a/doc/s2k.js.html b/doc/s2k.js.html index 27640374..617d8571 100644 --- a/doc/s2k.js.html +++ b/doc/s2k.js.html @@ -205,6 +205,15 @@ S2K.prototype.produce_key = function (passphrase, numBytes) { return result.substr(0, numBytes); }; + +module.exports.fromClone = function (clone) { + var s2k = new S2K(); + this.algorithm = clone.algorithm; + this.type = clone.type; + this.c = clone.c; + this.salt = clone.salt; + return s2k; +}; @@ -215,13 +224,13 @@ S2K.prototype.produce_key = function (passphrase, numBytes) {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
diff --git a/doc/secret_key-SecretKey.html b/doc/secret_key-SecretKey.html index 68d61777..92e663c5 100644 --- a/doc/secret_key-SecretKey.html +++ b/doc/secret_key-SecretKey.html @@ -220,7 +220,7 @@ as string
Source:
@@ -361,7 +361,7 @@ to key specifier
Source:
@@ -478,7 +478,7 @@ to key specifier
Source:
@@ -547,7 +547,7 @@ to key specifier
Source:
@@ -610,13 +610,13 @@ to key specifier
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/secret_key.html b/doc/secret_key.html index 6ccce91a..e39f561d 100644 --- a/doc/secret_key.html +++ b/doc/secret_key.html @@ -135,13 +135,13 @@ major versions. Consequently, this section is complex.
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:13 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/secret_key.js.html b/doc/secret_key.js.html index a9b6e166..89ef53b5 100644 --- a/doc/secret_key.js.html +++ b/doc/secret_key.js.html @@ -73,6 +73,7 @@ var publicKey = require('./public_key.js'), */ function SecretKey() { publicKey.call(this); + this.tag = enums.packet.secretKey; // encrypted secret-key data this.encrypted = null; // indicator if secret-key data is available in decrypted form @@ -302,13 +303,13 @@ SecretKey.prototype.generate = function (bits) {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
diff --git a/doc/secret_subkey-SecretSubkey.html b/doc/secret_subkey-SecretSubkey.html index 6afd0166..98e06425 100644 --- a/doc/secret_subkey-SecretSubkey.html +++ b/doc/secret_subkey-SecretSubkey.html @@ -78,7 +78,7 @@
Source:
@@ -139,13 +139,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/secret_subkey.html b/doc/secret_subkey.html index 8570ef13..ca05d7f1 100644 --- a/doc/secret_subkey.html +++ b/doc/secret_subkey.html @@ -87,6 +87,8 @@ @@ -118,13 +120,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/secret_subkey.js.html b/doc/secret_subkey.js.html index 01a44405..6368ad73 100644 --- a/doc/secret_subkey.js.html +++ b/doc/secret_subkey.js.html @@ -44,12 +44,14 @@ /** * @requires packet/secret_key + * @requires enums * @module packet/secret_subkey */ module.exports = SecretSubkey; -var secretKey = require('./secret_key.js'); +var secretKey = require('./secret_key.js'), + enums = require('../enums.js'); /** * @constructor @@ -57,6 +59,7 @@ var secretKey = require('./secret_key.js'); */ function SecretSubkey() { secretKey.call(this); + this.tag = enums.packet.secretSubkey; } SecretSubkey.prototype = new secretKey(); @@ -71,13 +74,13 @@ SecretSubkey.prototype.constructor = SecretSubkey;
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
diff --git a/doc/sha.html b/doc/sha.html index 0d3cb6f5..25670e25 100644 --- a/doc/sha.html +++ b/doc/sha.html @@ -454,13 +454,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:03 GMT+0100 (MEZ)
diff --git a/doc/sha.js.html b/doc/sha.js.html index 5590510f..71a6f505 100644 --- a/doc/sha.js.html +++ b/doc/sha.js.html @@ -1160,13 +1160,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/signature-Signature.html b/doc/signature-Signature.html index 81f6c8b7..07df007d 100644 --- a/doc/signature-Signature.html +++ b/doc/signature-Signature.html @@ -165,7 +165,7 @@
Source:
@@ -210,6 +210,75 @@ + + + + +
+

postCloneTypeFix()

+ + +
+
+ + +
+ Fix custom types after cloning +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + +
@@ -350,7 +419,7 @@
Source:
@@ -512,7 +581,7 @@
Source:
@@ -658,7 +727,7 @@
Source:
@@ -749,7 +818,7 @@
Source:
@@ -812,13 +881,13 @@
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/signature.html b/doc/signature.html index 992967c2..face1cdc 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.2 on Fri Jan 10 2014 09:39:11 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:04 GMT+0100 (MEZ)
diff --git a/doc/signature.js.html b/doc/signature.js.html index 82e9306f..d5d8c56b 100644 --- a/doc/signature.js.html +++ b/doc/signature.js.html @@ -148,13 +148,13 @@ module.exports = {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
diff --git a/doc/signature.js_.html b/doc/signature.js_.html index d0161b62..878c067b 100644 --- a/doc/signature.js_.html +++ b/doc/signature.js_.html @@ -71,7 +71,7 @@ var util = require('../util.js'), * @constructor */ function Signature() { - + this.tag = enums.packet.signature; this.version = 4; this.signatureType = null; this.hashAlgorithm = null; @@ -79,7 +79,6 @@ function Signature() { this.signatureData = null; this.signedHashValue = null; - this.mpi = null; this.created = new Date(); this.signatureExpirationTime = null; @@ -579,6 +578,7 @@ Signature.prototype.toSign = function (type, data) { break; case t.subkey_binding: + case t.subkey_revocation: case t.key_binding: return this.toSign(t.key, data) + this.toSign(t.key, { key: data.bind @@ -591,7 +591,6 @@ Signature.prototype.toSign = function (type, data) { return data.key.writeOld(); case t.key_revocation: - case t.subkey_revocation: return this.toSign(t.key, data); case t.timestamp: return ''; @@ -665,6 +664,13 @@ Signature.prototype.isExpired = function () { } return false; }; + +/** + * Fix custom types after cloning + */ +Signature.prototype.postCloneTypeFix = function() { + this.issuerKeyId = type_keyid.fromClone(this.issuerKeyId); +}; @@ -675,13 +681,13 @@ Signature.prototype.isExpired = function () {
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
diff --git a/doc/signature_.html b/doc/signature_.html index 369f151a..a456fd3e 100644 --- a/doc/signature_.html +++ b/doc/signature_.html @@ -239,7 +239,7 @@ in RFC4880 Section
Source:
@@ -302,13 +302,13 @@ in RFC4880 Section
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html b/doc/sym_encrypted_integrity_protected-SymEncryptedIntegrityProtected.html index feb06762..504a0b82 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:
@@ -361,7 +361,7 @@ have been called before
Source:
@@ -424,13 +424,13 @@ have been called before
- Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
diff --git a/doc/sym_encrypted_integrity_protected.html b/doc/sym_encrypted_integrity_protected.html index 670b0b6c..05970a30 100644 --- a/doc/sym_encrypted_integrity_protected.html +++ b/doc/sym_encrypted_integrity_protected.html @@ -99,6 +99,8 @@ packet.
  • module:crypto
  • module:util
  • + +
  • module:enums
  • @@ -130,13 +132,13 @@ packet.
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/sym_encrypted_integrity_protected.js.html b/doc/sym_encrypted_integrity_protected.js.html index 3634b362..2a117e47 100644 --- a/doc/sym_encrypted_integrity_protected.js.html +++ b/doc/sym_encrypted_integrity_protected.js.html @@ -54,18 +54,21 @@ * packet. * @requires crypto * @requires util + * @requires enums * @module packet/sym_encrypted_integrity_protected */ module.exports = SymEncryptedIntegrityProtected; var util = require('../util.js'), - crypto = require('../crypto'); + crypto = require('../crypto'), + enums = require('../enums.js'); /** * @constructor */ function SymEncryptedIntegrityProtected() { + this.tag = enums.packet.symEncryptedIntegrityProtected; /** The encrypted payload. */ this.encrypted = null; // string /** @@ -158,13 +161,13 @@ SymEncryptedIntegrityProtected.prototype.decrypt = function (sessionKeyAlgorithm
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
    diff --git a/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html b/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html index 7d3cc314..ba85fdd6 100644 --- a/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html +++ b/doc/sym_encrypted_session_key-SymEncryptedSessionKey.html @@ -211,6 +211,75 @@ packets (tag 1) + + + + +
    +

    postCloneTypeFix()

    + + +
    +
    + + +
    + Fix custom types after cloning +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + +
    @@ -415,13 +484,13 @@ packets (tag 1)
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/sym_encrypted_session_key.html b/doc/sym_encrypted_session_key.html index 41e4ed76..98440e28 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.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/sym_encrypted_session_key.js.html b/doc/sym_encrypted_session_key.js.html index 8bb5c304..39036cb9 100644 --- a/doc/sym_encrypted_session_key.js.html +++ b/doc/sym_encrypted_session_key.js.html @@ -72,7 +72,7 @@ module.exports = SymEncryptedSessionKey; * @constructor */ function SymEncryptedSessionKey() { - this.tag = 3; + this.tag = enums.packet.symEncryptedSessionKey; this.sessionKeyEncryptionAlgorithm = null; this.sessionKeyAlgorithm = 'aes256'; this.encrypted = null; @@ -167,6 +167,13 @@ SymEncryptedSessionKey.prototype.encrypt = function(passphrase) { crypto.getPrefixRandom(this.sessionKeyEncryptionAlgorithm), this.sessionKeyEncryptionAlgorithm, key, private_key, true); }; + +/** + * Fix custom types after cloning + */ +SymEncryptedSessionKey.prototype.postCloneTypeFix = function() { + this.s2k = type_s2k.fromClone(this.s2k); +}; @@ -177,13 +184,13 @@ SymEncryptedSessionKey.prototype.encrypt = function(passphrase) {
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
    diff --git a/doc/symmetrically_encrypted-SymmetricallyEncrypted.html b/doc/symmetrically_encrypted-SymmetricallyEncrypted.html index c4cd4a04..7fb3608f 100644 --- a/doc/symmetrically_encrypted-SymmetricallyEncrypted.html +++ b/doc/symmetrically_encrypted-SymmetricallyEncrypted.html @@ -78,7 +78,7 @@
    Source:
    @@ -168,7 +168,7 @@
    Source:
    @@ -305,7 +305,7 @@
    Source:
    @@ -346,13 +346,13 @@
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/symmetrically_encrypted.html b/doc/symmetrically_encrypted.html index ead400bd..597b2364 100644 --- a/doc/symmetrically_encrypted.html +++ b/doc/symmetrically_encrypted.html @@ -95,6 +95,8 @@ that form whole OpenPGP messages). @@ -126,13 +128,13 @@ that form whole OpenPGP messages).
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/symmetrically_encrypted.js.html b/doc/symmetrically_encrypted.js.html index 063cfdc7..b3bfba21 100644 --- a/doc/symmetrically_encrypted.js.html +++ b/doc/symmetrically_encrypted.js.html @@ -51,17 +51,20 @@ * theory other Symmetrically Encrypted Data packets or sequences of packets * that form whole OpenPGP messages). * @requires crypto + * @requires enums * @module packet/symmetrically_encrypted */ module.exports = SymmetricallyEncrypted; -var crypto = require('../crypto'); +var crypto = require('../crypto'), + enums = require('../enums.js'); /** * @constructor */ function SymmetricallyEncrypted() { + this.tag = enums.packet.symmetricallyEncrypted; this.encrypted = null; /** Decrypted packets contained within. * @type {module:packet/packetlist} */ @@ -108,13 +111,13 @@ SymmetricallyEncrypted.prototype.encrypt = function (algo, key) {
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
    diff --git a/doc/trust-Trust.html b/doc/trust-Trust.html index e2f5d1f2..2241aef3 100644 --- a/doc/trust-Trust.html +++ b/doc/trust-Trust.html @@ -78,7 +78,7 @@
    Source:
    @@ -133,13 +133,13 @@
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/trust.html b/doc/trust.html index 2f50309f..999e027a 100644 --- a/doc/trust.html +++ b/doc/trust.html @@ -83,6 +83,12 @@ +

    Requires

    + + +

    Classes

    @@ -112,13 +118,13 @@
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/trust.js.html b/doc/trust.js.html index e74f126f..2d6bf5fc 100644 --- a/doc/trust.js.html +++ b/doc/trust.js.html @@ -26,16 +26,20 @@
    /**
    + * @requires enums
      * @module packet/trust
      */
     
     module.exports = Trust;
     
    +var enums = require('../enums.js');
    +
     /**
      * @constructor
      */
     function Trust() {
    -};
    +  this.tag = enums.packet.trust;
    +}
     
    @@ -46,13 +50,13 @@ function Trust() {
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
    diff --git a/doc/twofish.html b/doc/twofish.html index 83099e0c..158f5609 100644 --- a/doc/twofish.html +++ b/doc/twofish.html @@ -105,13 +105,13 @@
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:10 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:03 GMT+0100 (MEZ)
    diff --git a/doc/twofish.js.html b/doc/twofish.js.html index d318e0bb..700fde19 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.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:01 GMT+0100 (MEZ)
    diff --git a/doc/user_attribute-UserAttribute.html b/doc/user_attribute-UserAttribute.html index 36aa6d9f..340e6b50 100644 --- a/doc/user_attribute-UserAttribute.html +++ b/doc/user_attribute-UserAttribute.html @@ -78,7 +78,7 @@
    Source:
    @@ -213,7 +213,7 @@
    Source:
    @@ -254,13 +254,13 @@
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/user_attribute.html b/doc/user_attribute.html index 41c9bf65..5be0cdcd 100644 --- a/doc/user_attribute.html +++ b/doc/user_attribute.html @@ -100,6 +100,12 @@ module packet/user_attribute +

    Requires

    + + +

    Classes

    @@ -129,13 +135,13 @@ module packet/user_attribute
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/user_attribute.js.html b/doc/user_attribute.js.html index 827e953a..bb8768c5 100644 --- a/doc/user_attribute.js.html +++ b/doc/user_attribute.js.html @@ -59,11 +59,13 @@ * User Attribute packet as a User ID packet with opaque contents, but * an implementation may use any method desired. * module packet/user_attribute + * @requires enums * @module packet/user_attribute */ var util = require('../util.js'), - packet = require('./packet.js'); + packet = require('./packet.js'), + enums = require('../enums.js'); module.exports = UserAttribute; @@ -71,6 +73,7 @@ module.exports = UserAttribute; * @constructor */ function UserAttribute() { + this.tag = enums.packet.userAttribute; this.attributes = []; } @@ -98,13 +101,13 @@ UserAttribute.prototype.read = function(bytes) {
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
    diff --git a/doc/userid-Userid.html b/doc/userid-Userid.html index fc9efdbb..a5564845 100644 --- a/doc/userid-Userid.html +++ b/doc/userid-Userid.html @@ -78,7 +78,7 @@
    Source:
    @@ -169,7 +169,7 @@ John Doe
    Source:
    @@ -282,7 +282,7 @@ John Doe
    Source:
    @@ -351,7 +351,7 @@ John Doe
    Source:
    @@ -414,13 +414,13 @@ John Doe
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/userid.html b/doc/userid.html index 89d20754..d564f5df 100644 --- a/doc/userid.html +++ b/doc/userid.html @@ -95,6 +95,8 @@ specifies the length of the User ID. @@ -126,13 +128,13 @@ specifies the length of the User ID.
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:14 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:06 GMT+0100 (MEZ)
    diff --git a/doc/userid.js.html b/doc/userid.js.html index 720bf3ec..ca72eaba 100644 --- a/doc/userid.js.html +++ b/doc/userid.js.html @@ -51,17 +51,20 @@ * restrictions on its content. The packet length in the header * specifies the length of the User ID. * @requires util + * @requires enums * @module packet/userid */ module.exports = Userid; -var util = require('../util.js'); +var util = require('../util.js'), + enums = require('../enums.js'); /** * @constructor */ function Userid() { + this.tag = enums.packet.userid; /** A string containing the user id. Usually in the form * John Doe <john@example.com> * @type {String} @@ -94,13 +97,13 @@ Userid.prototype.write = function () {
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
    diff --git a/doc/util.js.html b/doc/util.js.html index e5b5ad05..d85df983 100644 --- a/doc/util.js.html +++ b/doc/util.js.html @@ -339,13 +339,13 @@ module.exports = {
    - Documentation generated by JSDoc 3.2.2 on Fri Jan 10 2014 09:39:09 GMT-0800 (PST) + Documentation generated by JSDoc 3.2.2 on Wed Feb 12 2014 15:09:02 GMT+0100 (MEZ)
    diff --git a/src/index.js b/src/index.js index 711a8a55..4a2a0972 100644 --- a/src/index.js +++ b/src/index.js @@ -65,3 +65,8 @@ module.exports.crypto = require('./crypto'); * @name module:openpgp.Keyring */ module.exports.Keyring = require('./keyring'); +/** + * @see module:worker/async_proxy + * @name module:openpgp.AsyncProxy + */ +module.exports.AsyncProxy = require('./worker/async_proxy.js'); diff --git a/src/openpgp.js b/src/openpgp.js index 028d38c7..4cdabc32 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -275,4 +275,3 @@ exports.decryptAndVerifyMessage = decryptAndVerifyMessage; exports.signClearMessage = signClearMessage; exports.verifyClearSignedMessage = verifyClearSignedMessage; exports.generateKeyPair = generateKeyPair; -exports.AsyncProxy = AsyncProxy;