Refactor most src files to strict mode, delint
This commit is contained in:
parent
346aa8f11a
commit
90a7457b71
|
@ -7,7 +7,6 @@
|
||||||
"curly": true,
|
"curly": true,
|
||||||
"eqeqeq": true,
|
"eqeqeq": true,
|
||||||
"immed": true,
|
"immed": true,
|
||||||
"newcap": true,
|
|
||||||
"regexp": true,
|
"regexp": true,
|
||||||
"evil": true,
|
"evil": true,
|
||||||
"eqnull": true,
|
"eqnull": true,
|
||||||
|
@ -32,6 +31,7 @@
|
||||||
"afterEach": true,
|
"afterEach": true,
|
||||||
"escape": true,
|
"escape": true,
|
||||||
"unescape": true,
|
"unescape": true,
|
||||||
"asmCrypto": true
|
"asmCrypto": true,
|
||||||
|
"postMessage": true
|
||||||
}
|
}
|
||||||
}
|
}
|
48
Gruntfile.js
48
Gruntfile.js
|
@ -2,6 +2,50 @@
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
|
var lintFiles = [
|
||||||
|
'src/config/*.js',
|
||||||
|
'src/crypto/cipher/aes.js',
|
||||||
|
'src/crypto/cipher/blowfish.js',
|
||||||
|
'src/crypto/cipher/cast5.js',
|
||||||
|
'src/crypto/cipher/des.js',
|
||||||
|
'src/crypto/cipher/index.js',
|
||||||
|
'src/crypto/hash/md5.js',
|
||||||
|
'src/crypto/public_key/dsa.js',
|
||||||
|
'src/crypto/public_key/elgamal.js',
|
||||||
|
'src/crypto/public_key/index.js',
|
||||||
|
'src/crypto/public_key/rsa.js',
|
||||||
|
'src/crypto/cfb.js',
|
||||||
|
'src/crypto/crypto.js',
|
||||||
|
'src/crypto/index.js',
|
||||||
|
'src/crypto/pkcs1.js',
|
||||||
|
'src/crypto/random.js',
|
||||||
|
'src/crypto/signature.js',
|
||||||
|
'src/encoding/*.js',
|
||||||
|
'src/hkp/*.js',
|
||||||
|
'src/keyring/*.js',
|
||||||
|
'src/packet/all_packets.js',
|
||||||
|
'src/packet/compressed.js',
|
||||||
|
'src/packet/index.js',
|
||||||
|
'src/packet/literal.js',
|
||||||
|
'src/packet/marker.js',
|
||||||
|
'src/packet/one_pass_signature.js',
|
||||||
|
'src/packet/packet.js',
|
||||||
|
'src/packet/public_key.js',
|
||||||
|
'src/packet/public_key_encrypted_session_key.js',
|
||||||
|
'src/packet/public_subkey.js',
|
||||||
|
'src/packet/secret_key.js',
|
||||||
|
'src/packet/secret_subkey.js',
|
||||||
|
'src/packet/sym_encrypted_integrity_protected.js',
|
||||||
|
'src/packet/sym_encrypted_session_key.js',
|
||||||
|
'src/packet/symmetrically_encrypted.js',
|
||||||
|
'src/packet/trust.js',
|
||||||
|
'src/packet/user_attribute.js',
|
||||||
|
'src/packet/userid.js',
|
||||||
|
'src/type/*.js',
|
||||||
|
'src/worker/async_proxy.js',
|
||||||
|
'src/*.js',
|
||||||
|
]; // add more over time ... goal should be 100% coverage
|
||||||
|
|
||||||
var version = grunt.option('release');
|
var version = grunt.option('release');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var browser_capabilities;
|
var browser_capabilities;
|
||||||
|
@ -105,14 +149,14 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
src: ['src/*.js'], // add more over time ... goal should be 100% coverage
|
src: lintFiles,
|
||||||
build: ['Gruntfile.js', '*.json'],
|
build: ['Gruntfile.js', '*.json'],
|
||||||
options: {
|
options: {
|
||||||
jshintrc: '.jshintrc'
|
jshintrc: '.jshintrc'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jscs: {
|
jscs: {
|
||||||
src: ['src/*.js'], // add more over time ... goal should be 100% coverage
|
src: lintFiles,
|
||||||
build: ['Gruntfile.js'],
|
build: ['Gruntfile.js'],
|
||||||
options: {
|
options: {
|
||||||
config: ".jscsrc",
|
config: ".jscsrc",
|
||||||
|
|
|
@ -2,4 +2,7 @@
|
||||||
* @see module:config/config
|
* @see module:config/config
|
||||||
* @module config
|
* @module config
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = require('./config.js');
|
module.exports = require('./config.js');
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
* @module config/localStorage
|
* @module config/localStorage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = LocalStorage;
|
module.exports = LocalStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function LocalStorage() {
|
function LocalStorage() {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the config out of the HTML5 local storage
|
* Reads the config out of the HTML5 local storage
|
||||||
|
@ -22,8 +23,9 @@ LocalStorage.prototype.read = function () {
|
||||||
if (cf === null) {
|
if (cf === null) {
|
||||||
this.config = this.default_config;
|
this.config = this.default_config;
|
||||||
this.write();
|
this.write();
|
||||||
} else
|
} else {
|
||||||
this.config = cf;
|
this.config = cf;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -202,8 +202,8 @@ module.exports = {
|
||||||
ablock = cipherfn.encrypt(ablock);
|
ablock = cipherfn.encrypt(ablock);
|
||||||
|
|
||||||
// test check octets
|
// test check octets
|
||||||
if (iblock[block_size - 2] != (ablock[0] ^ ciphertext[block_size]) ||
|
if (iblock[block_size - 2] !== (ablock[0] ^ ciphertext[block_size]) ||
|
||||||
iblock[block_size - 1] != (ablock[1] ^ ciphertext[block_size + 1])) {
|
iblock[block_size - 1] !== (ablock[1] ^ ciphertext[block_size + 1])) {
|
||||||
throw new Error('CFB decrypt: invalid key');
|
throw new Error('CFB decrypt: invalid key');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ module.exports = {
|
||||||
var blockc = new Uint8Array(block_size);
|
var blockc = new Uint8Array(block_size);
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
var cyphertext = new Uint8Array(plaintext.length);
|
var cyphertext = new Uint8Array(plaintext.length);
|
||||||
var j = 0;
|
var i, j = 0;
|
||||||
|
|
||||||
if (iv === null) {
|
if (iv === null) {
|
||||||
for (i = 0; i < block_size; i++) {
|
for (i = 0; i < block_size; i++) {
|
||||||
|
@ -276,7 +276,7 @@ module.exports = {
|
||||||
while (plaintext.length > block_size * pos) {
|
while (plaintext.length > block_size * pos) {
|
||||||
var encblock = cipherfn.encrypt(blockc);
|
var encblock = cipherfn.encrypt(blockc);
|
||||||
blocki = plaintext.subarray((pos * block_size), (pos * block_size) + block_size);
|
blocki = plaintext.subarray((pos * block_size), (pos * block_size) + block_size);
|
||||||
for (var i = 0; i < blocki.length; i++) {
|
for (i = 0; i < blocki.length; i++) {
|
||||||
blockc[i] = blocki[i] ^ encblock[i];
|
blockc[i] = blocki[i] ^ encblock[i];
|
||||||
cyphertext[j++] = blockc[i];
|
cyphertext[j++] = blockc[i];
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ module.exports = {
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
var plaintext = new Uint8Array(ciphertext.length);
|
var plaintext = new Uint8Array(ciphertext.length);
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
var j = 0;
|
var i, j = 0;
|
||||||
|
|
||||||
if (iv === null) {
|
if (iv === null) {
|
||||||
blockp = new Uint8Array(block_size);
|
blockp = new Uint8Array(block_size);
|
||||||
|
@ -307,7 +307,7 @@ module.exports = {
|
||||||
while (ciphertext.length > (block_size * pos)) {
|
while (ciphertext.length > (block_size * pos)) {
|
||||||
var decblock = cipherfn.encrypt(blockp);
|
var decblock = cipherfn.encrypt(blockp);
|
||||||
blockp = ciphertext.subarray((pos * (block_size)) + offset, (pos * (block_size)) + (block_size) + offset);
|
blockp = ciphertext.subarray((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[j++] = blockp[i] ^ decblock[i];
|
plaintext[j++] = blockp[i] ^ decblock[i];
|
||||||
}
|
}
|
||||||
pos++;
|
pos++;
|
||||||
|
|
|
@ -339,7 +339,9 @@ function packBytes(octets) {
|
||||||
var len = octets.length;
|
var len = octets.length;
|
||||||
var b = new Array(len / 4);
|
var b = new Array(len / 4);
|
||||||
|
|
||||||
if (!octets || len % 4) return;
|
if (!octets || len % 4) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0, j = 0; j < len; j += 4) {
|
for (i = 0, j = 0; j < len; j += 4) {
|
||||||
b[i++] = octets[j] | (octets[j + 1] << 8) | (octets[j + 2] << 16) | (octets[j + 3] << 24);
|
b[i++] = octets[j] | (octets[j + 1] << 8) | (octets[j + 2] << 16) | (octets[j + 3] << 24);
|
||||||
|
@ -377,13 +379,13 @@ function keyExpansion(key) {
|
||||||
var tk = new Array(maxkc);
|
var tk = new Array(maxkc);
|
||||||
var rconpointer = 0;
|
var rconpointer = 0;
|
||||||
|
|
||||||
if (keylen == 16) {
|
if (keylen === 16) {
|
||||||
rounds = 10;
|
rounds = 10;
|
||||||
kc = 4;
|
kc = 4;
|
||||||
} else if (keylen == 24) {
|
} else if (keylen === 24) {
|
||||||
rounds = 12;
|
rounds = 12;
|
||||||
kc = 6;
|
kc = 6;
|
||||||
} else if (keylen == 32) {
|
} else if (keylen === 32) {
|
||||||
rounds = 14;
|
rounds = 14;
|
||||||
kc = 8;
|
kc = 8;
|
||||||
} else {
|
} else {
|
||||||
|
@ -408,7 +410,7 @@ function keyExpansion(key) {
|
||||||
for (; (j < kc) && (t < 4); j++, t++) {
|
for (; (j < kc) && (t < 4); j++, t++) {
|
||||||
keySched[r][t] = tk[j];
|
keySched[r][t] = tk[j];
|
||||||
}
|
}
|
||||||
if (t == 4) {
|
if (t === 4) {
|
||||||
r++;
|
r++;
|
||||||
t = 0;
|
t = 0;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +422,7 @@ function keyExpansion(key) {
|
||||||
tk[0] ^= S[B1(temp)] | (S[B2(temp)] << 8) | (S[B3(temp)] << 16) | (S[B0(temp)] << 24);
|
tk[0] ^= S[B1(temp)] | (S[B2(temp)] << 8) | (S[B3(temp)] << 16) | (S[B0(temp)] << 24);
|
||||||
tk[0] ^= Rcon[rconpointer++];
|
tk[0] ^= Rcon[rconpointer++];
|
||||||
|
|
||||||
if (kc != 8) {
|
if (kc !== 8) {
|
||||||
for (j = 1; j < kc; j++) {
|
for (j = 1; j < kc; j++) {
|
||||||
tk[j] ^= tk[j - 1];
|
tk[j] ^= tk[j - 1];
|
||||||
}
|
}
|
||||||
|
@ -441,7 +443,7 @@ function keyExpansion(key) {
|
||||||
for (; (j < kc) && (t < 4); j++, t++) {
|
for (; (j < kc) && (t < 4); j++, t++) {
|
||||||
keySched[r][t] = tk[j];
|
keySched[r][t] = tk[j];
|
||||||
}
|
}
|
||||||
if (t == 4) {
|
if (t === 4) {
|
||||||
r++;
|
r++;
|
||||||
t = 0;
|
t = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
* @module crypto/cipher/blowfish
|
* @module crypto/cipher/blowfish
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Javascript implementation based on Bruce Schneier's reference implementation.
|
* Javascript implementation based on Bruce Schneier's reference implementation.
|
||||||
*
|
*
|
||||||
|
@ -393,12 +395,6 @@ Blowfish.prototype.init = function(key) {
|
||||||
|
|
||||||
// added by Recurity Labs
|
// added by Recurity Labs
|
||||||
|
|
||||||
function BFencrypt(block, key) {
|
|
||||||
var bf = new Blowfish();
|
|
||||||
bf.init(key);
|
|
||||||
return bf.encrypt_block(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
function BF(key) {
|
function BF(key) {
|
||||||
this.bf = new Blowfish();
|
this.bf = new Blowfish();
|
||||||
this.bf.init(key);
|
this.bf.init(key);
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
/** @module crypto/cipher/cast5 */
|
/** @module crypto/cipher/cast5 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function OpenpgpSymencCast5() {
|
||||||
function openpgp_symenc_cast5() {
|
|
||||||
this.BlockSize = 8;
|
this.BlockSize = 8;
|
||||||
this.KeySize = 16;
|
this.KeySize = 16;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ function openpgp_symenc_cast5() {
|
||||||
|
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
||||||
if (key.length == this.KeySize) {
|
if (key.length === this.KeySize) {
|
||||||
this.keySchedule(key);
|
this.keySchedule(key);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('CAST-128: keys must be 16 bytes');
|
throw new Error('CAST-128: keys must be 16 bytes');
|
||||||
|
@ -44,7 +44,7 @@ function openpgp_symenc_cast5() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getBlockSize = function() {
|
this.getBlockSize = function() {
|
||||||
return BlockSize;
|
return this.BlockSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.encrypt = function(src) {
|
this.encrypt = function(src) {
|
||||||
|
@ -592,8 +592,8 @@ function openpgp_symenc_cast5() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cast5(key) {
|
function Cast5(key) {
|
||||||
this.cast5 = new openpgp_symenc_cast5();
|
this.cast5 = new OpenpgpSymencCast5();
|
||||||
this.cast5.setKey(key);
|
this.cast5.setKey(key);
|
||||||
|
|
||||||
this.encrypt = function(block) {
|
this.encrypt = function(block) {
|
||||||
|
@ -601,6 +601,6 @@ function cast5(key) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = cast5;
|
module.exports = Cast5;
|
||||||
module.exports.blockSize = cast5.prototype.blockSize = 8;
|
module.exports.blockSize = Cast5.prototype.blockSize = 8;
|
||||||
module.exports.keySize = cast5.prototype.keySize = 16;
|
module.exports.keySize = Cast5.prototype.keySize = 16;
|
||||||
|
|
|
@ -81,14 +81,14 @@ function des(keys, message, encrypt, mode, iv, padding) {
|
||||||
|
|
||||||
//create the 16 or 48 subkeys we will need
|
//create the 16 or 48 subkeys we will need
|
||||||
var m = 0,
|
var m = 0,
|
||||||
i, j, temp, temp2, right1, right2, left, right, looping;
|
i, j, temp, right1, right2, left, right, looping;
|
||||||
var cbcleft, cbcleft2, cbcright, cbcright2;
|
var cbcleft, cbcleft2, cbcright, cbcright2;
|
||||||
var endloop, loopinc;
|
var endloop, loopinc;
|
||||||
var len = message.length;
|
var len = message.length;
|
||||||
|
|
||||||
//set up the loops for single and triple des
|
//set up the loops for single and triple des
|
||||||
var iterations = keys.length == 32 ? 3 : 9; //single or triple des
|
var iterations = keys.length === 32 ? 3 : 9; //single or triple des
|
||||||
if (iterations == 3) {
|
if (iterations === 3) {
|
||||||
looping = encrypt ? new Array(0, 32, 2) : new Array(30, -2, -2);
|
looping = encrypt ? new Array(0, 32, 2) : new Array(30, -2, -2);
|
||||||
} else {
|
} else {
|
||||||
looping = encrypt ? new Array(0, 32, 2, 62, 30, -2, 64, 96, 2) : new Array(94, 62, -2, 32, 64, 2, 30, -2, -2);
|
looping = encrypt ? new Array(0, 32, 2, 62, 30, -2, 64, 96, 2) : new Array(94, 62, -2, 32, 64, 2, 30, -2, -2);
|
||||||
|
@ -105,7 +105,7 @@ function des(keys, message, encrypt, mode, iv, padding) {
|
||||||
var result = new Uint8Array(len);
|
var result = new Uint8Array(len);
|
||||||
var k = 0;
|
var k = 0;
|
||||||
|
|
||||||
if (mode == 1) { //CBC mode
|
if (mode === 1) { //CBC mode
|
||||||
cbcleft = (iv[m++] << 24) | (iv[m++] << 16) | (iv[m++] << 8) | iv[m++];
|
cbcleft = (iv[m++] << 24) | (iv[m++] << 16) | (iv[m++] << 8) | iv[m++];
|
||||||
cbcright = (iv[m++] << 24) | (iv[m++] << 16) | (iv[m++] << 8) | iv[m++];
|
cbcright = (iv[m++] << 24) | (iv[m++] << 16) | (iv[m++] << 8) | iv[m++];
|
||||||
m = 0;
|
m = 0;
|
||||||
|
@ -117,7 +117,7 @@ function des(keys, message, encrypt, mode, iv, padding) {
|
||||||
right = (message[m++] << 24) | (message[m++] << 16) | (message[m++] << 8) | message[m++];
|
right = (message[m++] << 24) | (message[m++] << 16) | (message[m++] << 8) | message[m++];
|
||||||
|
|
||||||
//for Cipher Block Chaining mode, xor the message with the previous result
|
//for Cipher Block Chaining mode, xor the message with the previous result
|
||||||
if (mode == 1) {
|
if (mode === 1) {
|
||||||
if (encrypt) {
|
if (encrypt) {
|
||||||
left ^= cbcleft;
|
left ^= cbcleft;
|
||||||
right ^= cbcright;
|
right ^= cbcright;
|
||||||
|
@ -154,7 +154,7 @@ function des(keys, message, encrypt, mode, iv, padding) {
|
||||||
endloop = looping[j + 1];
|
endloop = looping[j + 1];
|
||||||
loopinc = looping[j + 2];
|
loopinc = looping[j + 2];
|
||||||
//now go through and perform the encryption or decryption
|
//now go through and perform the encryption or decryption
|
||||||
for (i = looping[j]; i != endloop; i += loopinc) { //for efficiency
|
for (i = looping[j]; i !== endloop; i += loopinc) { //for efficiency
|
||||||
right1 = right ^ keys[i];
|
right1 = right ^ keys[i];
|
||||||
right2 = ((right >>> 4) | (right << 28)) ^ keys[i + 1];
|
right2 = ((right >>> 4) | (right << 28)) ^ keys[i + 1];
|
||||||
//the result is attained by passing these bytes through the S selection functions
|
//the result is attained by passing these bytes through the S selection functions
|
||||||
|
@ -191,7 +191,7 @@ function des(keys, message, encrypt, mode, iv, padding) {
|
||||||
left ^= (temp << 4);
|
left ^= (temp << 4);
|
||||||
|
|
||||||
//for Cipher Block Chaining mode, xor the message with the previous result
|
//for Cipher Block Chaining mode, xor the message with the previous result
|
||||||
if (mode == 1) {
|
if (mode === 1) {
|
||||||
if (encrypt) {
|
if (encrypt) {
|
||||||
cbcleft = left;
|
cbcleft = left;
|
||||||
cbcright = right;
|
cbcright = right;
|
||||||
|
@ -335,13 +335,13 @@ function des_addPadding(message, padding) {
|
||||||
var padLength = 8 - (message.length % 8);
|
var padLength = 8 - (message.length % 8);
|
||||||
|
|
||||||
var pad;
|
var pad;
|
||||||
if (padding == 2 && (padLength < 8)) { //pad the message with spaces
|
if (padding === 2 && (padLength < 8)) { //pad the message with spaces
|
||||||
pad = " ".charCodeAt(0);
|
pad = " ".charCodeAt(0);
|
||||||
} else if (padding == 1) { //PKCS7 padding
|
} else if (padding === 1) { //PKCS7 padding
|
||||||
pad = padLength;
|
pad = padLength;
|
||||||
} else if (!padding && (padLength < 8)) { //pad the message out with null bytes
|
} else if (!padding && (padLength < 8)) { //pad the message out with null bytes
|
||||||
pad = 0;
|
pad = 0;
|
||||||
} else if (padLength == 8) {
|
} else if (padLength === 8) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -362,9 +362,9 @@ function des_addPadding(message, padding) {
|
||||||
function des_removePadding(message, padding) {
|
function des_removePadding(message, padding) {
|
||||||
var padLength = null;
|
var padLength = null;
|
||||||
var pad;
|
var pad;
|
||||||
if (padding == 2) { // space padded
|
if (padding === 2) { // space padded
|
||||||
pad = " ".charCodeAt(0);
|
pad = " ".charCodeAt(0);
|
||||||
} else if (padding == 1) { // PKCS7
|
} else if (padding === 1) { // PKCS7
|
||||||
padLength = message[message.length - 1];
|
padLength = message[message.length - 1];
|
||||||
} else if (!padding) { // null padding
|
} else if (!padding) { // null padding
|
||||||
pad = 0;
|
pad = 0;
|
||||||
|
@ -384,9 +384,6 @@ function des_removePadding(message, padding) {
|
||||||
return message.subarray(0, message.length - padLength);
|
return message.subarray(0, message.length - padLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var util = require('../../util.js');
|
|
||||||
|
|
||||||
// added by Recurity Labs
|
// added by Recurity Labs
|
||||||
|
|
||||||
function Des(key) {
|
function Des(key) {
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* @module crypto/cipher
|
* @module crypto/cipher
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var desModule = require('./des.js');
|
var desModule = require('./des.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
* @module crypto/cipher/twofish
|
* @module crypto/cipher/twofish
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//Math
|
//Math
|
||||||
|
@ -42,10 +42,6 @@ function setW(a, i, w) {
|
||||||
a.splice(i, 4, w & 0xFF, (w >>> 8) & 0xFF, (w >>> 16) & 0xFF, (w >>> 24) & 0xFF);
|
a.splice(i, 4, w & 0xFF, (w >>> 8) & 0xFF, (w >>> 16) & 0xFF, (w >>> 24) & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setWInv(a, i, w) {
|
|
||||||
a.splice(i, 4, (w >>> 24) & 0xFF, (w >>> 16) & 0xFF, (w >>> 8) & 0xFF, w & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getB(x, n) {
|
function getB(x, n) {
|
||||||
return (x >>> (n * 8)) & 0xFF;
|
return (x >>> (n * 8)) & 0xFF;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +172,9 @@ function createTwofish() {
|
||||||
|
|
||||||
keyBytes = keyBytes.slice(0, 32);
|
keyBytes = keyBytes.slice(0, 32);
|
||||||
i = keyBytes.length;
|
i = keyBytes.length;
|
||||||
while (i != 16 && i != 24 && i != 32)
|
while (i !== 16 && i !== 24 && i !== 32) {
|
||||||
keyBytes[i++] = 0;
|
keyBytes[i++] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < keyBytes.length; i += 4) {
|
for (i = 0; i < keyBytes.length; i += 4) {
|
||||||
inKey[i >> 2] = getW(keyBytes, i);
|
inKey[i >> 2] = getW(keyBytes, i);
|
||||||
|
@ -334,15 +331,6 @@ function createTwofish() {
|
||||||
|
|
||||||
// added by Recurity Labs
|
// added by Recurity Labs
|
||||||
|
|
||||||
function TFencrypt(block, key) {
|
|
||||||
var block_copy = toArray(block);
|
|
||||||
var tf = createTwofish();
|
|
||||||
tf.open(toArray(key), 0);
|
|
||||||
var result = tf.encrypt(block_copy, 0);
|
|
||||||
tf.close();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function TF(key) {
|
function TF(key) {
|
||||||
this.tf = createTwofish();
|
this.tf = createTwofish();
|
||||||
this.tf.open(toArray(key), 0);
|
this.tf.open(toArray(key), 0);
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
* @module crypto/crypto
|
* @module crypto/crypto
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var random = require('./random.js'),
|
var random = require('./random.js'),
|
||||||
cipher = require('./cipher'),
|
cipher = require('./cipher'),
|
||||||
publicKey = require('./public_key'),
|
publicKey = require('./public_key'),
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
* @module crypto/hash/md5
|
* @module crypto/hash/md5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var util = require('../../util.js');
|
var util = require('../../util.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,12 +142,15 @@ function md51(s) {
|
||||||
}
|
}
|
||||||
s = s.substring(i - 64);
|
s = s.substring(i - 64);
|
||||||
var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
for (i = 0; i < s.length; i++)
|
for (i = 0; i < s.length; i++) {
|
||||||
tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);
|
tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);
|
||||||
|
}
|
||||||
tail[i >> 2] |= 0x80 << ((i % 4) << 3);
|
tail[i >> 2] |= 0x80 << ((i % 4) << 3);
|
||||||
if (i > 55) {
|
if (i > 55) {
|
||||||
md5cycle(state, tail);
|
md5cycle(state, tail);
|
||||||
for (i = 0; i < 16; i++) tail[i] = 0;
|
for (i = 0; i < 16; i++) {
|
||||||
|
tail[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tail[14] = n * 8;
|
tail[14] = n * 8;
|
||||||
md5cycle(state, tail);
|
md5cycle(state, tail);
|
||||||
|
@ -182,14 +187,16 @@ var hex_chr = '0123456789abcdef'.split('');
|
||||||
function rhex(n) {
|
function rhex(n) {
|
||||||
var s = '',
|
var s = '',
|
||||||
j = 0;
|
j = 0;
|
||||||
for (; j < 4; j++)
|
for (; j < 4; j++) {
|
||||||
s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F];
|
s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F];
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hex(x) {
|
function hex(x) {
|
||||||
for (var i = 0; i < x.length; i++)
|
for (var i = 0; i < x.length; i++) {
|
||||||
x[i] = rhex(x[i]);
|
x[i] = rhex(x[i]);
|
||||||
|
}
|
||||||
return x.join('');
|
return x.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,11 +213,3 @@ generated by an if clause. */
|
||||||
function add32(a, b) {
|
function add32(a, b) {
|
||||||
return (a + b) & 0xFFFFFFFF;
|
return (a + b) & 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
|
|
||||||
function add32(x, y) {
|
|
||||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
|
|
||||||
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
||||||
return (msw << 16) | (lsw & 0xFFFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
* @module crypto/pkcs1
|
* @module crypto/pkcs1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ASN1 object identifiers for hashes (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.2})
|
* ASN1 object identifiers for hashes (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.2})
|
||||||
*/
|
*/
|
||||||
|
@ -47,8 +49,7 @@ hash_headers[11] = [0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
|
||||||
0x00, 0x04, 0x1C
|
0x00, 0x04, 0x1C
|
||||||
];
|
];
|
||||||
|
|
||||||
var crypto = require('./crypto.js'),
|
var random = require('./random.js'),
|
||||||
random = require('./random.js'),
|
|
||||||
util = require('../util.js'),
|
util = require('../util.js'),
|
||||||
BigInteger = require('./public_key/jsbn.js'),
|
BigInteger = require('./public_key/jsbn.js'),
|
||||||
hash = require('./hash');
|
hash = require('./hash');
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
* @module crypto/public_key/dsa
|
* @module crypto/public_key/dsa
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var BigInteger = require('./jsbn.js'),
|
var BigInteger = require('./jsbn.js'),
|
||||||
random = require('../random.js'),
|
random = require('../random.js'),
|
||||||
hashModule = require('../hash'),
|
hashModule = require('../hash'),
|
||||||
|
@ -52,7 +54,7 @@ function DSA() {
|
||||||
k = random.getRandomBigIntegerInRange(BigInteger.ONE, q.subtract(BigInteger.ONE));
|
k = random.getRandomBigIntegerInRange(BigInteger.ONE, q.subtract(BigInteger.ONE));
|
||||||
s1 = (g.modPow(k, p)).mod(q);
|
s1 = (g.modPow(k, p)).mod(q);
|
||||||
s2 = (k.modInverse(q).multiply(hash.add(x.multiply(s1)))).mod(q);
|
s2 = (k.modInverse(q).multiply(hash.add(x.multiply(s1)))).mod(q);
|
||||||
if (s1 != 0 && s2 != 0) {
|
if (s1 !== 0 && s2 !== 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,28 +75,30 @@ function DSA() {
|
||||||
switch (Math.round(q.bitLength() / 8)) {
|
switch (Math.round(q.bitLength() / 8)) {
|
||||||
case 20:
|
case 20:
|
||||||
// 1024 bit
|
// 1024 bit
|
||||||
if (usersetting != 2 &&
|
if (usersetting !== 2 &&
|
||||||
usersetting > 11 &&
|
usersetting > 11 &&
|
||||||
usersetting != 10 &&
|
usersetting !== 10 &&
|
||||||
usersetting < 8)
|
usersetting < 8) {
|
||||||
return 2; // prefer sha1
|
return 2; // prefer sha1
|
||||||
|
}
|
||||||
return usersetting;
|
return usersetting;
|
||||||
case 28:
|
case 28:
|
||||||
// 2048 bit
|
// 2048 bit
|
||||||
if (usersetting > 11 &&
|
if (usersetting > 11 &&
|
||||||
usersetting < 8)
|
usersetting < 8) {
|
||||||
return 11;
|
return 11;
|
||||||
|
}
|
||||||
return usersetting;
|
return usersetting;
|
||||||
case 32:
|
case 32:
|
||||||
// 4096 bit // prefer sha224
|
// 4096 bit // prefer sha224
|
||||||
if (usersetting > 10 &&
|
if (usersetting > 10 &&
|
||||||
usersetting < 8)
|
usersetting < 8) {
|
||||||
return 8; // prefer sha256
|
return 8; // prefer sha256
|
||||||
|
}
|
||||||
return usersetting;
|
return usersetting;
|
||||||
default:
|
default:
|
||||||
util.print_debug("DSA select hash algorithm: returning null for an unknown length of q");
|
util.print_debug("DSA select hash algorithm: returning null for an unknown length of q");
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.select_hash_algorithm = select_hash_algorithm;
|
this.select_hash_algorithm = select_hash_algorithm;
|
||||||
|
@ -110,7 +114,7 @@ function DSA() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var w = s2.modInverse(q);
|
var w = s2.modInverse(q);
|
||||||
if (BigInteger.ZERO.compareTo(w) == 0) {
|
if (BigInteger.ZERO.compareTo(w) === 0) {
|
||||||
util.print_debug("invalid DSA Signature");
|
util.print_debug("invalid DSA Signature");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -119,68 +123,8 @@ function DSA() {
|
||||||
return g.modPow(u1, p).multiply(y.modPow(u2, p)).mod(p).mod(q);
|
return g.modPow(u1, p).multiply(y.modPow(u2, p)).mod(p).mod(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 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 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 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.sign = sign;
|
||||||
this.verify = verify;
|
this.verify = verify;
|
||||||
// this.generate = generateKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = DSA;
|
module.exports = DSA;
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
* @module crypto/public_key/elgamal
|
* @module crypto/public_key/elgamal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var BigInteger = require('./jsbn.js'),
|
var BigInteger = require('./jsbn.js'),
|
||||||
random = require('../random.js'),
|
random = require('../random.js'),
|
||||||
util = require('../../util.js');
|
util = require('../../util.js');
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
* @requires crypto/public_key/rsa
|
* @requires crypto/public_key/rsa
|
||||||
* @module crypto/public_key
|
* @module crypto/public_key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/** @see module:crypto/public_key/rsa */
|
/** @see module:crypto/public_key/rsa */
|
||||||
rsa: require('./rsa.js'),
|
rsa: require('./rsa.js'),
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
* @requires crypto/public_key
|
* @requires crypto/public_key
|
||||||
* @module crypto/signature */
|
* @module crypto/signature */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var util = require('../util'),
|
var util = require('../util'),
|
||||||
publicKey = require('./public_key'),
|
publicKey = require('./public_key'),
|
||||||
pkcs1 = require('./pkcs1.js'),
|
pkcs1 = require('./pkcs1.js');
|
||||||
hashModule = require('./hash');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +22,7 @@ module.exports = {
|
||||||
* @return {Boolean} true if signature (sig_data was equal to data over hash)
|
* @return {Boolean} true if signature (sig_data was equal to data over hash)
|
||||||
*/
|
*/
|
||||||
verify: function(algo, hash_algo, msg_MPIs, publickey_MPIs, data) {
|
verify: function(algo, hash_algo, msg_MPIs, publickey_MPIs, data) {
|
||||||
|
var m;
|
||||||
|
|
||||||
data = util.Uint8Array2str(data);
|
data = util.Uint8Array2str(data);
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ module.exports = {
|
||||||
var n = publickey_MPIs[0].toBigInteger();
|
var n = publickey_MPIs[0].toBigInteger();
|
||||||
var k = publickey_MPIs[0].byteLength();
|
var k = publickey_MPIs[0].byteLength();
|
||||||
var e = publickey_MPIs[1].toBigInteger();
|
var e = publickey_MPIs[1].toBigInteger();
|
||||||
var m = msg_MPIs[0].toBigInteger();
|
m = msg_MPIs[0].toBigInteger();
|
||||||
var EM = rsa.verify(m, e, n);
|
var EM = rsa.verify(m, e, n);
|
||||||
var EM2 = pkcs1.emsa.encode(hash_algo, data, k);
|
var EM2 = pkcs1.emsa.encode(hash_algo, data, k);
|
||||||
return EM.compareTo(EM2) === 0;
|
return EM.compareTo(EM2) === 0;
|
||||||
|
@ -51,7 +53,7 @@ module.exports = {
|
||||||
var q = publickey_MPIs[1].toBigInteger();
|
var q = publickey_MPIs[1].toBigInteger();
|
||||||
var g = publickey_MPIs[2].toBigInteger();
|
var g = publickey_MPIs[2].toBigInteger();
|
||||||
var y = publickey_MPIs[3].toBigInteger();
|
var y = publickey_MPIs[3].toBigInteger();
|
||||||
var m = data;
|
m = data;
|
||||||
var dopublic = dsa.verify(hash_algo, s1, s2, m, p, q, g, y);
|
var dopublic = dsa.verify(hash_algo, s1, s2, m, p, q, g, y);
|
||||||
return dopublic.compareTo(s1) === 0;
|
return dopublic.compareTo(s1) === 0;
|
||||||
default:
|
default:
|
||||||
|
@ -97,7 +99,6 @@ module.exports = {
|
||||||
var p = keyIntegers[0].toBigInteger();
|
var p = keyIntegers[0].toBigInteger();
|
||||||
var q = keyIntegers[1].toBigInteger();
|
var q = keyIntegers[1].toBigInteger();
|
||||||
var g = keyIntegers[2].toBigInteger();
|
var g = keyIntegers[2].toBigInteger();
|
||||||
var y = keyIntegers[3].toBigInteger();
|
|
||||||
var x = keyIntegers[4].toBigInteger();
|
var x = keyIntegers[4].toBigInteger();
|
||||||
m = data;
|
m = data;
|
||||||
var result = dsa.sign(hash_algo, m, g, p, q, x);
|
var result = dsa.sign(hash_algo, m, g, p, q, x);
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
* @module encoding/armor
|
* @module encoding/armor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var base64 = require('./base64.js'),
|
var base64 = require('./base64.js'),
|
||||||
enums = require('../enums.js'),
|
enums = require('../enums.js'),
|
||||||
config = require('../config');
|
config = require('../config');
|
||||||
|
@ -129,7 +131,7 @@ function getCheckSum(data) {
|
||||||
function verifyCheckSum(data, checksum) {
|
function verifyCheckSum(data, checksum) {
|
||||||
var c = getCheckSum(data);
|
var c = getCheckSum(data);
|
||||||
var d = checksum;
|
var d = checksum;
|
||||||
return c[0] == d[0] && c[1] == d[1] && c[2] == d[2] && c[3] == d[3];
|
return c[0] === d[0] && c[1] === d[1] && c[2] === d[2] && c[3] === d[3];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Internal function to calculate a CRC-24 checksum over a given string (data)
|
* Internal function to calculate a CRC-24 checksum over a given string (data)
|
||||||
|
@ -291,11 +293,11 @@ function dearmor(text) {
|
||||||
|
|
||||||
var result, checksum, msg;
|
var result, checksum, msg;
|
||||||
|
|
||||||
if (text.search(reSplit) != splittext[0].length) {
|
if (text.search(reSplit) !== splittext[0].length) {
|
||||||
indexBase = 0;
|
indexBase = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != 2) {
|
if (type !== 2) {
|
||||||
msg = splitHeaders(splittext[indexBase]);
|
msg = splitHeaders(splittext[indexBase]);
|
||||||
var msg_sum = splitChecksum(msg.body);
|
var msg_sum = splitChecksum(msg.body);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
* @module encoding/base64
|
* @module encoding/base64
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var b64s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
var b64s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,35 +38,40 @@ function s2r(t, o) {
|
||||||
if (s === 0) {
|
if (s === 0) {
|
||||||
r.push(b64s.charAt((c >> 2) & 63));
|
r.push(b64s.charAt((c >> 2) & 63));
|
||||||
a = (c & 3) << 4;
|
a = (c & 3) << 4;
|
||||||
} else if (s == 1) {
|
} else if (s === 1) {
|
||||||
r.push(b64s.charAt((a | (c >> 4) & 15)));
|
r.push(b64s.charAt((a | (c >> 4) & 15)));
|
||||||
a = (c & 15) << 2;
|
a = (c & 15) << 2;
|
||||||
} else if (s == 2) {
|
} else if (s === 2) {
|
||||||
r.push(b64s.charAt(a | ((c >> 6) & 3)));
|
r.push(b64s.charAt(a | ((c >> 6) & 3)));
|
||||||
l += 1;
|
l += 1;
|
||||||
if ((l % 60) === 0)
|
if ((l % 60) === 0) {
|
||||||
r.push("\n");
|
r.push("\n");
|
||||||
|
}
|
||||||
r.push(b64s.charAt(c & 63));
|
r.push(b64s.charAt(c & 63));
|
||||||
}
|
}
|
||||||
l += 1;
|
l += 1;
|
||||||
if ((l % 60) === 0)
|
if ((l % 60) === 0) {
|
||||||
r.push("\n");
|
r.push("\n");
|
||||||
|
}
|
||||||
|
|
||||||
s += 1;
|
s += 1;
|
||||||
if (s == 3)
|
if (s === 3) {
|
||||||
s = 0;
|
s = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (s > 0) {
|
if (s > 0) {
|
||||||
r.push(b64s.charAt(a));
|
r.push(b64s.charAt(a));
|
||||||
l += 1;
|
l += 1;
|
||||||
if ((l % 60) === 0)
|
if ((l % 60) === 0) {
|
||||||
r.push("\n");
|
r.push("\n");
|
||||||
|
}
|
||||||
r.push('=');
|
r.push('=');
|
||||||
l += 1;
|
l += 1;
|
||||||
}
|
}
|
||||||
if (s == 1) {
|
if (s === 1) {
|
||||||
if ((l % 60) === 0)
|
if ((l % 60) === 0) {
|
||||||
r.push("\n");
|
r.push("\n");
|
||||||
|
}
|
||||||
r.push('=');
|
r.push('=');
|
||||||
}
|
}
|
||||||
if (o)
|
if (o)
|
||||||
|
@ -91,8 +98,9 @@ function r2s(t) {
|
||||||
for (n = 0; n < tl; n++) {
|
for (n = 0; n < tl; n++) {
|
||||||
c = b64s.indexOf(t.charAt(n));
|
c = b64s.indexOf(t.charAt(n));
|
||||||
if (c >= 0) {
|
if (c >= 0) {
|
||||||
if (s)
|
if (s) {
|
||||||
r.push(a | (c >> (6 - s)) & 255);
|
r.push(a | (c >> (6 - s)) & 255);
|
||||||
|
}
|
||||||
s = (s + 2) & 7;
|
s = (s + 2) & 7;
|
||||||
a = (c << s) & 255;
|
a = (c << s) & 255;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see module:hkp/hkp
|
* @see module:hkp/hkp
|
||||||
* @module hkp
|
* @module hkp
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see module:keyring/keyring
|
* @see module:keyring/keyring
|
||||||
* @module keyring
|
* @module keyring
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
* @module keyring/keyring
|
* @module keyring/keyring
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var enums = require('../enums.js'),
|
'use strict';
|
||||||
keyModule = require('../key.js'),
|
|
||||||
util = require('../util.js');
|
var keyModule = require('../key.js');
|
||||||
|
|
||||||
module.exports = Keyring;
|
module.exports = Keyring;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization routine for the keyring. This method reads the
|
* Initialization routine for the keyring. This method reads the
|
||||||
* keyring from HTML5 local storage and initializes this instance.
|
* keyring from HTML5 local storage and initializes this instance.
|
||||||
* @constructor
|
* @constructor
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
* @module keyring/localstore
|
* @module keyring/localstore
|
||||||
* @param {String} prefix prefix for itemnames in localstore
|
* @param {String} prefix prefix for itemnames in localstore
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = LocalStore;
|
module.exports = LocalStore;
|
||||||
|
|
||||||
var config = require('../config'),
|
var config = require('../config'),
|
||||||
|
@ -31,7 +34,7 @@ function LocalStore(prefix) {
|
||||||
prefix = prefix || 'openpgp-';
|
prefix = prefix || 'openpgp-';
|
||||||
this.publicKeysItem = prefix + this.publicKeysItem;
|
this.publicKeysItem = prefix + this.publicKeysItem;
|
||||||
this.privateKeysItem = prefix + this.privateKeysItem;
|
this.privateKeysItem = prefix + this.privateKeysItem;
|
||||||
if (typeof window != 'undefined' && window.localStorage) {
|
if (typeof window !== 'undefined' && window.localStorage) {
|
||||||
this.storage = window.localStorage;
|
this.storage = window.localStorage;
|
||||||
} else {
|
} else {
|
||||||
this.storage = new (require('node-localstorage').LocalStorage)(config.node_store);
|
this.storage = new (require('node-localstorage').LocalStorage)(config.node_store);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @module packet
|
* @module packet
|
||||||
|
@ -57,10 +59,10 @@ module.exports = {
|
||||||
var tagName = enums.read(enums.packet, packetClone.tag);
|
var tagName = enums.read(enums.packet, packetClone.tag);
|
||||||
var packet = this.newPacketFromTag(tagName);
|
var packet = this.newPacketFromTag(tagName);
|
||||||
for (var attr in packetClone) {
|
for (var attr in packetClone) {
|
||||||
if (packetClone.hasOwnProperty(attr)) {
|
if (packetClone.hasOwnProperty(attr)) {
|
||||||
packet[attr] = packetClone[attr];
|
packet[attr] = packetClone[attr];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (packet.postCloneTypeFix) {
|
if (packet.postCloneTypeFix) {
|
||||||
packet.postCloneTypeFix();
|
packet.postCloneTypeFix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
* @module packet/compressed
|
* @module packet/compressed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = Compressed;
|
module.exports = Compressed;
|
||||||
|
|
||||||
var enums = require('../enums.js'),
|
var enums = require('../enums.js'),
|
||||||
|
@ -85,8 +87,9 @@ Compressed.prototype.read = function (bytes) {
|
||||||
* @return {String} binary compressed packet
|
* @return {String} binary compressed packet
|
||||||
*/
|
*/
|
||||||
Compressed.prototype.write = function () {
|
Compressed.prototype.write = function () {
|
||||||
if (this.compressed === null)
|
if (this.compressed === null) {
|
||||||
this.compress();
|
this.compress();
|
||||||
|
}
|
||||||
|
|
||||||
return util.concatUint8Array(new Uint8Array([enums.write(enums.compression, this.algorithm)]), this.compressed);
|
return util.concatUint8Array(new Uint8Array([enums.write(enums.compression, this.algorithm)]), this.compressed);
|
||||||
};
|
};
|
||||||
|
@ -97,7 +100,7 @@ Compressed.prototype.write = function () {
|
||||||
* read by read_packet
|
* read by read_packet
|
||||||
*/
|
*/
|
||||||
Compressed.prototype.decompress = function () {
|
Compressed.prototype.decompress = function () {
|
||||||
var decompressed;
|
var decompressed, inflate;
|
||||||
|
|
||||||
switch (this.algorithm) {
|
switch (this.algorithm) {
|
||||||
case 'uncompressed':
|
case 'uncompressed':
|
||||||
|
@ -105,12 +108,12 @@ Compressed.prototype.decompress = function () {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'zip':
|
case 'zip':
|
||||||
var inflate = new RawInflate.Zlib.RawInflate(this.compressed);
|
inflate = new RawInflate.Zlib.RawInflate(this.compressed);
|
||||||
decompressed = inflate.decompress();
|
decompressed = inflate.decompress();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'zlib':
|
case 'zlib':
|
||||||
var inflate = new Zlib.Zlib.Inflate(this.compressed);
|
inflate = new Zlib.Zlib.Inflate(this.compressed);
|
||||||
decompressed = inflate.decompress();
|
decompressed = inflate.decompress();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var enums = require('../enums.js');
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
|
@ -10,5 +10,6 @@ module.exports = {
|
||||||
|
|
||||||
var packets = require('./all_packets.js');
|
var packets = require('./all_packets.js');
|
||||||
|
|
||||||
for (var i in packets)
|
for (var i in packets) {
|
||||||
module.exports[i] = packets[i];
|
module.exports[i] = packets[i];
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
* @module packet/literal
|
* @module packet/literal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = Literal;
|
module.exports = Literal;
|
||||||
|
|
||||||
var util = require('../util.js'),
|
var util = require('../util.js'),
|
||||||
|
@ -50,7 +52,7 @@ Literal.prototype.setText = function (text) {
|
||||||
// normalize EOL to \r\n
|
// normalize EOL to \r\n
|
||||||
text = text.replace(/\r/g, '').replace(/\n/g, '\r\n');
|
text = text.replace(/\r/g, '').replace(/\n/g, '\r\n');
|
||||||
// encode UTF8
|
// encode UTF8
|
||||||
this.data = this.format == 'utf8' ? util.str2Uint8Array(util.encode_utf8(text)) : util.str2Uint8Array(text);
|
this.data = this.format === 'utf8' ? util.str2Uint8Array(util.encode_utf8(text)) : util.str2Uint8Array(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
* @module packet/marker
|
* @module packet/marker
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = Marker;
|
module.exports = Marker;
|
||||||
|
|
||||||
var enums = require('../enums.js');
|
var enums = require('../enums.js');
|
||||||
|
@ -52,10 +54,11 @@ function Marker() {
|
||||||
* @return {module:packet/marker} Object representation
|
* @return {module:packet/marker} Object representation
|
||||||
*/
|
*/
|
||||||
Marker.prototype.read = function (bytes) {
|
Marker.prototype.read = function (bytes) {
|
||||||
if (bytes[0] == 0x50 && // P
|
if (bytes[0] === 0x50 && // P
|
||||||
bytes[1] == 0x47 && // G
|
bytes[1] === 0x47 && // G
|
||||||
bytes[2] == 0x50) // P
|
bytes[2] === 0x50) { // P
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
// marker packet does not contain "PGP"
|
// marker packet does not contain "PGP"
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
* @module packet/one_pass_signature
|
* @module packet/one_pass_signature
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = OnePassSignature;
|
module.exports = OnePassSignature;
|
||||||
|
|
||||||
var util = require('../util.js'),
|
var util = require('../util.js'),
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
* @module packet/packet
|
* @module packet/packet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var enums = require('../enums.js'),
|
'use strict';
|
||||||
util = require('../util.js');
|
|
||||||
|
var util = require('../util.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
readSimpleLength: function(bytes) {
|
readSimpleLength: function(bytes) {
|
||||||
|
@ -37,7 +38,7 @@ module.exports = {
|
||||||
} else if (type < 255) {
|
} else if (type < 255) {
|
||||||
len = ((bytes[0] - 192) << 8) + (bytes[1]) + 192;
|
len = ((bytes[0] - 192) << 8) + (bytes[1]) + 192;
|
||||||
offset = 2;
|
offset = 2;
|
||||||
} else if (type == 255) {
|
} else if (type === 255) {
|
||||||
len = util.readNumber(bytes.subarray(1, 1 + 4));
|
len = util.readNumber(bytes.subarray(1, 1 + 4));
|
||||||
offset = 5;
|
offset = 5;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +236,7 @@ module.exports = {
|
||||||
|
|
||||||
// if there was'nt a partial body length: use the specified
|
// if there was'nt a partial body length: use the specified
|
||||||
// packet_length
|
// packet_length
|
||||||
if (real_packet_length == -1) {
|
if (real_packet_length === -1) {
|
||||||
real_packet_length = packet_length;
|
real_packet_length = packet_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
* @module packet/packetlist
|
* @module packet/packetlist
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = Packetlist;
|
module.exports = Packetlist;
|
||||||
|
|
||||||
var util = require('../util'),
|
var util = require('../util'),
|
||||||
|
@ -67,7 +69,9 @@ Packetlist.prototype.write = function () {
|
||||||
* writing to packetlist[i] directly will result in an error.
|
* writing to packetlist[i] directly will result in an error.
|
||||||
*/
|
*/
|
||||||
Packetlist.prototype.push = function (packet) {
|
Packetlist.prototype.push = function (packet) {
|
||||||
if (!packet) return;
|
if (!packet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
packet.packets = packet.packets || new Packetlist();
|
packet.packets = packet.packets || new Packetlist();
|
||||||
|
|
||||||
|
@ -100,7 +104,7 @@ Packetlist.prototype.filterByTag = function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
for (var i = 0; i < this.length; i++) {
|
for (var i = 0; i < this.length; i++) {
|
||||||
if (args.some(function(packetType) {return that[i].tag == packetType;})) {
|
if (args.some(function(packetType) {return that[i].tag === packetType;})) {
|
||||||
filtered.push(this[i]);
|
filtered.push(this[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +135,9 @@ Packetlist.prototype.findPacket = function (type) {
|
||||||
for (var i = 0; i < this.length; i++) {
|
for (var i = 0; i < this.length; i++) {
|
||||||
if (this[i].packets.length) {
|
if (this[i].packets.length) {
|
||||||
found = this[i].packets.findPacket(type);
|
found = this[i].packets.findPacket(type);
|
||||||
if (found) return found;
|
if (found) {
|
||||||
|
return found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
* @module packet/public_key
|
* @module packet/public_key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = PublicKey;
|
module.exports = PublicKey;
|
||||||
|
|
||||||
var util = require('../util.js'),
|
var util = require('../util.js'),
|
||||||
|
@ -78,12 +80,12 @@ PublicKey.prototype.read = function (bytes) {
|
||||||
// A one-octet version number (3 or 4).
|
// A one-octet version number (3 or 4).
|
||||||
this.version = bytes[pos++];
|
this.version = bytes[pos++];
|
||||||
|
|
||||||
if (this.version == 3 || this.version == 4) {
|
if (this.version === 3 || this.version === 4) {
|
||||||
// - A four-octet number denoting the time that the key was created.
|
// - A four-octet number denoting the time that the key was created.
|
||||||
this.created = util.readDate(bytes.subarray(pos, pos + 4));
|
this.created = util.readDate(bytes.subarray(pos, pos + 4));
|
||||||
pos += 4;
|
pos += 4;
|
||||||
|
|
||||||
if (this.version == 3) {
|
if (this.version === 3) {
|
||||||
// - A two-octet number denoting the time in days that this key is
|
// - A two-octet number denoting the time in days that this key is
|
||||||
// valid. If this number is zero, then it does not expire.
|
// valid. If this number is zero, then it does not expire.
|
||||||
this.expirationTimeV3 = util.readNumber(bytes.subarray(pos, pos + 2));
|
this.expirationTimeV3 = util.readNumber(bytes.subarray(pos, pos + 2));
|
||||||
|
@ -133,7 +135,7 @@ PublicKey.prototype.write = function () {
|
||||||
// Version
|
// Version
|
||||||
arr.push(new Uint8Array([this.version]));
|
arr.push(new Uint8Array([this.version]));
|
||||||
arr.push(util.writeDate(this.created));
|
arr.push(util.writeDate(this.created));
|
||||||
if (this.version == 3) {
|
if (this.version === 3) {
|
||||||
arr.push(util.writeNumber(this.expirationTimeV3, 2));
|
arr.push(util.writeNumber(this.expirationTimeV3, 2));
|
||||||
}
|
}
|
||||||
arr.push(new Uint8Array([enums.write(enums.publicKey, this.algorithm)]));
|
arr.push(new Uint8Array([enums.write(enums.publicKey, this.algorithm)]));
|
||||||
|
@ -171,9 +173,9 @@ PublicKey.prototype.getKeyId = function () {
|
||||||
return this.keyid;
|
return this.keyid;
|
||||||
}
|
}
|
||||||
this.keyid = new type_keyid();
|
this.keyid = new type_keyid();
|
||||||
if (this.version == 4) {
|
if (this.version === 4) {
|
||||||
this.keyid.read(util.str2Uint8Array(util.hex2bin(this.getFingerprint()).substr(12, 8)));
|
this.keyid.read(util.str2Uint8Array(util.hex2bin(this.getFingerprint()).substr(12, 8)));
|
||||||
} else if (this.version == 3) {
|
} else if (this.version === 3) {
|
||||||
var arr = this.mpi[0].write();
|
var arr = this.mpi[0].write();
|
||||||
this.keyid.read(arr.subarray(arr.length - 8, arr.length));
|
this.keyid.read(arr.subarray(arr.length - 8, arr.length));
|
||||||
}
|
}
|
||||||
|
@ -189,10 +191,10 @@ PublicKey.prototype.getFingerprint = function () {
|
||||||
return this.fingerprint;
|
return this.fingerprint;
|
||||||
}
|
}
|
||||||
var toHash = '';
|
var toHash = '';
|
||||||
if (this.version == 4) {
|
if (this.version === 4) {
|
||||||
toHash = this.writeOld();
|
toHash = this.writeOld();
|
||||||
this.fingerprint = util.Uint8Array2str(crypto.hash.sha1(toHash));
|
this.fingerprint = util.Uint8Array2str(crypto.hash.sha1(toHash));
|
||||||
} else if (this.version == 3) {
|
} else if (this.version === 3) {
|
||||||
var mpicount = crypto.getPublicMpiCount(this.algorithm);
|
var mpicount = crypto.getPublicMpiCount(this.algorithm);
|
||||||
for (var i = 0; i < mpicount; i++) {
|
for (var i = 0; i < mpicount; i++) {
|
||||||
toHash += this.mpi[i].toBytes();
|
toHash += this.mpi[i].toBytes();
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
* @module packet/public_key_encrypted_session_key
|
* @module packet/public_key_encrypted_session_key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = PublicKeyEncryptedSessionKey;
|
module.exports = PublicKeyEncryptedSessionKey;
|
||||||
|
|
||||||
var type_keyid = require('../type/keyid.js'),
|
var type_keyid = require('../type/keyid.js'),
|
||||||
|
@ -157,7 +159,7 @@ PublicKeyEncryptedSessionKey.prototype.decrypt = function (key) {
|
||||||
|
|
||||||
key = util.str2Uint8Array(decoded.substring(1, decoded.length - 2));
|
key = util.str2Uint8Array(decoded.substring(1, decoded.length - 2));
|
||||||
|
|
||||||
if (checksum != util.calc_checksum(key)) {
|
if (checksum !== util.calc_checksum(key)) {
|
||||||
throw new Error('Checksum mismatch');
|
throw new Error('Checksum mismatch');
|
||||||
} else {
|
} else {
|
||||||
this.sessionKey = key;
|
this.sessionKey = key;
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
* @module packet/public_subkey
|
* @module packet/public_subkey
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = PublicSubkey;
|
module.exports = PublicSubkey;
|
||||||
|
|
||||||
var publicKey = require('./public_key.js'),
|
var publicKey = require('./public_key.js'),
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
* @module packet/secret_key
|
* @module packet/secret_key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = SecretKey;
|
module.exports = SecretKey;
|
||||||
|
|
||||||
var publicKey = require('./public_key.js'),
|
var publicKey = require('./public_key.js'),
|
||||||
|
@ -57,19 +59,21 @@ SecretKey.prototype = new publicKey();
|
||||||
SecretKey.prototype.constructor = SecretKey;
|
SecretKey.prototype.constructor = SecretKey;
|
||||||
|
|
||||||
function get_hash_len(hash) {
|
function get_hash_len(hash) {
|
||||||
if (hash == 'sha1')
|
if (hash === 'sha1') {
|
||||||
return 20;
|
return 20;
|
||||||
else
|
} else {
|
||||||
return 2;
|
return 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_hash_fn(hash) {
|
function get_hash_fn(hash) {
|
||||||
if (hash == 'sha1')
|
if (hash === 'sha1') {
|
||||||
return crypto.hash.sha1;
|
return crypto.hash.sha1;
|
||||||
else
|
} else {
|
||||||
return function(c) {
|
return function(c) {
|
||||||
return util.writeNumber(util.calc_checksum(c), 2);
|
return util.writeNumber(util.calc_checksum(c), 2);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function
|
// Helper function
|
||||||
|
@ -83,8 +87,9 @@ function parse_cleartext_mpi(hash_algorithm, cleartext, algorithm) {
|
||||||
|
|
||||||
var hash = util.Uint8Array2str(hashfn(cleartext));
|
var hash = util.Uint8Array2str(hashfn(cleartext));
|
||||||
|
|
||||||
if (hash != hashtext)
|
if (hash !== hashtext) {
|
||||||
return new Error("Hash mismatch.");
|
return new Error("Hash mismatch.");
|
||||||
|
}
|
||||||
|
|
||||||
var mpis = crypto.getPrivateMpiCount(algorithm);
|
var mpis = crypto.getPrivateMpiCount(algorithm);
|
||||||
|
|
||||||
|
@ -141,8 +146,9 @@ SecretKey.prototype.read = function (bytes) {
|
||||||
// key data. These algorithm-specific fields are as described
|
// key data. These algorithm-specific fields are as described
|
||||||
// below.
|
// below.
|
||||||
var parsedMPI = parse_cleartext_mpi('mod', bytes.subarray(1, bytes.length), this.algorithm);
|
var parsedMPI = parse_cleartext_mpi('mod', bytes.subarray(1, bytes.length), this.algorithm);
|
||||||
if (parsedMPI instanceof Error)
|
if (parsedMPI instanceof Error) {
|
||||||
throw parsedMPI;
|
throw parsedMPI;
|
||||||
|
}
|
||||||
this.mpi = this.mpi.concat(parsedMPI);
|
this.mpi = this.mpi.concat(parsedMPI);
|
||||||
this.isDecrypted = true;
|
this.isDecrypted = true;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +175,7 @@ SecretKey.prototype.write = function () {
|
||||||
|
|
||||||
|
|
||||||
/** Encrypt the payload. By default, we use aes256 and iterated, salted string
|
/** Encrypt the payload. By default, we use aes256 and iterated, salted string
|
||||||
* to key specifier. If the key is in a decrypted state (isDecrypted == true)
|
* to key specifier. If the key is in a decrypted state (isDecrypted === true)
|
||||||
* and the passphrase is empty or undefined, the key will be set as not encrypted.
|
* and the passphrase is empty or undefined, the key will be set as not encrypted.
|
||||||
* This can be used to remove passphrase protection after calling decrypt().
|
* This can be used to remove passphrase protection after calling decrypt().
|
||||||
* @param {String} passphrase
|
* @param {String} passphrase
|
||||||
|
@ -213,8 +219,9 @@ function produceEncryptionKey(s2k, passphrase, algorithm) {
|
||||||
* decrypted; false if not
|
* decrypted; false if not
|
||||||
*/
|
*/
|
||||||
SecretKey.prototype.decrypt = function (passphrase) {
|
SecretKey.prototype.decrypt = function (passphrase) {
|
||||||
if (this.isDecrypted)
|
if (this.isDecrypted) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var i = 0,
|
var i = 0,
|
||||||
symmetric,
|
symmetric,
|
||||||
|
@ -224,7 +231,7 @@ SecretKey.prototype.decrypt = function (passphrase) {
|
||||||
|
|
||||||
// - [Optional] If string-to-key usage octet was 255 or 254, a one-
|
// - [Optional] If string-to-key usage octet was 255 or 254, a one-
|
||||||
// octet symmetric encryption algorithm.
|
// octet symmetric encryption algorithm.
|
||||||
if (s2k_usage == 255 || s2k_usage == 254) {
|
if (s2k_usage === 255 || s2k_usage === 254) {
|
||||||
symmetric = this.encrypted[i++];
|
symmetric = this.encrypted[i++];
|
||||||
symmetric = enums.read(enums.symmetric, symmetric);
|
symmetric = enums.read(enums.symmetric, symmetric);
|
||||||
|
|
||||||
|
@ -254,7 +261,7 @@ SecretKey.prototype.decrypt = function (passphrase) {
|
||||||
|
|
||||||
cleartext = crypto.cfb.normalDecrypt(symmetric, key, ciphertext, iv);
|
cleartext = crypto.cfb.normalDecrypt(symmetric, key, ciphertext, iv);
|
||||||
|
|
||||||
var hash = s2k_usage == 254 ?
|
var hash = s2k_usage === 254 ?
|
||||||
'sha1' :
|
'sha1' :
|
||||||
'mod';
|
'mod';
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
* @module packet/secret_subkey
|
* @module packet/secret_subkey
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = SecretSubkey;
|
module.exports = SecretSubkey;
|
||||||
|
|
||||||
var secretKey = require('./secret_key.js'),
|
var secretKey = require('./secret_key.js'),
|
||||||
|
|
|
@ -103,10 +103,11 @@ Signature.prototype.read = function (bytes) {
|
||||||
switch (this.version) {
|
switch (this.version) {
|
||||||
case 3:
|
case 3:
|
||||||
// One-octet length of following hashed material. MUST be 5.
|
// One-octet length of following hashed material. MUST be 5.
|
||||||
if (bytes[i++] != 5)
|
if (bytes[i++] !== 5) {
|
||||||
util.print_debug("packet/signature.js\n" +
|
util.print_debug("packet/signature.js\n" +
|
||||||
'invalid One-octet length of following hashed material.' +
|
'invalid One-octet length of following hashed material.' +
|
||||||
'MUST be 5. @:' + (i - 1));
|
'MUST be 5. @:' + (i - 1));
|
||||||
|
}
|
||||||
|
|
||||||
var sigpos = i;
|
var sigpos = i;
|
||||||
// One-octet signature type.
|
// One-octet signature type.
|
||||||
|
@ -142,7 +143,6 @@ Signature.prototype.read = function (bytes) {
|
||||||
var i = 2;
|
var i = 2;
|
||||||
|
|
||||||
// subpacket data set (zero or more subpackets)
|
// subpacket data set (zero or more subpackets)
|
||||||
var subpacked_read = 0;
|
|
||||||
while (i < 2 + subpacket_length) {
|
while (i < 2 + subpacket_length) {
|
||||||
|
|
||||||
var len = packet.readSimpleLength(bytes.subarray(i, bytes.length));
|
var len = packet.readSimpleLength(bytes.subarray(i, bytes.length));
|
||||||
|
@ -252,7 +252,7 @@ Signature.prototype.write_all_sub_packets = function () {
|
||||||
arr.push(write_sub_packet(sub.exportable_certification, new Uint8Array([this.exportable ? 1 : 0])));
|
arr.push(write_sub_packet(sub.exportable_certification, new Uint8Array([this.exportable ? 1 : 0])));
|
||||||
}
|
}
|
||||||
if (this.trustLevel !== null) {
|
if (this.trustLevel !== null) {
|
||||||
bytes = new Uint8Array([this.trustLevel,this.trustAmount]);;
|
bytes = new Uint8Array([this.trustLevel,this.trustAmount]);
|
||||||
arr.push(write_sub_packet(sub.trust_signature, bytes));
|
arr.push(write_sub_packet(sub.trust_signature, bytes));
|
||||||
}
|
}
|
||||||
if (this.regularExpression !== null) {
|
if (this.regularExpression !== null) {
|
||||||
|
@ -392,7 +392,7 @@ Signature.prototype.read_sub_packet = function (bytes) {
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
// Exportable Certification
|
// Exportable Certification
|
||||||
this.exportable = bytes[mypos++] == 1;
|
this.exportable = bytes[mypos++] === 1;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
// Trust Signature
|
// Trust Signature
|
||||||
|
@ -405,7 +405,7 @@ Signature.prototype.read_sub_packet = function (bytes) {
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
// Revocable
|
// Revocable
|
||||||
this.revocable = bytes[mypos++] == 1;
|
this.revocable = bytes[mypos++] === 1;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
// Key Expiration Time in seconds
|
// Key Expiration Time in seconds
|
||||||
|
@ -437,7 +437,7 @@ Signature.prototype.read_sub_packet = function (bytes) {
|
||||||
case 20:
|
case 20:
|
||||||
// Notation Data
|
// Notation Data
|
||||||
// We don't know how to handle anything but a text flagged data.
|
// We don't know how to handle anything but a text flagged data.
|
||||||
if (bytes[mypos] == 0x80) {
|
if (bytes[mypos] === 0x80) {
|
||||||
|
|
||||||
// We extract key/value tuple from the byte stream.
|
// We extract key/value tuple from the byte stream.
|
||||||
mypos += 4;
|
mypos += 4;
|
||||||
|
@ -452,8 +452,8 @@ Signature.prototype.read_sub_packet = function (bytes) {
|
||||||
this.notation = this.notation || {};
|
this.notation = this.notation || {};
|
||||||
this.notation[name] = value;
|
this.notation[name] = value;
|
||||||
} else {
|
} else {
|
||||||
util.print_debug("Unsupported notation flag "+bytes[mypos]);
|
util.print_debug("Unsupported notation flag "+bytes[mypos]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 21:
|
case 21:
|
||||||
// Preferred Hash Algorithms
|
// Preferred Hash Algorithms
|
||||||
|
@ -512,7 +512,7 @@ Signature.prototype.read_sub_packet = function (bytes) {
|
||||||
this.embeddedSignature.read(bytes.subarray(mypos, bytes.length));
|
this.embeddedSignature.read(bytes.subarray(mypos, bytes.length));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
util.print_debug("Unknown signature subpacket type " + type + " @:" + mypos);
|
util.print_debug("Unknown signature subpacket type " + type + " @:" + mypos);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -541,17 +541,19 @@ Signature.prototype.toSign = function (type, data) {
|
||||||
} else if (data.userattribute !== undefined) {
|
} else if (data.userattribute !== undefined) {
|
||||||
tag = 0xD1;
|
tag = 0xD1;
|
||||||
packet = data.userattribute;
|
packet = data.userattribute;
|
||||||
} else throw new Error('Either a userid or userattribute packet needs to be ' +
|
} else {
|
||||||
|
throw new Error('Either a userid or userattribute packet needs to be ' +
|
||||||
'supplied for certification.');
|
'supplied for certification.');
|
||||||
|
}
|
||||||
|
|
||||||
var bytes = packet.write();
|
var bytes = packet.write();
|
||||||
|
|
||||||
if (this.version == 4) {
|
if (this.version === 4) {
|
||||||
return util.concatUint8Array([this.toSign(t.key, data),
|
return util.concatUint8Array([this.toSign(t.key, data),
|
||||||
new Uint8Array([tag]),
|
new Uint8Array([tag]),
|
||||||
util.writeNumber(bytes.length, 4),
|
util.writeNumber(bytes.length, 4),
|
||||||
bytes]);
|
bytes]);
|
||||||
} else if (this.version == 3) {
|
} else if (this.version === 3) {
|
||||||
return util.concatUint8Array([this.toSign(t.key, data),
|
return util.concatUint8Array([this.toSign(t.key, data),
|
||||||
bytes]);
|
bytes]);
|
||||||
}
|
}
|
||||||
|
@ -565,8 +567,9 @@ Signature.prototype.toSign = function (type, data) {
|
||||||
})]);
|
})]);
|
||||||
|
|
||||||
case t.key:
|
case t.key:
|
||||||
if (data.key === undefined)
|
if (data.key === undefined) {
|
||||||
throw new Error('Key packet is required for this signature.');
|
throw new Error('Key packet is required for this signature.');
|
||||||
|
}
|
||||||
return data.key.writeOld();
|
return data.key.writeOld();
|
||||||
|
|
||||||
case t.key_revocation:
|
case t.key_revocation:
|
||||||
|
@ -584,7 +587,9 @@ Signature.prototype.toSign = function (type, data) {
|
||||||
Signature.prototype.calculateTrailer = function () {
|
Signature.prototype.calculateTrailer = function () {
|
||||||
// calculating the trailer
|
// calculating the trailer
|
||||||
// V3 signatures don't have a trailer
|
// V3 signatures don't have a trailer
|
||||||
if (this.version == 3) return new Uint8Array(0);
|
if (this.version === 3) {
|
||||||
|
return new Uint8Array(0);
|
||||||
|
}
|
||||||
var first = new Uint8Array([4, 0xFF]); //Version, ?
|
var first = new Uint8Array([4, 0xFF]); //Version, ?
|
||||||
return util.concatUint8Array([first, util.writeNumber(this.signatureData.length, 4)]);
|
return util.concatUint8Array([first, util.writeNumber(this.signatureData.length, 4)]);
|
||||||
};
|
};
|
||||||
|
@ -609,13 +614,15 @@ Signature.prototype.verify = function (key, data) {
|
||||||
var mpicount = 0;
|
var mpicount = 0;
|
||||||
// Algorithm-Specific Fields for RSA signatures:
|
// Algorithm-Specific Fields for RSA signatures:
|
||||||
// - multiprecision number (MPI) of RSA signature value m**d mod n.
|
// - multiprecision number (MPI) of RSA signature value m**d mod n.
|
||||||
if (publicKeyAlgorithm > 0 && publicKeyAlgorithm < 4)
|
if (publicKeyAlgorithm > 0 && publicKeyAlgorithm < 4) {
|
||||||
mpicount = 1;
|
mpicount = 1;
|
||||||
|
}
|
||||||
// Algorithm-Specific Fields for DSA signatures:
|
// Algorithm-Specific Fields for DSA signatures:
|
||||||
// - MPI of DSA value r.
|
// - MPI of DSA value r.
|
||||||
// - MPI of DSA value s.
|
// - MPI of DSA value s.
|
||||||
else if (publicKeyAlgorithm == 17)
|
else if (publicKeyAlgorithm === 17) {
|
||||||
mpicount = 2;
|
mpicount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
var mpi = [],
|
var mpi = [],
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
* @module packet/sym_encrypted_session_key
|
* @module packet/sym_encrypted_session_key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var util = require('../util.js'),
|
var util = require('../util.js'),
|
||||||
type_s2k = require('../type/s2k.js'),
|
type_s2k = require('../type/s2k.js'),
|
||||||
enums = require('../enums.js'),
|
enums = require('../enums.js'),
|
||||||
|
@ -83,8 +85,9 @@ SymEncryptedSessionKey.prototype.read = function(bytes) {
|
||||||
if (done < bytes.length) {
|
if (done < bytes.length) {
|
||||||
this.encrypted = bytes.subarray(done, bytes.length);
|
this.encrypted = bytes.subarray(done, bytes.length);
|
||||||
this.sessionKeyEncryptionAlgorithm = algo;
|
this.sessionKeyEncryptionAlgorithm = algo;
|
||||||
} else
|
} else {
|
||||||
this.sessionKeyAlgorithm = algo;
|
this.sessionKeyAlgorithm = algo;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SymEncryptedSessionKey.prototype.write = function() {
|
SymEncryptedSessionKey.prototype.write = function() {
|
||||||
|
@ -94,8 +97,9 @@ SymEncryptedSessionKey.prototype.write = function() {
|
||||||
|
|
||||||
var bytes = util.concatUint8Array([new Uint8Array([this.version, enums.write(enums.symmetric, algo)]), this.s2k.write()]);
|
var bytes = util.concatUint8Array([new Uint8Array([this.version, enums.write(enums.symmetric, algo)]), this.s2k.write()]);
|
||||||
|
|
||||||
if (this.encrypted !== null)
|
if (this.encrypted !== null) {
|
||||||
bytes = util.concatUint8Array([bytes, this.encrypted]);
|
bytes = util.concatUint8Array([bytes, this.encrypted]);
|
||||||
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,7 +121,6 @@ SymEncryptedSessionKey.prototype.decrypt = function(passphrase) {
|
||||||
this.sessionKey = key;
|
this.sessionKey = key;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var decrypted = crypto.cfb.normalDecrypt(
|
var decrypted = crypto.cfb.normalDecrypt(
|
||||||
algo, key, this.encrypted, null);
|
algo, key, this.encrypted, null);
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
* @module packet/symmetrically_encrypted
|
* @module packet/symmetrically_encrypted
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = SymmetricallyEncrypted;
|
module.exports = SymmetricallyEncrypted;
|
||||||
|
|
||||||
var crypto = require('../crypto'),
|
var crypto = require('../crypto'),
|
||||||
|
@ -70,7 +72,7 @@ SymmetricallyEncrypted.prototype.decrypt = function (sessionKeyAlgorithm, key) {
|
||||||
(sessionKeyAlgorithm === 'aes128' ||
|
(sessionKeyAlgorithm === 'aes128' ||
|
||||||
sessionKeyAlgorithm === 'aes192' ||
|
sessionKeyAlgorithm === 'aes192' ||
|
||||||
sessionKeyAlgorithm === 'aes256')) {
|
sessionKeyAlgorithm === 'aes256')) {
|
||||||
throw new Error('Decryption failed due to missing MDC in combination with modern cipher.')
|
throw new Error('Decryption failed due to missing MDC in combination with modern cipher.');
|
||||||
}
|
}
|
||||||
this.packets.read(decrypted);
|
this.packets.read(decrypted);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* @module packet/trust
|
* @module packet/trust
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = Trust;
|
module.exports = Trust;
|
||||||
|
|
||||||
var enums = require('../enums.js');
|
var enums = require('../enums.js');
|
||||||
|
@ -19,6 +21,4 @@ function Trust() {
|
||||||
* Currently empty as we ignore trust packets
|
* Currently empty as we ignore trust packets
|
||||||
* @param {String} byptes payload of a tag 12 packet
|
* @param {String} byptes payload of a tag 12 packet
|
||||||
*/
|
*/
|
||||||
Trust.prototype.read = function (bytes) {
|
Trust.prototype.read = function () {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
* @module packet/user_attribute
|
* @module packet/user_attribute
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var util = require('../util.js'),
|
var util = require('../util.js'),
|
||||||
packet = require('./packet.js'),
|
packet = require('./packet.js'),
|
||||||
enums = require('../enums.js');
|
enums = require('../enums.js');
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
* @module packet/userid
|
* @module packet/userid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = Userid;
|
module.exports = Userid;
|
||||||
|
|
||||||
var util = require('../util.js'),
|
var util = require('../util.js'),
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
* @module type/keyid
|
* @module type/keyid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = Keyid;
|
module.exports = Keyid;
|
||||||
|
|
||||||
var util = require('../util.js');
|
var util = require('../util.js');
|
||||||
|
@ -34,7 +36,6 @@ var util = require('../util.js');
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Keyid() {
|
function Keyid() {
|
||||||
|
|
||||||
this.bytes = '';
|
this.bytes = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ Keyid.prototype.toHex = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Keyid.prototype.equals = function(keyid) {
|
Keyid.prototype.equals = function(keyid) {
|
||||||
return this.bytes == keyid.bytes;
|
return this.bytes === keyid.bytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
Keyid.prototype.isNull = function() {
|
Keyid.prototype.isNull = function() {
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
* @module type/mpi
|
* @module type/mpi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = MPI;
|
module.exports = MPI;
|
||||||
|
|
||||||
var BigInteger = require('../crypto/public_key/jsbn.js'),
|
var BigInteger = require('../crypto/public_key/jsbn.js'),
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
* @module type/s2k
|
* @module type/s2k
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = S2K;
|
module.exports = S2K;
|
||||||
|
|
||||||
var enums = require('../enums.js'),
|
var enums = require('../enums.js'),
|
||||||
|
@ -85,10 +87,10 @@ S2K.prototype.read = function (bytes) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'gnu':
|
case 'gnu':
|
||||||
if (util.Uint8Array2str(bytes.subarray(i, 3)) == "GNU") {
|
if (util.Uint8Array2str(bytes.subarray(i, 3)) === "GNU") {
|
||||||
i += 3; // GNU
|
i += 3; // GNU
|
||||||
var gnuExtType = 1000 + bytes[i++];
|
var gnuExtType = 1000 + bytes[i++];
|
||||||
if (gnuExtType == 1001) {
|
if (gnuExtType === 1001) {
|
||||||
this.type = gnuExtType;
|
this.type = gnuExtType;
|
||||||
// GnuPG extension mode 1001 -- don't write secret key at all
|
// GnuPG extension mode 1001 -- don't write secret key at all
|
||||||
} else {
|
} else {
|
||||||
|
@ -160,13 +162,15 @@ S2K.prototype.produce_key = function (passphrase, numBytes) {
|
||||||
count = s2k.get_count(),
|
count = s2k.get_count(),
|
||||||
data = util.concatUint8Array([s2k.salt,passphrase]);
|
data = util.concatUint8Array([s2k.salt,passphrase]);
|
||||||
|
|
||||||
while (isp.length * data.length < count)
|
while (isp.length * data.length < count) {
|
||||||
isp.push(data);
|
isp.push(data);
|
||||||
|
}
|
||||||
|
|
||||||
isp = util.concatUint8Array(isp);
|
isp = util.concatUint8Array(isp);
|
||||||
|
|
||||||
if (isp.length > count)
|
if (isp.length > count) {
|
||||||
isp = isp.subarray(0, count);
|
isp = isp.subarray(0, count);
|
||||||
|
}
|
||||||
|
|
||||||
return crypto.hash.digest(algorithm, util.concatUint8Array([prefix,isp]));
|
return crypto.hash.digest(algorithm, util.concatUint8Array([prefix,isp]));
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,9 @@ AsyncProxy.prototype.seedRandom = function(size) {
|
||||||
* @return {Uint8Array}
|
* @return {Uint8Array}
|
||||||
*/
|
*/
|
||||||
AsyncProxy.prototype.getRandomBuffer = function(size) {
|
AsyncProxy.prototype.getRandomBuffer = function(size) {
|
||||||
if (!size) return null;
|
if (!size) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
var buf = new Uint8Array(size);
|
var buf = new Uint8Array(size);
|
||||||
crypto.random.getRandomValues(buf);
|
crypto.random.getRandomValues(buf);
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -397,8 +399,8 @@ AsyncProxy.prototype.decryptKey = function(privateKey, password) {
|
||||||
});
|
});
|
||||||
|
|
||||||
self.tasks.push({ resolve:function(data) {
|
self.tasks.push({ resolve:function(data) {
|
||||||
var packetlist = packet.List.fromStructuredClone(data),
|
var packetlist = packet.List.fromStructuredClone(data);
|
||||||
data = new key.Key(packetlist);
|
data = new key.Key(packetlist);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}, reject:reject });
|
}, reject:reject });
|
||||||
});
|
});
|
||||||
|
@ -425,8 +427,8 @@ AsyncProxy.prototype.decryptKeyPacket = function(privateKey, keyIds, password) {
|
||||||
});
|
});
|
||||||
|
|
||||||
self.tasks.push({ resolve:function(data) {
|
self.tasks.push({ resolve:function(data) {
|
||||||
var packetlist = packet.List.fromStructuredClone(data),
|
var packetlist = packet.List.fromStructuredClone(data);
|
||||||
data = new key.Key(packetlist);
|
data = new key.Key(packetlist);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}, reject:reject });
|
}, reject:reject });
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user