diff --git a/src/packet/compressed_data.js b/src/packet/compressed_data.js index cdeddea0..fa7fddc2 100644 --- a/src/packet/compressed_data.js +++ b/src/packet/compressed_data.js @@ -151,8 +151,12 @@ function zlib(compressionStreamInstantiator, ZlibStreamedConstructor) { return streamFromAsync(() => streamReadToEnd(data).then(inputData => { return new Promise((resolve, reject) => { const zlibStream = new ZlibStreamedConstructor(); - zlibStream.ondata = processedData => { - resolve(processedData); + const processedChunks = []; + zlibStream.ondata = (processedData, final) => { + processedChunks.push(processedData); + if (final) { + resolve(util.concatUint8Array(processedChunks)); + } }; try { zlibStream.push(inputData, true); // only one chunk to push diff --git a/test/general/openpgp.js b/test/general/openpgp.js index 4558cb5c..d626522b 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -3698,6 +3698,26 @@ XfA3pqV4mTzF }); }); + it('should encrypt and decrypt with one password (larger message)', async function () { + const largerPlaintext = new Uint8Array(100_000); + const encOpt = modifyCompressionEncryptOptions({ + message: await openpgp.createMessage({ binary: largerPlaintext }), + passwords: password1 + }); + const decOpt = { + passwords: password1, + format: 'binary' + }; + return openpgp.encrypt(encOpt).then(async function (encrypted) { + decOpt.message = await openpgp.readMessage({ armoredMessage: encrypted }); + return openpgp.decrypt(decOpt); + }).then(function (decrypted) { + expect(util.equalsUint8Array(decrypted.data, largerPlaintext)).to.be.true; + expect(decrypted.signatures.length).to.equal(0); + verifyCompressionDecrypted(decrypted); + }); + }); + it('Streaming encrypt and decrypt small message roundtrip', async function() { const plaintext = []; let i = 0;