Bugfix our modified OpenPGP.js

This commit is contained in:
the-djmaze 2022-01-31 11:54:13 +01:00
parent c012fe09f0
commit 70c55a60be
2 changed files with 8 additions and 34 deletions

View file

@ -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);