mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-10 01:47:03 +03:00
Fix OpenPGP error
This commit is contained in:
parent
b2b576a69c
commit
066a0c08d2
7 changed files with 29 additions and 152 deletions
3
vendors/openpgp-2.6.2/src/crypto/gcm.js
vendored
3
vendors/openpgp-2.6.2/src/crypto/gcm.js
vendored
|
|
@ -24,11 +24,10 @@
|
|||
|
||||
import util from '../util.js';
|
||||
import config from '../config';
|
||||
import asmCrypto from 'asmcrypto-lite';
|
||||
import asmCrypto from '../asmcrypto.js';
|
||||
const webCrypto = util.getWebCrypto(); // no GCM support in IE11, Safari 9
|
||||
|
||||
export const ivLength = 12; // size of the IV in bytes
|
||||
const TAG_LEN = 16; // size of the tag in bytes
|
||||
const ALGO = 'AES-GCM';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
'use strict';
|
||||
|
||||
import sha from './sha.js';
|
||||
import asmCrypto from 'asmcrypto-lite';
|
||||
import Rusha from 'rusha';
|
||||
import asmCrypto from '../../asmcrypto.js';
|
||||
import Rusha from '../../rusha.js';
|
||||
import md5 from './md5.js';
|
||||
import ripemd from './ripe-md.js';
|
||||
import util from '../../util.js';
|
||||
|
|
|
|||
|
|
@ -44,10 +44,6 @@ import util from '../../util.js';
|
|||
// Bits per digit
|
||||
var dbits;
|
||||
|
||||
// JavaScript engine analysis
|
||||
var canary = 0xdeadbeefcafe;
|
||||
var j_lm = ((canary & 0xffffff) == 0xefcafe);
|
||||
|
||||
// (public) Constructor
|
||||
|
||||
export default function BigInteger(a, b, c) {
|
||||
|
|
@ -80,52 +76,9 @@ function am1(i, x, w, j, c, n) {
|
|||
}
|
||||
return c;
|
||||
}
|
||||
// am2 avoids a big mult-and-extract completely.
|
||||
// Max digit bits should be <= 30 because we do bitwise ops
|
||||
// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
|
||||
|
||||
function am2(i, x, w, j, c, n) {
|
||||
var xl = x & 0x7fff,
|
||||
xh = x >> 15;
|
||||
while (--n >= 0) {
|
||||
var l = this[i] & 0x7fff;
|
||||
var h = this[i++] >> 15;
|
||||
var m = xh * l + h * xl;
|
||||
l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
|
||||
c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
|
||||
w[j++] = l & 0x3fffffff;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
// Alternately, set max digit bits to 28 since some
|
||||
// browsers slow down when dealing with 32-bit numbers.
|
||||
|
||||
function am3(i, x, w, j, c, n) {
|
||||
var xl = x & 0x3fff,
|
||||
xh = x >> 14;
|
||||
while (--n >= 0) {
|
||||
var l = this[i] & 0x3fff;
|
||||
var h = this[i++] >> 14;
|
||||
var m = xh * l + h * xl;
|
||||
l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
|
||||
c = (l >> 28) + (m >> 14) + xh * h;
|
||||
w[j++] = l & 0xfffffff;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
/*if(j_lm && (navigator != undefined &&
|
||||
navigator.appName == "Microsoft Internet Explorer")) {
|
||||
BigInteger.prototype.am = am2;
|
||||
dbits = 30;
|
||||
}
|
||||
else if(j_lm && (navigator != undefined && navigator.appName != "Netscape")) {*/
|
||||
BigInteger.prototype.am = am1;
|
||||
dbits = 26;
|
||||
/*}
|
||||
else { // Mozilla/Netscape seems to prefer am3
|
||||
BigInteger.prototype.am = am3;
|
||||
dbits = 28;
|
||||
}*/
|
||||
|
||||
BigInteger.prototype.DB = dbits;
|
||||
BigInteger.prototype.DM = ((1 << dbits) - 1);
|
||||
|
|
@ -1584,32 +1537,6 @@ function bnIsProbablePrime(t) {
|
|||
|
||||
/* added by Recurity Labs */
|
||||
|
||||
function nbits(x) {
|
||||
var n = 1,
|
||||
t;
|
||||
if ((t = x >>> 16) != 0) {
|
||||
x = t;
|
||||
n += 16;
|
||||
}
|
||||
if ((t = x >> 8) != 0) {
|
||||
x = t;
|
||||
n += 8;
|
||||
}
|
||||
if ((t = x >> 4) != 0) {
|
||||
x = t;
|
||||
n += 4;
|
||||
}
|
||||
if ((t = x >> 2) != 0) {
|
||||
x = t;
|
||||
n += 2;
|
||||
}
|
||||
if ((t = x >> 1) != 0) {
|
||||
x = t;
|
||||
n += 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
function bnToMPI() {
|
||||
var ba = this.toByteArray();
|
||||
var size = (ba.length - 1) * 8 + nbits(ba[0]);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import config from '../config';
|
||||
import * as keyModule from '../key.js';
|
||||
import util from '../util.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
import util from '../util.js';
|
||||
import crypto from '../crypto';
|
||||
import enums from '../enums.js';
|
||||
import asmCrypto from 'asmcrypto-lite';
|
||||
import asmCrypto from '../asmcrypto.js';
|
||||
|
||||
const VERSION = 1; // A one-octet version number of the data packet.
|
||||
|
||||
|
|
@ -146,5 +146,6 @@ function aesEncrypt(algo, prefix, pt, key) {
|
|||
}
|
||||
|
||||
function aesDecrypt(algo, ct, key) {
|
||||
return asmCrypto.AES_CFB.decrypt(ct, key).subarray(crypto.cipher[algo].blockSize + 2, pt.length); // Remove random prefix
|
||||
var pt = asmCrypto.AES_CFB.decrypt(ct, key);
|
||||
return pt.subarray(crypto.cipher[algo].blockSize + 2, pt.length); // Remove random prefix
|
||||
}
|
||||
|
|
|
|||
44
vendors/openpgp-2.6.2/src/util.js
vendored
44
vendors/openpgp-2.6.2/src/util.js
vendored
|
|
@ -25,19 +25,15 @@
|
|||
|
||||
import config from './config';
|
||||
|
||||
var browser = window || self;
|
||||
|
||||
export default {
|
||||
|
||||
isString: function(data) {
|
||||
return typeof data === 'string' || String.prototype.isPrototypeOf(data);
|
||||
},
|
||||
isString: data => typeof data === 'string' || String.prototype.isPrototypeOf(data),
|
||||
|
||||
isArray: function(data) {
|
||||
return Array.prototype.isPrototypeOf(data);
|
||||
},
|
||||
isArray: data => Array.isArray(data),
|
||||
|
||||
isUint8Array: function(data) {
|
||||
return Uint8Array.prototype.isPrototypeOf(data);
|
||||
},
|
||||
isUint8Array: data => Uint8Array.prototype.isPrototypeOf(data),
|
||||
|
||||
isEmailAddress: function(data) {
|
||||
if (!this.isString(data)) {
|
||||
|
|
@ -48,10 +44,7 @@ export default {
|
|||
},
|
||||
|
||||
isUserId: function(data) {
|
||||
if (!this.isString(data)) {
|
||||
return false;
|
||||
}
|
||||
return /</.test(data) && />$/.test(data);
|
||||
return this.isString(data) ? /</.test(data) && />$/.test(data) : false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -455,13 +448,7 @@ export default {
|
|||
* be deactivated with config.use_native
|
||||
* @return {Object} The SubtleCrypto api or 'undefined'
|
||||
*/
|
||||
getWebCrypto: function() {
|
||||
if (!config.use_native) {
|
||||
return;
|
||||
}
|
||||
|
||||
return typeof window !== 'undefined' && window.crypto && window.crypto.subtle;
|
||||
},
|
||||
getWebCrypto: () => config.use_native && browser && browser.crypto && browser.crypto.subtle,
|
||||
|
||||
/**
|
||||
* Get native Web Cryptography api for all browsers, including legacy
|
||||
|
|
@ -475,21 +462,14 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
if (window.crypto) {
|
||||
return window.crypto.subtle || window.crypto.webkitSubtle;
|
||||
if (browser) {
|
||||
if (browser.crypto) {
|
||||
return browser.crypto.subtle || browser.crypto.webkitSubtle;
|
||||
}
|
||||
if (window.msCrypto) {
|
||||
return window.msCrypto.subtle;
|
||||
if (browser.msCrypto) {
|
||||
return browser.msCrypto.subtle;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Detect Node.js runtime.
|
||||
*/
|
||||
detectNode: function() {
|
||||
return typeof window === 'undefined';
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue