diff --git a/src/core/crypto.js b/src/core/crypto.js index 5c95a7b53..89daf30b2 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -1787,7 +1787,14 @@ class CipherTransformFactory { ); } - this.encryptionKey = encryptionKey; + if (algorithm === 4 && encryptionKey.length < 16) { + // Extend key to 16 byte minimum (undocumented), + // fixes issue19484_1.pdf and issue19484_2.pdf. + this.encryptionKey = new Uint8Array(16); + this.encryptionKey.set(encryptionKey); + } else { + this.encryptionKey = encryptionKey; + } if (algorithm >= 4) { const cf = dict.get("CF"); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index c3ff64116..9d415b91c 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -106,6 +106,7 @@ !issue9084.pdf !issue12963.pdf !issue9105_reduced.pdf +!issue19484_2.pdf !issue9105_other.pdf !issue9252.pdf !issue9262_reduced.pdf @@ -481,6 +482,7 @@ !openoffice.pdf !js-buttons.pdf !issue7014.pdf +!issue19484_1.pdf !issue8187.pdf !annotation-link-text-popup.pdf !issue9278.pdf diff --git a/test/pdfs/issue19484_1.pdf b/test/pdfs/issue19484_1.pdf new file mode 100644 index 000000000..2e8a37de0 Binary files /dev/null and b/test/pdfs/issue19484_1.pdf differ diff --git a/test/pdfs/issue19484_2.pdf b/test/pdfs/issue19484_2.pdf new file mode 100644 index 000000000..4a8caeb74 Binary files /dev/null and b/test/pdfs/issue19484_2.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 8c9058adf..28506e4c8 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -3629,6 +3629,14 @@ "link": false, "type": "text" }, + { + "id": "issue19484_1", + "file": "pdfs/issue19484_1.pdf", + "md5": "4e9e78a84226dbdddbd735388ccc2dcd", + "rounds": 1, + "link": false, + "type": "eq" + }, { "id": "issue5644", "file": "pdfs/issue5644.pdf", @@ -5043,6 +5051,14 @@ "rounds": 1, "type": "eq" }, + { + "id": "issue19484_2", + "file": "pdfs/issue19484_2.pdf", + "md5": "cd3050eda9fa18a7e6a78c702f9890bb", + "rounds": 1, + "link": false, + "type": "eq" + }, { "id": "bug894572", "file": "pdfs/bug894572.pdf",