mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibPDF: Add support for AESV2 encryption
This commit is contained in:
parent
67d8c8badb
commit
5998072f15
3 changed files with 163 additions and 20 deletions
|
@ -9,8 +9,18 @@
|
|||
#include <AK/Span.h>
|
||||
#include <LibPDF/ObjectDerivatives.h>
|
||||
|
||||
namespace Crypto::Cipher {
|
||||
enum class Intent;
|
||||
}
|
||||
|
||||
namespace PDF {
|
||||
|
||||
enum class CryptFilterMethod {
|
||||
None,
|
||||
V2, // RC4
|
||||
AESV2,
|
||||
};
|
||||
|
||||
class SecurityHandler : public RefCounted<SecurityHandler> {
|
||||
public:
|
||||
static PDFErrorOr<NonnullRefPtr<SecurityHandler>> create(Document*, NonnullRefPtr<DictObject> encryption_dict);
|
||||
|
@ -28,7 +38,7 @@ class StandardSecurityHandler : public SecurityHandler {
|
|||
public:
|
||||
static PDFErrorOr<NonnullRefPtr<StandardSecurityHandler>> create(Document*, NonnullRefPtr<DictObject> encryption_dict);
|
||||
|
||||
StandardSecurityHandler(Document*, size_t revision, DeprecatedString const& o_entry, DeprecatedString const& u_entry, u32 flags, bool encrypt_metadata, size_t length);
|
||||
StandardSecurityHandler(Document*, size_t revision, DeprecatedString const& o_entry, DeprecatedString const& u_entry, u32 flags, bool encrypt_metadata, size_t length, CryptFilterMethod method);
|
||||
|
||||
~StandardSecurityHandler() override = default;
|
||||
|
||||
|
@ -41,6 +51,8 @@ protected:
|
|||
void decrypt(NonnullRefPtr<Object>, Reference reference) const override;
|
||||
|
||||
private:
|
||||
void crypt(NonnullRefPtr<Object>, Reference reference, Crypto::Cipher::Intent) const;
|
||||
|
||||
ByteBuffer compute_user_password_value_v2(ByteBuffer password_string);
|
||||
ByteBuffer compute_user_password_value_v3_and_newer(ByteBuffer password_string);
|
||||
|
||||
|
@ -54,6 +66,7 @@ private:
|
|||
u32 m_flags;
|
||||
bool m_encrypt_metadata;
|
||||
size_t m_length;
|
||||
CryptFilterMethod m_method;
|
||||
};
|
||||
|
||||
class RC4 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue