diff --git a/src/ssn/extractFileStream.ts b/src/ssn/extractFileStream.ts index ca7899d..8b6689b 100644 --- a/src/ssn/extractFileStream.ts +++ b/src/ssn/extractFileStream.ts @@ -31,13 +31,14 @@ export default function extractFileStream(file: ISsnFileEntry, inputStream: stre let curStream = inputStream; - //set max length - const maxLength = streamSetMaxLength(curStream, 12 + file.compressedSize); + const storedSize = (file.decryptionKeys !== undefined) ? (12 + file.compressedSize) : file.compressedSize; + //set max length (including random 12 byte encryption header) + const maxLength = streamSetMaxLength(curStream, storedSize); curStream = maxLength; //pipe into decryption if file is encrypted if (file.decryptionKeys !== undefined) { - const decryptTransform = decryptStream(curStream, file.decryptionKeys); + const decryptTransform = decryptStream(curStream, [...file.decryptionKeys] as [number, number, number]); curStream = decryptTransform; }