diff --git a/src/ssn/decryption/decryptChunk.ts b/src/ssn/decryption/decryptChunk.ts index b733a85..fcab808 100644 --- a/src/ssn/decryption/decryptChunk.ts +++ b/src/ssn/decryption/decryptChunk.ts @@ -12,7 +12,7 @@ export default function getDecryptor(decryptionKeys: [number, number, number]) { let curChar = encryptedChunk.readUInt8(i); //decrypt byte - const keyPart = (key2 | 2) & 0xFFFF; + const keyPart = ((key2 | 2) >>> 0) & 0xFFFF; const decryptedByte = int32Mul(keyPart, keyPart ^ 1) >>> 8; curChar = (curChar ^ (decryptedByte & 0xFF)) & 0xFF; diff --git a/src/ssn/decryption/lib/updateKeys.ts b/src/ssn/decryption/lib/updateKeys.ts index 986bd0d..966c073 100644 --- a/src/ssn/decryption/lib/updateKeys.ts +++ b/src/ssn/decryption/lib/updateKeys.ts @@ -3,7 +3,7 @@ import int32Mul from './int32Mul'; export default function updateKeys([key0, key1, key2]: [number, number, number], curChar: number): [number, number, number] { key0 = getCrc(key0, curChar); - key1 = ((int32Mul(((key1 + (key0 & 0xFF)) >>> 0), 134775813) >>> 0) + 1) >>> 0; + key1 = ((int32Mul((((key1 >>> 0) + ((key0 >>> 0) & 0xFF)) >>> 0), 134775813) >>> 0) + 1) >>> 0; key2 = getCrc(key2, key1 >>> 24); return [key0, key1, key2];