diff --git a/src/ssn/decryption/decryptChunk.ts b/src/ssn/decryption/decryptChunk.ts index ea6b6e5..8c60509 100644 --- a/src/ssn/decryption/decryptChunk.ts +++ b/src/ssn/decryption/decryptChunk.ts @@ -1,31 +1,10 @@ import updateKeys from './lib/updateKeys'; -/*export default function decryptChunk(encryptedChunk: Buffer, [key0, key1, key2]: [number, number, number]): {decryptedChunk: Buffer, keys: [number, number, number]} { - const decryptedChunk = Buffer.alloc(encryptedChunk.length); - const dvOut = new DataView(decryptedChunk.buffer); - - for (let i = 0; i < encryptedChunk.length; i += 1) { - //read and decrypt byte - let curChar = encryptedChunk.readUInt8(i); - const keyPart = (key2 | 2) & 0xFFFF; - const decryptedByte = (keyPart * (keyPart ^ 1)) >>> 8; - curChar ^= decryptedByte & 0xFF; - dvOut.setUint8(i, curChar); - - //update keys - [key0, key1, key2] = updateKeys([key0, key1, key2], curChar); - } - - return { decryptedChunk, keys: [key0, key1, key2] }; -}*/ - export default function getDecryptor(decryptionKeys: [number, number, number]) { let [key0, key1, key2] = decryptionKeys; - let position = 0; return (encryptedChunk: Buffer) => { const decryptedChunk = Buffer.alloc(encryptedChunk.length); - //const decryptedChunk = Buffer.alloc(encryptedChunk.length - Math.max(12 - position, 0)); for (let i = 0; i < encryptedChunk.length; i += 1) { //read byte @@ -40,18 +19,9 @@ export default function getDecryptor(decryptionKeys: [number, number, number]) { [key0, key1, key2] = updateKeys([key0, key1, key2], curChar); //write byte - /*if (position + i < 12) { - //do nothing - } else if (position + i >= 12 && position < 12) { - decryptedChunk.writeUInt8(curChar, position + i - 12); - } else { - decryptedChunk.writeUInt8(curChar, i); - }*/ decryptedChunk.writeUInt8(curChar, i); } - position += encryptedChunk.length; - return decryptedChunk; }; } diff --git a/src/ssn/getPatch.ts b/src/ssn/getPatch.ts index 46178f6..1158798 100644 --- a/src/ssn/getPatch.ts +++ b/src/ssn/getPatch.ts @@ -32,7 +32,6 @@ export default async function getPatch(product: Product, from: number, to: numbe //Then we need to wait for disks to finish download before we can extract individual files //TODO: we can optimize this to already extract some files as soon as their relevant parts are downloaded const diskFilenames = await Promise.all(diskFiles); - //const dvArray = bufferArray.map((buffer) => new DataView(buffer)); //TODO: Verify that downloaded files match the hash in `solidpkg.pieces`