From 9cbdb334ab53ee142ebba01b532ae04986178cd0 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 20 Jul 2023 14:07:08 -0400 Subject: [PATCH] LibPDF: Make try_provide_user_password() work for R6+ files try_provide_user_password() calls compute_encryption_key_r6_and_later() now. This checks both owner and user passwords. (For pre-R6 files, owner password checking isn't yet implemented, as far as I can tell.) With this, CIPA_DC-007-2021_E.pdf (or other AESV3-encrypted files) successfully compute a file encryption key (...and then hit the TODO() in StandardSecurityHandler::crypt() for AESV3, but it's still good progress.) --- Userland/Libraries/LibPDF/Encryption.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPDF/Encryption.cpp b/Userland/Libraries/LibPDF/Encryption.cpp index 68f448cb07..bfd27f6992 100644 --- a/Userland/Libraries/LibPDF/Encryption.cpp +++ b/Userland/Libraries/LibPDF/Encryption.cpp @@ -342,10 +342,13 @@ bool StandardSecurityHandler::authenticate_owner_password_r6_and_later(StringVie bool StandardSecurityHandler::try_provide_user_password(StringView password_string) { bool has_user_password; - if (m_revision >= 6) - has_user_password = authenticate_user_password_r6_and_later(password_string); - else + if (m_revision >= 6) { + // This checks both owner and user password. + auto password = ByteBuffer::copy(password_string.bytes()).release_value_but_fixme_should_propagate_errors(); + has_user_password = compute_encryption_key_r6_and_later(move(password)); + } else { has_user_password = authenticate_user_password_r2_to_r5(password_string); + } if (!has_user_password) m_encryption_key = {};