Replace check for detecting that an object is a promise
This commit is contained in:
parent
1a4a75501a
commit
a730d3f7ad
129
dist/openpgp.js
vendored
129
dist/openpgp.js
vendored
|
@ -838,7 +838,7 @@ function verifyHeaders(headers, packetlist) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
var oneHeader = null;
|
var oneHeader = null;
|
||||||
var hashAlgos = [];
|
var hashAlgos = [];
|
||||||
for (var i = 0; i < headers.length; i++) {
|
for (var i = 0; i < headers.length; i++) {
|
||||||
|
@ -989,7 +989,10 @@ module.exports = {
|
||||||
prefer_hash_algorithm: enums.hash.sha256,
|
prefer_hash_algorithm: enums.hash.sha256,
|
||||||
encryption_cipher: enums.symmetric.aes256,
|
encryption_cipher: enums.symmetric.aes256,
|
||||||
compression: enums.compression.zip,
|
compression: enums.compression.zip,
|
||||||
|
// use integrity protection for symmetric encryption
|
||||||
integrity_protect: true,
|
integrity_protect: true,
|
||||||
|
// fail on decrypt if message is not integrity protected
|
||||||
|
ignore_mdc_error: false,
|
||||||
rsa_blinding: true,
|
rsa_blinding: true,
|
||||||
useWebCrypto: true,
|
useWebCrypto: true,
|
||||||
|
|
||||||
|
@ -2954,8 +2957,8 @@ function des(keys, message, encrypt, mode, iv, padding) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//store the result here
|
//store the result here
|
||||||
result = "";
|
var result = "";
|
||||||
tempresult = "";
|
var tempresult = "";
|
||||||
|
|
||||||
if (mode == 1) { //CBC mode
|
if (mode == 1) { //CBC mode
|
||||||
cbcleft = (iv.charCodeAt(m++) << 24) | (iv.charCodeAt(m++) << 16) | (iv.charCodeAt(m++) << 8) | iv.charCodeAt(m++);
|
cbcleft = (iv.charCodeAt(m++) << 24) | (iv.charCodeAt(m++) << 16) | (iv.charCodeAt(m++) << 8) | iv.charCodeAt(m++);
|
||||||
|
@ -3084,6 +3087,7 @@ function des(keys, message, encrypt, mode, iv, padding) {
|
||||||
|
|
||||||
function des_createKeys(key) {
|
function des_createKeys(key) {
|
||||||
//declaring this locally speeds things up a bit
|
//declaring this locally speeds things up a bit
|
||||||
|
var pc2bytes0;
|
||||||
pc2bytes0 = new Array(0, 0x4, 0x20000000, 0x20000004, 0x10000, 0x10004, 0x20010000, 0x20010004, 0x200, 0x204,
|
pc2bytes0 = new Array(0, 0x4, 0x20000000, 0x20000004, 0x10000, 0x10004, 0x20010000, 0x20010004, 0x200, 0x204,
|
||||||
0x20000200, 0x20000204, 0x10200, 0x10204, 0x20010200, 0x20010204);
|
0x20000200, 0x20000204, 0x10200, 0x10204, 0x20010200, 0x20010204);
|
||||||
pc2bytes1 = new Array(0, 0x1, 0x100000, 0x100001, 0x4000000, 0x4000001, 0x4100000, 0x4100001, 0x100, 0x101, 0x100100,
|
pc2bytes1 = new Array(0, 0x1, 0x100000, 0x100001, 0x4000000, 0x4000001, 0x4100000, 0x4100001, 0x100, 0x101, 0x100100,
|
||||||
|
@ -3124,8 +3128,8 @@ function des_createKeys(key) {
|
||||||
temp;
|
temp;
|
||||||
|
|
||||||
for (var j = 0; j < iterations; j++) { //either 1 or 3 iterations
|
for (var j = 0; j < iterations; j++) { //either 1 or 3 iterations
|
||||||
left = (key.charCodeAt(m++) << 24) | (key.charCodeAt(m++) << 16) | (key.charCodeAt(m++) << 8) | key.charCodeAt(m++);
|
var left = (key.charCodeAt(m++) << 24) | (key.charCodeAt(m++) << 16) | (key.charCodeAt(m++) << 8) | key.charCodeAt(m++);
|
||||||
right = (key.charCodeAt(m++) << 24) | (key.charCodeAt(m++) << 16) | (key.charCodeAt(m++) << 8) | key.charCodeAt(m++);
|
var right = (key.charCodeAt(m++) << 24) | (key.charCodeAt(m++) << 16) | (key.charCodeAt(m++) << 8) | key.charCodeAt(m++);
|
||||||
|
|
||||||
temp = ((left >>> 4) ^ right) & 0x0f0f0f0f;
|
temp = ((left >>> 4) ^ right) & 0x0f0f0f0f;
|
||||||
right ^= temp;
|
right ^= temp;
|
||||||
|
@ -5486,8 +5490,8 @@ var indexes = [
|
||||||
];
|
];
|
||||||
|
|
||||||
function compress(MDbuf, X) {
|
function compress(MDbuf, X) {
|
||||||
blockA = [];
|
var blockA = [];
|
||||||
blockB = [];
|
var blockB = [];
|
||||||
|
|
||||||
var retBlock;
|
var retBlock;
|
||||||
|
|
||||||
|
@ -9096,7 +9100,7 @@ function RSA() {
|
||||||
keyGenOpt = {
|
keyGenOpt = {
|
||||||
name: 'RSA-OAEP',
|
name: 'RSA-OAEP',
|
||||||
modulusLength: B, // the specified keysize in bits
|
modulusLength: B, // the specified keysize in bits
|
||||||
publicExponent: Euint8.subarray(0, 3), // take three bytes (max 65537)
|
publicExponent: Euint8.subarray(0, 3) // take three bytes (max 65537)
|
||||||
};
|
};
|
||||||
keys = webCrypto.generateKey(keyGenOpt, true, ['encrypt', 'decrypt']);
|
keys = webCrypto.generateKey(keyGenOpt, true, ['encrypt', 'decrypt']);
|
||||||
}
|
}
|
||||||
|
@ -9112,7 +9116,7 @@ function RSA() {
|
||||||
};
|
};
|
||||||
|
|
||||||
keys = webCrypto.generateKey(keyGenOpt, true, ['sign', 'verify']);
|
keys = webCrypto.generateKey(keyGenOpt, true, ['sign', 'verify']);
|
||||||
if (!(keys instanceof Promise)) { // IE11 KeyOperation
|
if (!(typeof keys.then === 'function')) { // IE11 KeyOperation
|
||||||
keys = convertKeyOperation(keys, 'Error generating RSA key pair.');
|
keys = convertKeyOperation(keys, 'Error generating RSA key pair.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9130,7 +9134,7 @@ function RSA() {
|
||||||
// export the generated keys as JsonWebKey (JWK)
|
// export the generated keys as JsonWebKey (JWK)
|
||||||
// https://tools.ietf.org/html/draft-ietf-jose-json-web-key-33
|
// https://tools.ietf.org/html/draft-ietf-jose-json-web-key-33
|
||||||
var key = webCrypto.exportKey('jwk', keypair.privateKey);
|
var key = webCrypto.exportKey('jwk', keypair.privateKey);
|
||||||
if (!(key instanceof Promise)) { // IE11 KeyOperation
|
if (!(typeof key.then === 'function')) { // IE11 KeyOperation
|
||||||
key = convertKeyOperation(key, 'Error exporting RSA key pair.');
|
key = convertKeyOperation(key, 'Error exporting RSA key pair.');
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
|
@ -9159,10 +9163,10 @@ function RSA() {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
keyop.onerror = function (err) {
|
keyop.onerror = function (err) {
|
||||||
reject(new Error(errmsg));
|
reject(new Error(errmsg));
|
||||||
}
|
};
|
||||||
keyop.oncomplete = function (e) {
|
keyop.oncomplete = function (e) {
|
||||||
resolve(e.target.result);
|
resolve(e.target.result);
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9577,14 +9581,14 @@ function getType(text) {
|
||||||
// BEGIN PGP MESSAGE, PART X/Y
|
// BEGIN PGP MESSAGE, PART X/Y
|
||||||
// Used for multi-part messages, where the armor is split amongst Y
|
// Used for multi-part messages, where the armor is split amongst Y
|
||||||
// parts, and this is the Xth part out of Y.
|
// parts, and this is the Xth part out of Y.
|
||||||
if (header[1].match(/MESSAGE, PART \d+\/\d+/)) {
|
if (/MESSAGE, PART \d+\/\d+/.test(header[1])) {
|
||||||
return enums.armor.multipart_section;
|
return enums.armor.multipart_section;
|
||||||
} else
|
} else
|
||||||
// BEGIN PGP MESSAGE, PART X
|
// BEGIN PGP MESSAGE, PART X
|
||||||
// Used for multi-part messages, where this is the Xth part of an
|
// Used for multi-part messages, where this is the Xth part of an
|
||||||
// unspecified number of parts. Requires the MESSAGE-ID Armor
|
// unspecified number of parts. Requires the MESSAGE-ID Armor
|
||||||
// Header to be used.
|
// Header to be used.
|
||||||
if (header[1].match(/MESSAGE, PART \d+/)) {
|
if (/MESSAGE, PART \d+/.test(header[1])) {
|
||||||
return enums.armor.multipart_last;
|
return enums.armor.multipart_last;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
@ -9592,25 +9596,25 @@ function getType(text) {
|
||||||
// Used for detached signatures, OpenPGP/MIME signatures, and
|
// Used for detached signatures, OpenPGP/MIME signatures, and
|
||||||
// cleartext signatures. Note that PGP 2.x uses BEGIN PGP MESSAGE
|
// cleartext signatures. Note that PGP 2.x uses BEGIN PGP MESSAGE
|
||||||
// for detached signatures.
|
// for detached signatures.
|
||||||
if (header[1].match(/SIGNED MESSAGE/)) {
|
if (/SIGNED MESSAGE/.test(header[1])) {
|
||||||
return enums.armor.signed;
|
return enums.armor.signed;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
// BEGIN PGP MESSAGE
|
// BEGIN PGP MESSAGE
|
||||||
// Used for signed, encrypted, or compressed files.
|
// Used for signed, encrypted, or compressed files.
|
||||||
if (header[1].match(/MESSAGE/)) {
|
if (/MESSAGE/.test(header[1])) {
|
||||||
return enums.armor.message;
|
return enums.armor.message;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
// BEGIN PGP PUBLIC KEY BLOCK
|
// BEGIN PGP PUBLIC KEY BLOCK
|
||||||
// Used for armoring public keys.
|
// Used for armoring public keys.
|
||||||
if (header[1].match(/PUBLIC KEY BLOCK/)) {
|
if (/PUBLIC KEY BLOCK/.test(header[1])) {
|
||||||
return enums.armor.public_key;
|
return enums.armor.public_key;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
// BEGIN PGP PRIVATE KEY BLOCK
|
// BEGIN PGP PRIVATE KEY BLOCK
|
||||||
// Used for armoring private keys.
|
// Used for armoring private keys.
|
||||||
if (header[1].match(/PRIVATE KEY BLOCK/)) {
|
if (/PRIVATE KEY BLOCK/.test(header[1])) {
|
||||||
return enums.armor.private_key;
|
return enums.armor.private_key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9768,8 +9772,8 @@ function splitHeaders(text) {
|
||||||
*/
|
*/
|
||||||
function verifyHeaders(headers) {
|
function verifyHeaders(headers) {
|
||||||
for (var i = 0; i < headers.length; i++) {
|
for (var i = 0; i < headers.length; i++) {
|
||||||
if (!headers[i].match(/^(Version|Comment|MessageID|Hash|Charset): .+$/)) {
|
if (!/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(headers[i])) {
|
||||||
throw new Error('Improperly formatted armor header: ' + headers[i]);;
|
throw new Error('Improperly formatted armor header: ' + headers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10428,7 +10432,10 @@ HKP.prototype.lookup = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetch(uri).then(function(response) {
|
return fetch(uri).then(function(response) {
|
||||||
|
if (response.status === 200) {
|
||||||
return response.text();
|
return response.text();
|
||||||
|
}
|
||||||
|
|
||||||
}).then(function(publicKeyArmored) {
|
}).then(function(publicKeyArmored) {
|
||||||
if (!publicKeyArmored || publicKeyArmored.indexOf('-----END PGP PUBLIC KEY BLOCK-----') < 0) {
|
if (!publicKeyArmored || publicKeyArmored.indexOf('-----END PGP PUBLIC KEY BLOCK-----') < 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -11450,7 +11457,8 @@ function readArmored(armoredText) {
|
||||||
* @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsa_encrypt_sign] to indicate what type of key to make.
|
* @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsa_encrypt_sign] to indicate what type of key to make.
|
||||||
* RSA is 1. See {@link http://tools.ietf.org/html/rfc4880#section-9.1}
|
* RSA is 1. See {@link http://tools.ietf.org/html/rfc4880#section-9.1}
|
||||||
* @param {Integer} options.numBits number of bits for the key creation.
|
* @param {Integer} options.numBits number of bits for the key creation.
|
||||||
* @param {String} options.userId assumes already in form of "User Name <username@email.com>"
|
* @param {String|Array<String>} options.userId assumes already in form of "User Name <username@email.com>"
|
||||||
|
If array is used, the first userId is set as primary user Id
|
||||||
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
||||||
* @param {Boolean} [options.unlocked=false] The secret part of the generated key is unlocked
|
* @param {Boolean} [options.unlocked=false] The secret part of the generated key is unlocked
|
||||||
* @return {module:key~Key}
|
* @return {module:key~Key}
|
||||||
|
@ -11468,6 +11476,9 @@ function generate(options) {
|
||||||
if (!options.passphrase) {
|
if (!options.passphrase) {
|
||||||
options.unlocked = true;
|
options.unlocked = true;
|
||||||
}
|
}
|
||||||
|
if (String.prototype.isPrototypeOf(options.userId) || typeof options.userId === 'string') {
|
||||||
|
options.userId = [options.userId];
|
||||||
|
}
|
||||||
|
|
||||||
// generate
|
// generate
|
||||||
var genSecretKey = generateSecretKey();
|
var genSecretKey = generateSecretKey();
|
||||||
|
@ -11495,8 +11506,12 @@ function generate(options) {
|
||||||
|
|
||||||
packetlist = new packet.List();
|
packetlist = new packet.List();
|
||||||
|
|
||||||
|
packetlist.push(secretKeyPacket);
|
||||||
|
|
||||||
|
options.userId.forEach(function(userId, index) {
|
||||||
|
|
||||||
userIdPacket = new packet.Userid();
|
userIdPacket = new packet.Userid();
|
||||||
userIdPacket.read(options.userId);
|
userIdPacket.read(userId);
|
||||||
|
|
||||||
dataToSign = {};
|
dataToSign = {};
|
||||||
dataToSign.userid = userIdPacket;
|
dataToSign.userid = userIdPacket;
|
||||||
|
@ -11519,12 +11534,20 @@ function generate(options) {
|
||||||
signaturePacket.preferredCompressionAlgorithms = [];
|
signaturePacket.preferredCompressionAlgorithms = [];
|
||||||
signaturePacket.preferredCompressionAlgorithms.push(enums.compression.zlib);
|
signaturePacket.preferredCompressionAlgorithms.push(enums.compression.zlib);
|
||||||
signaturePacket.preferredCompressionAlgorithms.push(enums.compression.zip);
|
signaturePacket.preferredCompressionAlgorithms.push(enums.compression.zip);
|
||||||
|
if (index === 0) {
|
||||||
|
signaturePacket.isPrimaryUserID = true;
|
||||||
|
}
|
||||||
if (config.integrity_protect) {
|
if (config.integrity_protect) {
|
||||||
signaturePacket.features = [];
|
signaturePacket.features = [];
|
||||||
signaturePacket.features.push(1); // Modification Detection
|
signaturePacket.features.push(1); // Modification Detection
|
||||||
}
|
}
|
||||||
signaturePacket.sign(secretKeyPacket, dataToSign);
|
signaturePacket.sign(secretKeyPacket, dataToSign);
|
||||||
|
|
||||||
|
packetlist.push(userIdPacket);
|
||||||
|
packetlist.push(signaturePacket);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
dataToSign = {};
|
dataToSign = {};
|
||||||
dataToSign.key = secretKeyPacket;
|
dataToSign.key = secretKeyPacket;
|
||||||
dataToSign.bind = secretSubkeyPacket;
|
dataToSign.bind = secretSubkeyPacket;
|
||||||
|
@ -11535,9 +11558,6 @@ function generate(options) {
|
||||||
subkeySignaturePacket.keyFlags = [enums.keyFlags.encrypt_communication | enums.keyFlags.encrypt_storage];
|
subkeySignaturePacket.keyFlags = [enums.keyFlags.encrypt_communication | enums.keyFlags.encrypt_storage];
|
||||||
subkeySignaturePacket.sign(secretKeyPacket, dataToSign);
|
subkeySignaturePacket.sign(secretKeyPacket, dataToSign);
|
||||||
|
|
||||||
packetlist.push(secretKeyPacket);
|
|
||||||
packetlist.push(userIdPacket);
|
|
||||||
packetlist.push(signaturePacket);
|
|
||||||
packetlist.push(secretSubkeyPacket);
|
packetlist.push(secretSubkeyPacket);
|
||||||
packetlist.push(subkeySignaturePacket);
|
packetlist.push(subkeySignaturePacket);
|
||||||
|
|
||||||
|
@ -11722,12 +11742,14 @@ KeyArray.prototype.getForAddress = function(email) {
|
||||||
* @return {Boolean} True if the email address is defined in the specified key
|
* @return {Boolean} True if the email address is defined in the specified key
|
||||||
*/
|
*/
|
||||||
function emailCheck(email, key) {
|
function emailCheck(email, key) {
|
||||||
|
email = email.toLowerCase();
|
||||||
// escape email before using in regular expression
|
// escape email before using in regular expression
|
||||||
email = email.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
var emailEsc = email.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||||
var emailRegex = new RegExp('<' + email + '>');
|
var emailRegex = new RegExp('<' + emailEsc + '>');
|
||||||
var keyEmails = key.getUserIds();
|
var userIds = key.getUserIds();
|
||||||
for (var i = 0; i < keyEmails.length; i++) {
|
for (var i = 0; i < userIds.length; i++) {
|
||||||
if (emailRegex.test(keyEmails[i].toLowerCase())) {
|
var userId = userIds[i].toLowerCase();
|
||||||
|
if (email === userId || emailRegex.test(userId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11918,10 +11940,14 @@ LocalStore.prototype.storePrivate = function (keys) {
|
||||||
|
|
||||||
function storeKeys(storage, itemname, keys) {
|
function storeKeys(storage, itemname, keys) {
|
||||||
var armoredKeys = [];
|
var armoredKeys = [];
|
||||||
|
if (keys.length) {
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
armoredKeys.push(keys[i].armor());
|
armoredKeys.push(keys[i].armor());
|
||||||
}
|
}
|
||||||
storage.setItem(itemname, JSON.stringify(armoredKeys));
|
storage.setItem(itemname, JSON.stringify(armoredKeys));
|
||||||
|
} else {
|
||||||
|
storage.removeItem(itemname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},{"../config":17,"../key.js":47,"../util.js":76,"node-localstorage":false}],51:[function(require,module,exports){
|
},{"../config":17,"../key.js":47,"../util.js":76,"node-localstorage":false}],51:[function(require,module,exports){
|
||||||
|
@ -12173,7 +12199,7 @@ Message.prototype.sign = function(privateKeys) {
|
||||||
var literalFormat = enums.write(enums.literal, literalDataPacket.format);
|
var literalFormat = enums.write(enums.literal, literalDataPacket.format);
|
||||||
var signatureType = literalFormat == enums.literal.binary ?
|
var signatureType = literalFormat == enums.literal.binary ?
|
||||||
enums.signature.binary : enums.signature.text;
|
enums.signature.binary : enums.signature.text;
|
||||||
var i;
|
var i, signingKeyPacket;
|
||||||
for (i = 0; i < privateKeys.length; i++) {
|
for (i = 0; i < privateKeys.length; i++) {
|
||||||
if (privateKeys[i].isPublic()) {
|
if (privateKeys[i].isPublic()) {
|
||||||
throw new Error('Need private key for signing');
|
throw new Error('Need private key for signing');
|
||||||
|
@ -12182,7 +12208,7 @@ Message.prototype.sign = function(privateKeys) {
|
||||||
onePassSig.type = signatureType;
|
onePassSig.type = signatureType;
|
||||||
//TODO get preferred hashg algo from key signature
|
//TODO get preferred hashg algo from key signature
|
||||||
onePassSig.hashAlgorithm = config.prefer_hash_algorithm;
|
onePassSig.hashAlgorithm = config.prefer_hash_algorithm;
|
||||||
var signingKeyPacket = privateKeys[i].getSigningKeyPacket();
|
signingKeyPacket = privateKeys[i].getSigningKeyPacket();
|
||||||
if (!signingKeyPacket) {
|
if (!signingKeyPacket) {
|
||||||
throw new Error('Could not find valid key packet for signing in key ' + privateKeys[i].primaryKey.getKeyId().toHex());
|
throw new Error('Could not find valid key packet for signing in key ' + privateKeys[i].primaryKey.getKeyId().toHex());
|
||||||
}
|
}
|
||||||
|
@ -12272,8 +12298,7 @@ function readArmored(armoredText) {
|
||||||
var input = armor.decode(armoredText).data;
|
var input = armor.decode(armoredText).data;
|
||||||
var packetlist = new packet.List();
|
var packetlist = new packet.List();
|
||||||
packetlist.read(input);
|
packetlist.read(input);
|
||||||
var newMessage = new Message(packetlist);
|
return new Message(packetlist);
|
||||||
return newMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12288,8 +12313,7 @@ function readSignedContent(content, detachedSignature) {
|
||||||
packetlist.push(literalDataPacket);
|
packetlist.push(literalDataPacket);
|
||||||
var input = armor.decode(detachedSignature).data;
|
var input = armor.decode(detachedSignature).data;
|
||||||
packetlist.read(input);
|
packetlist.read(input);
|
||||||
var newMessage = new Message(packetlist);
|
return new Message(packetlist);
|
||||||
return newMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12304,23 +12328,25 @@ function fromText(text) {
|
||||||
literalDataPacket.setText(text);
|
literalDataPacket.setText(text);
|
||||||
var literalDataPacketlist = new packet.List();
|
var literalDataPacketlist = new packet.List();
|
||||||
literalDataPacketlist.push(literalDataPacket);
|
literalDataPacketlist.push(literalDataPacket);
|
||||||
var newMessage = new Message(literalDataPacketlist);
|
return new Message(literalDataPacketlist);
|
||||||
return newMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates new message object from binary data
|
* creates new message object from binary data
|
||||||
* @param {String} bytes
|
* @param {String} bytes
|
||||||
|
* @param {String} filename
|
||||||
* @return {module:message~Message} new message object
|
* @return {module:message~Message} new message object
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function fromBinary(bytes) {
|
function fromBinary(bytes, filename) {
|
||||||
var literalDataPacket = new packet.Literal();
|
var literalDataPacket = new packet.Literal();
|
||||||
|
if (filename) {
|
||||||
|
literalDataPacket.setFilename(filename);
|
||||||
|
}
|
||||||
literalDataPacket.setBytes(bytes, enums.read(enums.literal, enums.literal.binary));
|
literalDataPacket.setBytes(bytes, enums.read(enums.literal, enums.literal.binary));
|
||||||
var literalDataPacketlist = new packet.List();
|
var literalDataPacketlist = new packet.List();
|
||||||
literalDataPacketlist.push(literalDataPacket);
|
literalDataPacketlist.push(literalDataPacket);
|
||||||
var newMessage = new Message(literalDataPacketlist);
|
return new Message(literalDataPacketlist);
|
||||||
return newMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Message = Message;
|
exports.Message = Message;
|
||||||
|
@ -12706,7 +12732,7 @@ module.exports = {
|
||||||
* @returns {Object} new packet object with data from packet clone
|
* @returns {Object} new packet object with data from packet clone
|
||||||
*/
|
*/
|
||||||
fromStructuredClone: function(packetClone) {
|
fromStructuredClone: function(packetClone) {
|
||||||
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)) {
|
||||||
|
@ -15472,7 +15498,8 @@ SymEncryptedSessionKey.prototype.postCloneTypeFix = function() {
|
||||||
module.exports = SymmetricallyEncrypted;
|
module.exports = SymmetricallyEncrypted;
|
||||||
|
|
||||||
var crypto = require('../crypto'),
|
var crypto = require('../crypto'),
|
||||||
enums = require('../enums.js');
|
enums = require('../enums.js'),
|
||||||
|
config = require('../config');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -15483,6 +15510,7 @@ function SymmetricallyEncrypted() {
|
||||||
/** Decrypted packets contained within.
|
/** Decrypted packets contained within.
|
||||||
* @type {module:packet/packetlist} */
|
* @type {module:packet/packetlist} */
|
||||||
this.packets = null;
|
this.packets = null;
|
||||||
|
this.ignore_mdc_error = config.ignore_mdc_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
SymmetricallyEncrypted.prototype.read = function (bytes) {
|
SymmetricallyEncrypted.prototype.read = function (bytes) {
|
||||||
|
@ -15503,10 +15531,15 @@ SymmetricallyEncrypted.prototype.write = function () {
|
||||||
* algorithm
|
* algorithm
|
||||||
*/
|
*/
|
||||||
SymmetricallyEncrypted.prototype.decrypt = function (sessionKeyAlgorithm, key) {
|
SymmetricallyEncrypted.prototype.decrypt = function (sessionKeyAlgorithm, key) {
|
||||||
var decrypted = crypto.cfb.decrypt(
|
var decrypted = crypto.cfb.decrypt(sessionKeyAlgorithm, key, this.encrypted, true);
|
||||||
sessionKeyAlgorithm, key, this.encrypted, true);
|
// for modern cipher (blocklength != 64 bit, except for Twofish) MDC is required
|
||||||
|
if (!this.ignore_mdc_error &&
|
||||||
this.packets.read(decrypted.join(''))
|
(sessionKeyAlgorithm === 'aes128' ||
|
||||||
|
sessionKeyAlgorithm === 'aes192' ||
|
||||||
|
sessionKeyAlgorithm === 'aes256')) {
|
||||||
|
throw new Error('Decryption failed due to missing MDC in combination with modern cipher.')
|
||||||
|
}
|
||||||
|
this.packets.read(decrypted.join(''));
|
||||||
};
|
};
|
||||||
|
|
||||||
SymmetricallyEncrypted.prototype.encrypt = function (algo, key) {
|
SymmetricallyEncrypted.prototype.encrypt = function (algo, key) {
|
||||||
|
@ -15516,7 +15549,7 @@ SymmetricallyEncrypted.prototype.encrypt = function (algo, key) {
|
||||||
crypto.getPrefixRandom(algo), algo, data, key, true);
|
crypto.getPrefixRandom(algo), algo, data, key, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
},{"../crypto":32,"../enums.js":43}],70:[function(require,module,exports){
|
},{"../config":17,"../crypto":32,"../enums.js":43}],70:[function(require,module,exports){
|
||||||
/**
|
/**
|
||||||
* @requires enums
|
* @requires enums
|
||||||
* @module packet/trust
|
* @module packet/trust
|
||||||
|
|
14
dist/openpgp.min.js
vendored
14
dist/openpgp.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/openpgp.worker.min.js
vendored
2
dist/openpgp.worker.min.js
vendored
|
@ -1 +1 @@
|
||||||
/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v1.4.1 - 2015-12-19 */!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a){window.openpgp.crypto.random.randomBuffer.size<g&&postMessage({event:"request-seed"}),postMessage(a)}function e(a){var b=window.openpgp.packet.List.fromStructuredClone(a);return new window.openpgp.key.Key(b)}function f(a){var b=window.openpgp.packet.List.fromStructuredClone(a);return new window.openpgp.message.Message(b)}window={},Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),importScripts("openpgp.min.js");var g=4e4,h=6e4;window.openpgp.crypto.random.randomBuffer.init(h),self.onmessage=function(a){var b=null,c=null,g=a.data,h=!1;switch(g.event){case"configure":for(var i in g.config)window.openpgp.config[i]=g.config[i];break;case"seed-random":g.buf instanceof Uint8Array||(g.buf=new Uint8Array(g.buf)),window.openpgp.crypto.random.randomBuffer.set(g.buf);break;case"encrypt-message":g.keys.length||(g.keys=[g.keys]),g.keys=g.keys.map(e),window.openpgp.encryptMessage(g.keys,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"sign-and-encrypt-message":g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e),g.privateKey=e(g.privateKey),window.openpgp.signAndEncryptMessage(g.publicKeys,g.privateKey,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-message":g.privateKey=e(g.privateKey),g.message=f(g.message.packets),window.openpgp.decryptMessage(g.privateKey,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-and-verify-message":g.privateKey=e(g.privateKey),g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e),g.message=f(g.message.packets),window.openpgp.decryptAndVerifyMessage(g.privateKey,g.publicKeys,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"sign-clear-message":g.privateKeys=g.privateKeys.map(e),window.openpgp.signClearMessage(g.privateKeys,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"verify-clear-signed-message":g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e);var j=window.openpgp.packet.List.fromStructuredClone(g.message.packets);g.message=new window.openpgp.cleartext.CleartextMessage(g.message.text,j),window.openpgp.verifyClearSignedMessage(g.publicKeys,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"generate-key-pair":window.openpgp.generateKeyPair(g.options).then(function(a){a.key=a.key.toPacketlist(),d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-key":try{g.privateKey=e(g.privateKey),h=g.privateKey.decrypt(g.password),h?b=g.privateKey.toPacketlist():c="Wrong password"}catch(k){c=k.message}d({event:"method-return",data:b,err:c});break;case"decrypt-key-packet":try{g.privateKey=e(g.privateKey),g.keyIds=g.keyIds.map(window.openpgp.Keyid.fromClone),h=g.privateKey.decryptKeyPacket(g.keyIds,g.password),h?b=g.privateKey.toPacketlist():c="Wrong password"}catch(k){c=k.message}d({event:"method-return",data:b,err:c});break;default:throw new Error("Unknown Worker Event.")}}},{}]},{},[1]);
|
/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v1.4.1 - 2016-01-07 */!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a){window.openpgp.crypto.random.randomBuffer.size<g&&postMessage({event:"request-seed"}),postMessage(a)}function e(a){var b=window.openpgp.packet.List.fromStructuredClone(a);return new window.openpgp.key.Key(b)}function f(a){var b=window.openpgp.packet.List.fromStructuredClone(a);return new window.openpgp.message.Message(b)}window={},Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),importScripts("openpgp.min.js");var g=4e4,h=6e4;window.openpgp.crypto.random.randomBuffer.init(h),self.onmessage=function(a){var b=null,c=null,g=a.data,h=!1;switch(g.event){case"configure":for(var i in g.config)window.openpgp.config[i]=g.config[i];break;case"seed-random":g.buf instanceof Uint8Array||(g.buf=new Uint8Array(g.buf)),window.openpgp.crypto.random.randomBuffer.set(g.buf);break;case"encrypt-message":g.keys.length||(g.keys=[g.keys]),g.keys=g.keys.map(e),window.openpgp.encryptMessage(g.keys,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"sign-and-encrypt-message":g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e),g.privateKey=e(g.privateKey),window.openpgp.signAndEncryptMessage(g.publicKeys,g.privateKey,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-message":g.privateKey=e(g.privateKey),g.message=f(g.message.packets),window.openpgp.decryptMessage(g.privateKey,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-and-verify-message":g.privateKey=e(g.privateKey),g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e),g.message=f(g.message.packets),window.openpgp.decryptAndVerifyMessage(g.privateKey,g.publicKeys,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"sign-clear-message":g.privateKeys=g.privateKeys.map(e),window.openpgp.signClearMessage(g.privateKeys,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"verify-clear-signed-message":g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e);var j=window.openpgp.packet.List.fromStructuredClone(g.message.packets);g.message=new window.openpgp.cleartext.CleartextMessage(g.message.text,j),window.openpgp.verifyClearSignedMessage(g.publicKeys,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"generate-key-pair":window.openpgp.generateKeyPair(g.options).then(function(a){a.key=a.key.toPacketlist(),d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-key":try{g.privateKey=e(g.privateKey),h=g.privateKey.decrypt(g.password),h?b=g.privateKey.toPacketlist():c="Wrong password"}catch(k){c=k.message}d({event:"method-return",data:b,err:c});break;case"decrypt-key-packet":try{g.privateKey=e(g.privateKey),g.keyIds=g.keyIds.map(window.openpgp.Keyid.fromClone),h=g.privateKey.decryptKeyPacket(g.keyIds,g.password),h?b=g.privateKey.toPacketlist():c="Wrong password"}catch(k){c=k.message}d({event:"method-return",data:b,err:c});break;default:throw new Error("Unknown Worker Event.")}}},{}]},{},[1]);
|
|
@ -167,7 +167,7 @@ function RSA() {
|
||||||
};
|
};
|
||||||
|
|
||||||
keys = webCrypto.generateKey(keyGenOpt, true, ['sign', 'verify']);
|
keys = webCrypto.generateKey(keyGenOpt, true, ['sign', 'verify']);
|
||||||
if (!(keys instanceof Promise)) { // IE11 KeyOperation
|
if (!(typeof keys.then === 'function')) { // IE11 KeyOperation
|
||||||
keys = convertKeyOperation(keys, 'Error generating RSA key pair.');
|
keys = convertKeyOperation(keys, 'Error generating RSA key pair.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ function RSA() {
|
||||||
// export the generated keys as JsonWebKey (JWK)
|
// export the generated keys as JsonWebKey (JWK)
|
||||||
// https://tools.ietf.org/html/draft-ietf-jose-json-web-key-33
|
// https://tools.ietf.org/html/draft-ietf-jose-json-web-key-33
|
||||||
var key = webCrypto.exportKey('jwk', keypair.privateKey);
|
var key = webCrypto.exportKey('jwk', keypair.privateKey);
|
||||||
if (!(key instanceof Promise)) { // IE11 KeyOperation
|
if (!(typeof key.then === 'function')) { // IE11 KeyOperation
|
||||||
key = convertKeyOperation(key, 'Error exporting RSA key pair.');
|
key = convertKeyOperation(key, 'Error exporting RSA key pair.');
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user