mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Tests/LibPDF: Add test for AES-encrypted PDF
I created this by typing "sup" into TextEdit.app on macOS 13.4, hitting Cmd-P to bring up the print dialog, clicked the PDF button at the bottom, changed Title and Author to "sup", clicked "Security Options…", and checked "Require password to open document" (with password "sup"). This file tests several things: - It has a compressed stream as first object. This used to make the linearization dict detection logic assert. - It uses AES as encryption key using version 4 of the encryption dict. This used to not be implemented.
This commit is contained in:
parent
e0887dd045
commit
2061ee2632
Notes:
sideshowbarker
2024-07-16 22:17:03 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/2061ee2632 Pull-request: https://github.com/SerenityOS/serenity/pull/19947 Reviewed-by: https://github.com/mattco98 ✅
3 changed files with 10 additions and 0 deletions
|
@ -10,6 +10,7 @@ set(TEST_FILES
|
|||
complex.pdf
|
||||
linearized.pdf
|
||||
non-linearized.pdf
|
||||
password-is-sup.pdf
|
||||
type1.pdf
|
||||
)
|
||||
install(FILES ${TEST_FILES} DESTINATION home/anon/Documents/pdf)
|
||||
|
|
|
@ -48,3 +48,12 @@ TEST_CASE(truncated_pdf_header_issue_10717)
|
|||
auto document = PDF::Document::create(string.bytes());
|
||||
EXPECT(document.is_error());
|
||||
}
|
||||
|
||||
TEST_CASE(encrypted_with_aes)
|
||||
{
|
||||
auto file = MUST(Core::MappedFile::map("password-is-sup.pdf"sv));
|
||||
auto document = MUST(PDF::Document::create(file->bytes()));
|
||||
EXPECT(document->security_handler()->try_provide_user_password("sup"sv));
|
||||
MUST(document->initialize());
|
||||
EXPECT_EQ(document->get_page_count(), 1U);
|
||||
}
|
||||
|
|
BIN
Tests/LibPDF/password-is-sup.pdf
Normal file
BIN
Tests/LibPDF/password-is-sup.pdf
Normal file
Binary file not shown.
Loading…
Reference in a new issue