mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 06:04:57 +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
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…
Add table
Add a link
Reference in a new issue