mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-22 21:14:55 +08:00
Bugfix our modified OpenPGP.js
This commit is contained in:
parent
c012fe09f0
commit
70c55a60be
2 changed files with 8 additions and 34 deletions
|
@ -194,9 +194,14 @@ RainLoop uses the old OpenPGP.js v2
|
||||||
SnappyMail v2.12 uses OpenPGP.js v5, GnuPG and Mailvelope.
|
SnappyMail v2.12 uses OpenPGP.js v5, GnuPG and Mailvelope.
|
||||||
SnappyMail is able to use and generate ECDSA and EDDSA keys, where RainLoop does not.
|
SnappyMail is able to use and generate ECDSA and EDDSA keys, where RainLoop does not.
|
||||||
|
|
||||||
|
Since SnappyMail tries to achieve the best mobile experience, it forked OpenPGP.js to strip it down.
|
||||||
|
* remove all unused Node.js
|
||||||
|
* remove all old browsers support
|
||||||
|
See https://github.com/the-djmaze/openpgpjs for development
|
||||||
|
|
||||||
|OpenPGP |RainLoop |Snappy |RL gzip |SM gzip |RL brotli |SM brotli |
|
|OpenPGP |RainLoop |Snappy |RL gzip |SM gzip |RL brotli |SM brotli |
|
||||||
|--------------- |--------: |--------: |------: |-------: |--------: |--------: |
|
|--------------- |--------: |--------: |------: |-------: |--------: |--------: |
|
||||||
|openpgp.min.js | 330.742 | 550.724 |102.388 | 170.033 | 84.241 | 139.429 |
|
|openpgp.min.js | 330.742 | 540.542 |102.388 | 167.397 | 84.241 | 137.502 |
|
||||||
|openpgp.worker | 1.499 | | 824 | | 695 | |
|
|openpgp.worker | 1.499 | | 824 | | 695 | |
|
||||||
|
|
||||||
|
|
||||||
|
|
35
vendors/openpgp-5/dist/openpgp.js
vendored
35
vendors/openpgp-5/dist/openpgp.js
vendored
|
@ -2034,18 +2034,8 @@ var openpgp = (function (exports) {
|
||||||
* provided with the application or distribution.
|
* provided with the application or distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let encodeChunk;
|
let encodeChunk = buf => btoa(util.uint8ArrayToString(buf));
|
||||||
let decodeChunk;
|
let decodeChunk = str => util.stringToUint8Array(atob(str));
|
||||||
if (Buffer) {
|
|
||||||
encodeChunk = buf => Buffer.from(buf).toString('base64');
|
|
||||||
decodeChunk = str => {
|
|
||||||
const b = Buffer.from(str, 'base64');
|
|
||||||
return new Uint8Array(b.buffer, b.byteOffset, b.byteLength);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
encodeChunk = buf => btoa(util.uint8ArrayToString(buf));
|
|
||||||
decodeChunk = str => util.stringToUint8Array(atob(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert binary array to radix-64
|
* Convert binary array to radix-64
|
||||||
|
@ -10722,8 +10712,6 @@ var openpgp = (function (exports) {
|
||||||
// OpenPGP.js - An OpenPGP implementation in javascript
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
||||||
|
|
||||||
const webCrypto$4 = util.getWebCrypto();
|
const webCrypto$4 = util.getWebCrypto();
|
||||||
const nodeCrypto = util.getNodeCrypto();
|
|
||||||
const Buffer$1 = util.getNodeBuffer();
|
|
||||||
|
|
||||||
const blockLength = 16;
|
const blockLength = 16;
|
||||||
const ivLength = 12; // size of the IV in bytes
|
const ivLength = 12; // size of the IV in bytes
|
||||||
|
@ -10776,25 +10764,6 @@ var openpgp = (function (exports) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (util.getNodeCrypto()) { // Node crypto library
|
|
||||||
return {
|
|
||||||
encrypt: async function(pt, iv, adata = new Uint8Array()) {
|
|
||||||
const en = new nodeCrypto.createCipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
|
|
||||||
en.setAAD(adata);
|
|
||||||
const ct = Buffer$1.concat([en.update(pt), en.final(), en.getAuthTag()]); // append auth tag to ciphertext
|
|
||||||
return new Uint8Array(ct);
|
|
||||||
},
|
|
||||||
|
|
||||||
decrypt: async function(ct, iv, adata = new Uint8Array()) {
|
|
||||||
const de = new nodeCrypto.createDecipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
|
|
||||||
de.setAAD(adata);
|
|
||||||
de.setAuthTag(ct.slice(ct.length - tagLength, ct.length)); // read auth tag at end of ciphertext
|
|
||||||
const pt = Buffer$1.concat([de.update(ct.slice(0, ct.length - tagLength)), de.final()]);
|
|
||||||
return new Uint8Array(pt);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
encrypt: async function(pt, iv, adata) {
|
encrypt: async function(pt, iv, adata) {
|
||||||
return AES_GCM.encrypt(pt, key, iv, adata);
|
return AES_GCM.encrypt(pt, key, iv, adata);
|
||||||
|
|
Loading…
Add table
Reference in a new issue