mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibPDF: Implement StandardSecurityHandler::crypt for AESV3
With this, AESV3 support is complete and CIPA_DC-007-2021_E.pdf can be opened :^) (CIPA_DC-003-2020_E.pdf incorrectly cannot be opened yet. This is due to a minor bug in computing_a_hash_r6_and_later() that I'll fix a bit later. But except for this minor bug, all AESV3 files I've found so far seem to work.)
This commit is contained in:
parent
12e77cba0a
commit
f26783596d
1 changed files with 13 additions and 12 deletions
|
@ -663,18 +663,6 @@ void StandardSecurityHandler::crypt(NonnullRefPtr<Object> object, Reference refe
|
|||
}
|
||||
};
|
||||
|
||||
if (m_method == CryptFilterMethod::AESV3) {
|
||||
// ISO 32000 (PDF 2.0), 7.6.3.3 Algorithm 1.A: Encryption of data using the AES algorithms
|
||||
|
||||
// a) Use the 32-byte file encryption key for the AES-256 symmetric key algorithm, along with the string or
|
||||
// stream data to be encrypted.
|
||||
//
|
||||
// Use the AES algorithm in Cipher Block Chaining (CBC) mode, which requires an initialization
|
||||
// vector. The block size parameter is set to 16 bytes, and the initialization vector is a 16-byte random
|
||||
// number that is stored as the first 16 bytes of the encrypted stream or string.
|
||||
TODO();
|
||||
}
|
||||
|
||||
ReadonlyBytes bytes;
|
||||
Function<void(ByteBuffer)> assign;
|
||||
|
||||
|
@ -701,6 +689,19 @@ void StandardSecurityHandler::crypt(NonnullRefPtr<Object> object, Reference refe
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (m_method == CryptFilterMethod::AESV3) {
|
||||
// ISO 32000 (PDF 2.0), 7.6.3.3 Algorithm 1.A: Encryption of data using the AES algorithms
|
||||
|
||||
// a) Use the 32-byte file encryption key for the AES-256 symmetric key algorithm, along with the string or
|
||||
// stream data to be encrypted.
|
||||
//
|
||||
// Use the AES algorithm in Cipher Block Chaining (CBC) mode, which requires an initialization
|
||||
// vector. The block size parameter is set to 16 bytes, and the initialization vector is a 16-byte random
|
||||
// number that is stored as the first 16 bytes of the encrypted stream or string.
|
||||
assign(aes(bytes, m_encryption_key.value()));
|
||||
return;
|
||||
}
|
||||
|
||||
// 7.6.2 General Encryption Algorithm
|
||||
// Algorithm 1: Encryption of data using the RC3 or AES algorithms
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue