From b80ac4e3cdc355cfa97d153c439dd4432b4f4fbb Mon Sep 17 00:00:00 2001 From: Ryan Emery Date: Tue, 27 Aug 2019 15:37:40 -0700 Subject: [PATCH] fix: Zero length frames in old version of Node resolves #199 In Node.js versions 10.9 and older will fail to decrypt if decipher.update is not called. https://github.com/nodejs/node/pull/22538 fixes this. If the content is empty, push an empty buffer. --- modules/decrypt-node/src/decipher_stream.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/decrypt-node/src/decipher_stream.ts b/modules/decrypt-node/src/decipher_stream.ts index d6bbaefed..e7368cb94 100644 --- a/modules/decrypt-node/src/decipher_stream.ts +++ b/modules/decrypt-node/src/decipher_stream.ts @@ -160,6 +160,10 @@ export function getDecipherStream () { decipherState = {} as any decipher.setAuthTag(authTag) + /* In Node.js versions 10.9 and older will fail to decrypt if decipher.update is not called. + * https://github.com/nodejs/node/pull/22538 fixes this. + */ + if (!content.length) decipher.update(Buffer.alloc(0)) const clear: Buffer[] = [] for (const cipherChunk of content) {