From 70c55a60be1a79b1c79836a1468c2b67b1dc1664 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 31 Jan 2022 11:54:13 +0100 Subject: [PATCH] Bugfix our modified OpenPGP.js --- README.md | 7 ++++++- vendors/openpgp-5/dist/openpgp.js | 35 ++----------------------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index a6fff690f..636718de3 100644 --- a/README.md +++ b/README.md @@ -194,9 +194,14 @@ RainLoop uses the old OpenPGP.js v2 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. +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.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 | | diff --git a/vendors/openpgp-5/dist/openpgp.js b/vendors/openpgp-5/dist/openpgp.js index 8e953ea81..a37bdaec2 100644 --- a/vendors/openpgp-5/dist/openpgp.js +++ b/vendors/openpgp-5/dist/openpgp.js @@ -2034,18 +2034,8 @@ var openpgp = (function (exports) { * provided with the application or distribution. */ - let encodeChunk; - let decodeChunk; - 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)); - } + let encodeChunk = buf => btoa(util.uint8ArrayToString(buf)); + let decodeChunk = str => util.stringToUint8Array(atob(str)); /** * Convert binary array to radix-64 @@ -10722,8 +10712,6 @@ var openpgp = (function (exports) { // OpenPGP.js - An OpenPGP implementation in javascript const webCrypto$4 = util.getWebCrypto(); - const nodeCrypto = util.getNodeCrypto(); - const Buffer$1 = util.getNodeBuffer(); const blockLength = 16; 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 { encrypt: async function(pt, iv, adata) { return AES_GCM.encrypt(pt, key, iv, adata);