1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #19496 from Snuffleupagus/shorter-#buildObjectKey

Shorten the `CipherTransformFactory.prototype.#buildObjectKey` method
This commit is contained in:
Jonas Jenwald 2025-02-15 17:03:35 +01:00 committed by GitHub
commit 8dec353c7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1595,12 +1595,10 @@ class CipherTransformFactory {
}
#buildObjectKey(num, gen, encryptionKey, isAes = false) {
const key = new Uint8Array(encryptionKey.length + 9);
const n = encryptionKey.length;
let i;
for (i = 0; i < n; ++i) {
key[i] = encryptionKey[i];
}
const key = new Uint8Array(n + 9);
key.set(encryptionKey);
let i = n;
key[i++] = num & 0xff;
key[i++] = (num >> 8) & 0xff;
key[i++] = (num >> 16) & 0xff;
@ -1613,7 +1611,7 @@ class CipherTransformFactory {
key[i++] = 0x54;
}
const hash = calculateMD5(key, 0, i);
return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
return hash.subarray(0, Math.min(n + 5, 16));
}
#buildCipherConstructor(cf, name, num, gen, key) {