From e0b592236db902e3e8cbca7ec64f8e2b192e1935 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 12 Apr 2017 16:50:51 -0700 Subject: Refcount CPDF_CryptoHandler Avoid tracking ownership via m_bLocalCryptoHandler. Also remove m_bEncryptCloned, as it is always false. Replace some methods with direct calls to underlying code. Change-Id: Ifa9d6f721c59d07e3b8e258f76832ca9f2ea0fc9 Reviewed-on: https://pdfium-review.googlesource.com/4111 Reviewed-by: Lei Zhang Commit-Queue: Lei Zhang --- core/fpdfapi/parser/cpdf_crypto_handler.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 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 1e3890a55b..24caff7081 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.h +++ b/core/fpdfapi/parser/cpdf_crypto_handler.h @@ -7,6 +7,7 @@ #ifndef CORE_FPDFAPI_PARSER_CPDF_CRYPTO_HANDLER_H_ #define CORE_FPDFAPI_PARSER_CPDF_CRYPTO_HANDLER_H_ +#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" @@ -14,10 +15,10 @@ class CPDF_Dictionary; class CPDF_SecurityHandler; -class CPDF_CryptoHandler { +class CPDF_CryptoHandler : public CFX_Retainable { public: - CPDF_CryptoHandler(); - ~CPDF_CryptoHandler(); + template + friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); bool Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler); @@ -44,7 +45,11 @@ class CPDF_CryptoHandler { bool Init(int cipher, const uint8_t* key, int keylen); - protected: + private: + CPDF_CryptoHandler(); + ~CPDF_CryptoHandler() override; + + void PopulateKey(uint32_t objnum, uint32_t gennum, uint8_t* key); void CryptBlock(bool bEncrypt, uint32_t objnum, uint32_t gennum, @@ -64,9 +69,6 @@ class CPDF_CryptoHandler { int m_KeyLen; int m_Cipher; uint8_t* m_pAESContext; - - private: - void PopulateKey(uint32_t objnum, uint32_t gennum, uint8_t* key); }; #endif // CORE_FPDFAPI_PARSER_CPDF_CRYPTO_HANDLER_H_ -- cgit v1.2.3