From 5f09f797ab4538aa2313312e11543623c87fd759 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Thu, 16 Jul 2026 14:00:06 +0200 Subject: [PATCH] Fix decryption of AES-256 revision 5 PDFs with non-ASCII passwords It fixes #21579. --- src/core/crypto.js | 2 +- test/pdfs/.gitignore | 1 + test/pdfs/issue21579.pdf | Bin 0 -> 1394 bytes test/test_manifest.json | 8 +++++++ test/unit/crypto_spec.js | 47 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/issue21579.pdf diff --git a/src/core/crypto.js b/src/core/crypto.js index 744254e29..567c2f11b 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -1130,7 +1130,7 @@ class CipherTransformFactory { const fileIdBytes = stringToBytes(fileId); let passwordBytes; if (password) { - if (revision === 6) { + if (algorithm === 5) { try { password = utf8StringToString(password); } catch { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 7cd2904ed..b2c905c79 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -943,3 +943,4 @@ !issue17333.pdf !issue20504.pdf !issue20504_skia.pdf +!issue21579.pdf diff --git a/test/pdfs/issue21579.pdf b/test/pdfs/issue21579.pdf new file mode 100644 index 0000000000000000000000000000000000000000..fb01774c0014b07fb329a3cae999b3a260d1937f GIT binary patch literal 1394 zcmah}O=}%h7#2hqcOh!rs9+Cbtf1+fk2!PB!P~(3Y^uhjxi%KlE+)Ctz~i=KR3+JzjSzQW9;>ZkH7il27dHF{{BJz>{oaHx%$_O1Q54a_GnFpPbDf zTYW_QzJ6`(!qCw(H=kQL_f+@b+5>kFsm&_O^o^^3 z&L@|zG?%Yk{QQ!C<*j|kVj$bDZdW1(z7x_`>H29&8ok-7U&#m(l$g9*Y<(Fk7FUX@ zHJ1;RB^yu)t;MP+QPQaLb~7)VD4B-zCR6dToixfb$a3f>zfm=}S2m2JMEk}x+a)pz zNUvJ(E3vwX>o7ww%oHL9f$?L+~1mG?Fis7{EM!YWB+2$GvrGQxDQ8BGnwTn6eK zcU~J2U`>r6iaTKic06@fVd^twGAx`?L@Licvo=scL6T}Gq=P;=3RW~{+-ORp9XLG41P(5eiOWbZhSDr3=9vlvjGK^Qa8)y$rV1!Qb7zPbfH@