1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

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.)
This commit is contained in:
Nico Weber 2023-07-20 14:07:08 -04:00 committed by Andreas Kling
parent 0428308420
commit 9cbdb334ab

View file

@ -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 = {};