From d8169d7607b5084cdeceee3eaffca0ab16d2c14d Mon Sep 17 00:00:00 2001 From: Artem Strygin Date: Mon, 2 Oct 2017 19:19:28 +0300 Subject: Implement CPDF_CryptoHandler::DecryptObject Decryption logic has been extracted from CPDF_SyntaxParser::GetObjectBody into CPDF_CryptoHandler::DecryptObject Performance comparison results: https://pdfium-review.googlesource.com/c/pdfium/+/12970 Change-Id: Iaeaed56b7f96166bbbcf6db162192d2ba9af4698 Reviewed-on: https://pdfium-review.googlesource.com/12971 Commit-Queue: Art Snake Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_crypto_handler.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'core/fpdfapi/parser/cpdf_crypto_handler.h') diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h index d815e786f6..60f32b70ba 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.h +++ b/core/fpdfapi/parser/cpdf_crypto_handler.h @@ -17,6 +17,7 @@ #include "core/fxcrt/retain_ptr.h" class CPDF_Dictionary; +class CPDF_Object; class CPDF_SecurityHandler; class CPDF_CryptoHandler : public Retainable { @@ -24,16 +25,14 @@ class CPDF_CryptoHandler : public Retainable { template friend RetainPtr pdfium::MakeRetain(Args&&... args); + static bool IsSignatureDictionary(const CPDF_Dictionary* dictionary); + bool Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler); - uint32_t DecryptGetSize(uint32_t src_size); - void* DecryptStart(uint32_t objnum, uint32_t gennum); - ByteString Decrypt(uint32_t objnum, uint32_t gennum, const ByteString& str); - bool DecryptStream(void* context, - const uint8_t* src_buf, - uint32_t src_size, - CFX_BinaryBuf& dest_buf); - bool DecryptFinish(void* context, CFX_BinaryBuf& dest_buf); + + std::unique_ptr DecryptObjectTree( + std::unique_ptr object); + uint32_t EncryptGetSize(uint32_t objnum, uint32_t version, const uint8_t* src_buf, @@ -52,6 +51,15 @@ class CPDF_CryptoHandler : public Retainable { CPDF_CryptoHandler(); ~CPDF_CryptoHandler() override; + uint32_t DecryptGetSize(uint32_t src_size); + void* DecryptStart(uint32_t objnum, uint32_t gennum); + ByteString Decrypt(uint32_t objnum, uint32_t gennum, const ByteString& str); + bool DecryptStream(void* context, + const uint8_t* src_buf, + uint32_t src_size, + CFX_BinaryBuf& dest_buf); + bool DecryptFinish(void* context, CFX_BinaryBuf& dest_buf); + void PopulateKey(uint32_t objnum, uint32_t gennum, uint8_t* key); void CryptBlock(bool bEncrypt, uint32_t objnum, -- cgit v1.2.3