mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-03 02:48:49 +03:00
Cleanup OpenPGP.js and prepare for using Rollup
This commit is contained in:
parent
f6bba786ed
commit
c571a4fbe7
22 changed files with 5522 additions and 582 deletions
6
vendors/openpgp-2.6.2/src/crypto/gcm.js
vendored
6
vendors/openpgp-2.6.2/src/crypto/gcm.js
vendored
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
import util from '../util.js';
|
||||
import config from '../config';
|
||||
import asmCrypto from '../asmcrypto.js';
|
||||
import '../asmcrypto.js';
|
||||
const webCrypto = util.getWebCrypto(); // no GCM support in IE11, Safari 9
|
||||
|
||||
export const ivLength = 12; // size of the IV in bytes
|
||||
|
|
@ -43,7 +43,7 @@ export function encrypt(cipher, plaintext, key, iv) {
|
|||
return Promise.reject(new Error('GCM mode supports only AES cipher'));
|
||||
}
|
||||
|
||||
if (webCrypto && config.use_native && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
|
||||
if (webCrypto && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
|
||||
return webEncrypt(plaintext, key, iv);
|
||||
}
|
||||
// asm.js fallback
|
||||
|
|
@ -63,7 +63,7 @@ export function decrypt(cipher, ciphertext, key, iv) {
|
|||
return Promise.reject(new Error('GCM mode supports only AES cipher'));
|
||||
}
|
||||
|
||||
if (webCrypto && config.use_native && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
|
||||
if (webCrypto && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
|
||||
return webDecrypt(ciphertext, key, iv);
|
||||
}
|
||||
// asm.js fallback
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
'use strict';
|
||||
|
||||
import sha from './sha.js';
|
||||
import asmCrypto from '../../asmcrypto.js';
|
||||
import Rusha from '../../rusha.js';
|
||||
import '../../asmcrypto.js';
|
||||
import '../../rusha.js';
|
||||
import md5 from './md5.js';
|
||||
import ripemd from './ripe-md.js';
|
||||
import util from '../../util.js';
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ export default function DSA() {
|
|||
}
|
||||
return usersetting;
|
||||
default:
|
||||
util.print_debug("DSA select hash algorithm: returning null for an unknown length of q");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -110,12 +109,10 @@ export default function DSA() {
|
|||
s1.compareTo(q) >= 0 ||
|
||||
BigInteger.ZERO.compareTo(s2) >= 0 ||
|
||||
s2.compareTo(q) >= 0) {
|
||||
util.print_debug("invalid DSA Signature");
|
||||
return null;
|
||||
}
|
||||
var w = s2.modInverse(q);
|
||||
if (BigInteger.ZERO.compareTo(w) === 0) {
|
||||
util.print_debug("invalid DSA Signature");
|
||||
return null;
|
||||
}
|
||||
var u1 = hash.multiply(w).mod(q);
|
||||
|
|
|
|||
|
|
@ -44,10 +44,6 @@ export default function Elgamal() {
|
|||
}
|
||||
|
||||
function decrypt(c1, c2, p, x) {
|
||||
util.print_debug("Elgamal Decrypt:\nc1:" + util.hexstrdump(c1.toMPI()) + "\n" +
|
||||
"c2:" + util.hexstrdump(c2.toMPI()) + "\n" +
|
||||
"p:" + util.hexstrdump(p.toMPI()) + "\n" +
|
||||
"x:" + util.hexstrdump(x.toMPI()));
|
||||
return (c1.modPow(x, p).modInverse(p)).multiply(c2).mod(p);
|
||||
//var c = c1.pow(x).modInverse(p); // c0^-a mod p
|
||||
//return c.multiply(c2).mod(p);
|
||||
|
|
|
|||
|
|
@ -77,12 +77,9 @@ export default function RSA() {
|
|||
* @return {BigInteger} The decrypted value of the message
|
||||
*/
|
||||
function decrypt(m, n, e, d, p, q, u) {
|
||||
if (config.rsa_blinding) {
|
||||
m = blind(m, n, e);
|
||||
}
|
||||
m = blind(m, n, e);
|
||||
var xp = m.mod(p).modPow(d.mod(p.subtract(BigInteger.ONE)), p);
|
||||
var xq = m.mod(q).modPow(d.mod(q.subtract(BigInteger.ONE)), q);
|
||||
util.print_debug("rsa.js decrypt\nxpn:" + util.hexstrdump(xp.toMPI()) + "\nxqn:" + util.hexstrdump(xq.toMPI()));
|
||||
|
||||
var t = xq.subtract(xp);
|
||||
if (t[0] === 0) {
|
||||
|
|
@ -93,9 +90,7 @@ export default function RSA() {
|
|||
t = t.multiply(u).mod(q);
|
||||
}
|
||||
t = t.multiply(p).add(xp);
|
||||
if (config.rsa_blinding) {
|
||||
t = unblind(t, n);
|
||||
}
|
||||
t = unblind(t, n);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue