From b7fe3c6e8c9d332fc6d3ca55ec9f852ce162c5a1 Mon Sep 17 00:00:00 2001 From: Artem Strygin Date: Tue, 3 Oct 2017 19:10:04 +0300 Subject: Move the CryptoHandler into the SecurityHandler Change-Id: Idb5928e65833641d0443d955e4f2866d0f94cf5f Reviewed-on: https://pdfium-review.googlesource.com/15291 Commit-Queue: Art Snake Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_parser.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'core/fpdfapi/parser/cpdf_parser.cpp') diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 17f49c6324..a1b8a2deba 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -155,10 +155,6 @@ void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) { m_pEncryptDict = pDict; } -CPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() const { - return m_pCryptoHandler.get(); -} - RetainPtr CPDF_Parser::GetFileAccess() const { return m_pSyntax->GetFileAccess(); } @@ -315,17 +311,15 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() { m_Password)) return PASSWORD_ERROR; - m_pSecurityHandler = std::move(pSecurityHandler); - auto pCryptoHandler = pdfium::MakeUnique(); - if (!pCryptoHandler->Init(m_pEncryptDict.Get(), m_pSecurityHandler.get())) + if (!pSecurityHandler->InitCryptoHandler()) return HANDLER_ERROR; - m_pCryptoHandler = std::move(pCryptoHandler); + + m_pSecurityHandler = std::move(pSecurityHandler); } return SUCCESS; } void CPDF_Parser::ReleaseEncryptHandler() { - m_pCryptoHandler.reset(); m_pSecurityHandler.reset(); SetEncryptDictionary(nullptr); } @@ -1276,9 +1270,12 @@ std::unique_ptr CPDF_Parser::ParseIndirectObjectAtInternal( if (result && objnum && result->GetObjNum() != objnum) return nullptr; - const bool should_decrypt = m_pCryptoHandler && objnum != m_MetadataObjnum; + const bool should_decrypt = m_pSecurityHandler && + m_pSecurityHandler->GetCryptoHandler() && + objnum != m_MetadataObjnum; if (should_decrypt) - result = m_pCryptoHandler->DecryptObjectTree(std::move(result)); + result = m_pSecurityHandler->GetCryptoHandler()->DecryptObjectTree( + std::move(result)); return result; } -- cgit v1.2.3