summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp22
-rw-r--r--core/fpdfapi/fpdf_edit/include/cpdf_creator.h6
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp (renamed from core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp)113
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h67
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_parser.cpp12
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp (renamed from core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp)146
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_security_handler.h (renamed from core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h)38
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h64
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp6
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h6
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_parser.h8
-rw-r--r--core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h45
-rw-r--r--core/fpdfapi/fpdf_parser/ipdf_security_handler.h36
13 files changed, 241 insertions, 328 deletions
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index 0bd07a1819..7570a796e4 100644
--- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -9,8 +9,8 @@
#include <vector>
#include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h"
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h"
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
@@ -20,7 +20,6 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
#include "core/fxcrt/include/fx_ext.h"
#include "third_party/base/stl_util.h"
@@ -479,7 +478,7 @@ class CPDF_Encryptor {
public:
CPDF_Encryptor();
~CPDF_Encryptor();
- FX_BOOL Initialize(IPDF_CryptoHandler* pHandler,
+ FX_BOOL Initialize(CPDF_CryptoHandler* pHandler,
int objnum,
uint8_t* src_data,
uint32_t src_size);
@@ -492,7 +491,7 @@ CPDF_Encryptor::CPDF_Encryptor() {
m_dwSize = 0;
m_bNewBuf = FALSE;
}
-FX_BOOL CPDF_Encryptor::Initialize(IPDF_CryptoHandler* pHandler,
+FX_BOOL CPDF_Encryptor::Initialize(CPDF_CryptoHandler* pHandler,
int objnum,
uint8_t* src_data,
uint32_t src_size) {
@@ -549,7 +548,7 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) {
return 0;
}
CFX_FileBufferArchive* pFile = &pCreator->m_File;
- IPDF_CryptoHandler* pHandler = pCreator->m_pCryptoHandler;
+ CPDF_CryptoHandler* pHandler = pCreator->m_pCryptoHandler;
FX_FILESIZE ObjOffset = pCreator->m_Offset;
if (!m_dwObjNum) {
m_dwObjNum = ++pCreator->m_dwLastObjNum;
@@ -1025,7 +1024,7 @@ int32_t CPDF_Creator::AppendObjectNumberToXRef(uint32_t objnum) {
}
int32_t CPDF_Creator::WriteStream(const CPDF_Object* pStream,
uint32_t objnum,
- IPDF_CryptoHandler* pCrypto) {
+ CPDF_CryptoHandler* pCrypto) {
CPDF_FlateEncoder encoder;
encoder.Initialize(const_cast<CPDF_Stream*>(pStream->AsStream()),
pStream == m_pMetadata ? FALSE : m_bCompress);
@@ -1068,7 +1067,7 @@ int32_t CPDF_Creator::WriteIndirectObj(uint32_t objnum,
m_Offset += len;
if (pObj->IsStream()) {
- IPDF_CryptoHandler* pHandler = nullptr;
+ CPDF_CryptoHandler* pHandler = nullptr;
pHandler =
(pObj == m_pMetadata && !m_bEncryptMetadata) ? NULL : m_pCryptoHandler;
if (WriteStream(pObj, objnum, pHandler) < 0)
@@ -1148,7 +1147,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
encoder.Initialize(const_cast<CPDF_Stream*>(pObj->AsStream()),
m_bCompress);
CPDF_Encryptor encryptor;
- IPDF_CryptoHandler* pHandler = m_pCryptoHandler;
+ CPDF_CryptoHandler* pHandler = m_pCryptoHandler;
encryptor.Initialize(pHandler, objnum, encoder.m_pData, encoder.m_dwSize);
if ((uint32_t)encoder.m_pDict->GetIntegerBy("Length") !=
encryptor.m_dwSize) {
@@ -2008,15 +2007,16 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) {
m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone());
if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) {
if (m_pEncryptDict->GetStringBy("Filter") == "Standard") {
- CPDF_StandardSecurityHandler handler;
CFX_ByteString user_pass = m_pParser->GetPassword();
uint32_t flag = PDF_ENCRYPT_CONTENT;
+
+ CPDF_SecurityHandler handler;
handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(),
user_pass.GetLength(), flag);
if (m_bNewCrypto) {
delete m_pCryptoHandler;
}
- m_pCryptoHandler = new CPDF_StandardCryptoHandler;
+ m_pCryptoHandler = new CPDF_CryptoHandler;
m_pCryptoHandler->Init(m_pEncryptDict, &handler);
m_bNewCrypto = TRUE;
m_bSecurityChanged = TRUE;
diff --git a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h
index d6a1c1079a..e9490a3be7 100644
--- a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h
+++ b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h
@@ -10,12 +10,12 @@
#include "core/fxcrt/include/fx_basic.h"
class CPDF_Array;
+class CPDF_CryptoHandler;
class CPDF_Dictionary;
class CPDF_Document;
class CPDF_Object;
class CPDF_Parser;
class CPDF_XRefStream;
-class IPDF_CryptoHandler;
#define FPDFCREATE_INCREMENTAL 1
#define FPDFCREATE_NO_ORIGINAL 2
@@ -69,7 +69,7 @@ class CPDF_Creator {
int32_t WriteStream(const CPDF_Object* pStream,
uint32_t objnum,
- IPDF_CryptoHandler* pCrypto);
+ CPDF_CryptoHandler* pCrypto);
CPDF_Document* m_pDocument;
CPDF_Parser* m_pParser;
@@ -79,7 +79,7 @@ class CPDF_Creator {
uint32_t m_dwEnryptObjNum;
FX_BOOL m_bEncryptCloned;
FX_BOOL m_bStandardSecurity;
- IPDF_CryptoHandler* m_pCryptoHandler;
+ CPDF_CryptoHandler* m_pCryptoHandler;
FX_BOOL m_bNewCrypto;
FX_BOOL m_bEncryptMetadata;
CPDF_Object* m_pMetadata;
diff --git a/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp
index 6bfe1b60b3..2d845d856a 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp
@@ -4,34 +4,22 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
#include <time.h>
#include "core/fdrm/crypto/include/fx_crypt.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_security_handler.h"
-IPDF_CryptoHandler::~IPDF_CryptoHandler() {}
-
-void IPDF_CryptoHandler::Decrypt(uint32_t objnum,
- uint32_t gennum,
- CFX_ByteString& str) {
- CFX_BinaryBuf dest_buf;
- void* context = DecryptStart(objnum, gennum);
- DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf);
- DecryptFinish(context, dest_buf);
- str = CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize());
-}
-
-void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt,
- uint32_t objnum,
- uint32_t gennum,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) {
+void CPDF_CryptoHandler::CryptBlock(FX_BOOL bEncrypt,
+ uint32_t objnum,
+ uint32_t gennum,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size) {
if (m_Cipher == FXCIPHER_NONE) {
FXSYS_memcpy(dest_buf, src_buf, src_size);
return;
@@ -99,9 +87,9 @@ struct AESCryptContext {
uint32_t m_BlockOffset;
};
-void* CPDF_StandardCryptoHandler::CryptStart(uint32_t objnum,
- uint32_t gennum,
- FX_BOOL bEncrypt) {
+void* CPDF_CryptoHandler::CryptStart(uint32_t objnum,
+ uint32_t gennum,
+ FX_BOOL bEncrypt) {
if (m_Cipher == FXCIPHER_NONE) {
return this;
}
@@ -149,11 +137,11 @@ void* CPDF_StandardCryptoHandler::CryptStart(uint32_t objnum,
CRYPT_ArcFourSetup(pContext, realkey, realkeylen);
return pContext;
}
-FX_BOOL CPDF_StandardCryptoHandler::CryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt) {
+FX_BOOL CPDF_CryptoHandler::CryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf,
+ FX_BOOL bEncrypt) {
if (!context) {
return FALSE;
}
@@ -208,9 +196,9 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptStream(void* context,
}
return TRUE;
}
-FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(void* context,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt) {
+FX_BOOL CPDF_CryptoHandler::CryptFinish(void* context,
+ CFX_BinaryBuf& dest_buf,
+ FX_BOOL bEncrypt) {
if (!context) {
return FALSE;
}
@@ -244,17 +232,26 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(void* context,
FX_Free(pContext);
return TRUE;
}
-void* CPDF_StandardCryptoHandler::DecryptStart(uint32_t objnum,
- uint32_t gennum) {
+
+void CPDF_CryptoHandler::Decrypt(uint32_t objnum,
+ uint32_t gennum,
+ CFX_ByteString& str) {
+ CFX_BinaryBuf dest_buf;
+ void* context = DecryptStart(objnum, gennum);
+ DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf);
+ DecryptFinish(context, dest_buf);
+ str = CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize());
+}
+
+void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) {
return CryptStart(objnum, gennum, FALSE);
}
-uint32_t CPDF_StandardCryptoHandler::DecryptGetSize(uint32_t src_size) {
+uint32_t CPDF_CryptoHandler::DecryptGetSize(uint32_t src_size) {
return m_Cipher == FXCIPHER_AES ? src_size - 16 : src_size;
}
-FX_BOOL CPDF_StandardCryptoHandler::Init(
- CPDF_Dictionary* pEncryptDict,
- IPDF_SecurityHandler* pSecurityHandler) {
+FX_BOOL CPDF_CryptoHandler::Init(CPDF_Dictionary* pEncryptDict,
+ CPDF_SecurityHandler* pSecurityHandler) {
const uint8_t* key;
if (!pSecurityHandler->GetCryptInfo(m_Cipher, key, m_KeyLen)) {
return FALSE;
@@ -271,9 +268,7 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(
return TRUE;
}
-FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher,
- const uint8_t* key,
- int keylen) {
+FX_BOOL CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) {
if (cipher == FXCIPHER_AES) {
switch (keylen) {
case 16:
@@ -304,39 +299,39 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher,
}
return TRUE;
}
-FX_BOOL CPDF_StandardCryptoHandler::DecryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf) {
+FX_BOOL CPDF_CryptoHandler::DecryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf) {
return CryptStream(context, src_buf, src_size, dest_buf, FALSE);
}
-FX_BOOL CPDF_StandardCryptoHandler::DecryptFinish(void* context,
- CFX_BinaryBuf& dest_buf) {
+FX_BOOL CPDF_CryptoHandler::DecryptFinish(void* context,
+ CFX_BinaryBuf& dest_buf) {
return CryptFinish(context, dest_buf, FALSE);
}
-uint32_t CPDF_StandardCryptoHandler::EncryptGetSize(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size) {
+uint32_t CPDF_CryptoHandler::EncryptGetSize(uint32_t objnum,
+ uint32_t version,
+ const uint8_t* src_buf,
+ uint32_t src_size) {
if (m_Cipher == FXCIPHER_AES) {
return src_size + 32;
}
return src_size;
}
-FX_BOOL CPDF_StandardCryptoHandler::EncryptContent(uint32_t objnum,
- uint32_t gennum,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) {
+FX_BOOL CPDF_CryptoHandler::EncryptContent(uint32_t objnum,
+ uint32_t gennum,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size) {
CryptBlock(TRUE, objnum, gennum, src_buf, src_size, dest_buf, dest_size);
return TRUE;
}
-CPDF_StandardCryptoHandler::CPDF_StandardCryptoHandler() {
+CPDF_CryptoHandler::CPDF_CryptoHandler() {
m_pAESContext = NULL;
m_Cipher = FXCIPHER_NONE;
m_KeyLen = 0;
}
-CPDF_StandardCryptoHandler::~CPDF_StandardCryptoHandler() {
+CPDF_CryptoHandler::~CPDF_CryptoHandler() {
FX_Free(m_pAESContext);
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h b/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h
new file mode 100644
index 0000000000..3edc47b7b0
--- /dev/null
+++ b/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h
@@ -0,0 +1,67 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_CRYPTO_HANDLER_H_
+#define CORE_FPDFAPI_FPDF_PARSER_CPDF_CRYPTO_HANDLER_H_
+
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_Dictionary;
+class CPDF_SecurityHandler;
+
+class CPDF_CryptoHandler {
+ public:
+ CPDF_CryptoHandler();
+ ~CPDF_CryptoHandler();
+
+ FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
+ CPDF_SecurityHandler* pSecurityHandler);
+ uint32_t DecryptGetSize(uint32_t src_size);
+ void* DecryptStart(uint32_t objnum, uint32_t gennum);
+ void Decrypt(uint32_t objnum, uint32_t gennum, CFX_ByteString& str);
+ FX_BOOL DecryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf);
+ FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf);
+ uint32_t EncryptGetSize(uint32_t objnum,
+ uint32_t version,
+ const uint8_t* src_buf,
+ uint32_t src_size);
+ FX_BOOL EncryptContent(uint32_t objnum,
+ uint32_t version,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size);
+
+ FX_BOOL Init(int cipher, const uint8_t* key, int keylen);
+
+ protected:
+ void CryptBlock(FX_BOOL bEncrypt,
+ uint32_t objnum,
+ uint32_t gennum,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size);
+ void* CryptStart(uint32_t objnum, uint32_t gennum, FX_BOOL bEncrypt);
+ FX_BOOL CryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf,
+ FX_BOOL bEncrypt);
+ FX_BOOL CryptFinish(void* context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);
+
+ uint8_t m_EncryptKey[32];
+ int m_KeyLen;
+ int m_Cipher;
+ uint8_t* m_pAESContext;
+};
+
+#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_CRYPTO_HANDLER_H_
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
index 7fed6a380c..1ec912ebee 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
@@ -8,7 +8,8 @@
#include <vector>
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
#include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h"
#include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
@@ -18,7 +19,6 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
#include "core/fxcrt/include/fx_ext.h"
#include "core/fxcrt/include/fx_safe_types.h"
#include "third_party/base/stl_util.h"
@@ -101,7 +101,7 @@ void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) {
m_pEncryptDict = pDict;
}
-IPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() {
+CPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() {
return m_pSyntax->m_pCryptoHandler.get();
}
@@ -275,10 +275,10 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() {
if (m_pEncryptDict) {
CFX_ByteString filter = m_pEncryptDict->GetStringBy("Filter");
- std::unique_ptr<IPDF_SecurityHandler> pSecurityHandler;
+ std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler;
Error err = HANDLER_ERROR;
if (filter == "Standard") {
- pSecurityHandler.reset(new CPDF_StandardSecurityHandler);
+ pSecurityHandler.reset(new CPDF_SecurityHandler);
err = PASSWORD_ERROR;
}
if (!pSecurityHandler)
@@ -288,7 +288,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() {
return err;
m_pSecurityHandler = std::move(pSecurityHandler);
- std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler(
+ std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler(
m_pSecurityHandler->CreateCryptoHandler());
if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get()))
return HANDLER_ERROR;
diff --git a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
index 627ff5263f..38099e0328 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
@@ -4,12 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
#include <time.h>
#include "core/fdrm/crypto/include/fx_crypt.h"
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
@@ -67,9 +67,7 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt,
} // namespace
-IPDF_SecurityHandler::~IPDF_SecurityHandler() {}
-
-CPDF_StandardSecurityHandler::CPDF_StandardSecurityHandler() {
+CPDF_SecurityHandler::CPDF_SecurityHandler() {
m_Version = 0;
m_Revision = 0;
m_pParser = NULL;
@@ -79,14 +77,14 @@ CPDF_StandardSecurityHandler::CPDF_StandardSecurityHandler() {
m_KeyLen = 0;
}
-CPDF_StandardSecurityHandler::~CPDF_StandardSecurityHandler() {}
+CPDF_SecurityHandler::~CPDF_SecurityHandler() {}
-IPDF_CryptoHandler* CPDF_StandardSecurityHandler::CreateCryptoHandler() {
- return new CPDF_StandardCryptoHandler;
+CPDF_CryptoHandler* CPDF_SecurityHandler::CreateCryptoHandler() {
+ return new CPDF_CryptoHandler;
}
-FX_BOOL CPDF_StandardSecurityHandler::OnInit(CPDF_Parser* pParser,
- CPDF_Dictionary* pEncryptDict) {
+FX_BOOL CPDF_SecurityHandler::OnInit(CPDF_Parser* pParser,
+ CPDF_Dictionary* pEncryptDict) {
m_pParser = pParser;
if (!LoadDict(pEncryptDict)) {
return FALSE;
@@ -96,7 +94,7 @@ FX_BOOL CPDF_StandardSecurityHandler::OnInit(CPDF_Parser* pParser,
}
return CheckSecurity(m_KeyLen);
}
-FX_BOOL CPDF_StandardSecurityHandler::CheckSecurity(int32_t key_len) {
+FX_BOOL CPDF_SecurityHandler::CheckSecurity(int32_t key_len) {
CFX_ByteString password = m_pParser->GetPassword();
if (CheckPassword(password.raw_str(), password.GetLength(), TRUE,
m_EncryptKey, key_len)) {
@@ -111,7 +109,7 @@ FX_BOOL CPDF_StandardSecurityHandler::CheckSecurity(int32_t key_len) {
return CheckPassword(password.raw_str(), password.GetLength(), FALSE,
m_EncryptKey, key_len);
}
-uint32_t CPDF_StandardSecurityHandler::GetPermissions() {
+uint32_t CPDF_SecurityHandler::GetPermissions() {
return m_Permissions;
}
static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
@@ -160,7 +158,7 @@ static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
return TRUE;
}
-FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
+FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
m_pEncryptDict = pEncryptDict;
m_Version = pEncryptDict->GetIntegerBy("V");
m_Revision = pEncryptDict->GetIntegerBy("R");
@@ -180,10 +178,10 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
return TRUE;
}
-FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
- uint32_t type,
- int& cipher,
- int& key_len) {
+FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
+ uint32_t type,
+ int& cipher,
+ int& key_len) {
m_pEncryptDict = pEncryptDict;
m_Version = pEncryptDict->GetIntegerBy("V");
m_Revision = pEncryptDict->GetIntegerBy("R");
@@ -204,9 +202,9 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
return TRUE;
}
-FX_BOOL CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher,
- const uint8_t*& buffer,
- int& keylen) {
+FX_BOOL CPDF_SecurityHandler::GetCryptInfo(int& cipher,
+ const uint8_t*& buffer,
+ int& keylen) {
cipher = m_Cipher;
buffer = m_EncryptKey;
keylen = m_KeyLen;
@@ -305,11 +303,10 @@ void Revision6_Hash(const uint8_t* password,
FXSYS_memcpy(hash, input, 32);
}
}
-FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
- const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- uint8_t* key) {
+FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
+ uint32_t size,
+ FX_BOOL bOwner,
+ uint8_t* key) {
CFX_ByteString okey =
m_pEncryptDict ? m_pEncryptDict->GetStringBy("O") : CFX_ByteString();
if (okey.GetLength() < 48) {
@@ -394,11 +391,11 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
return TRUE;
}
-int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- uint8_t* key,
- int32_t key_len) {
+int CPDF_SecurityHandler::CheckPassword(const uint8_t* password,
+ uint32_t size,
+ FX_BOOL bOwner,
+ uint8_t* key,
+ int32_t key_len) {
if (m_Revision >= 5) {
return AES256_CheckPassword(password, size, bOwner, key);
}
@@ -412,12 +409,11 @@ int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password,
return CheckUserPassword(password, size, FALSE, key, key_len) ||
CheckUserPassword(password, size, TRUE, key, key_len);
}
-FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(
- const uint8_t* password,
- uint32_t pass_size,
- FX_BOOL bIgnoreEncryptMeta,
- uint8_t* key,
- int32_t key_len) {
+FX_BOOL CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password,
+ uint32_t pass_size,
+ FX_BOOL bIgnoreEncryptMeta,
+ uint8_t* key,
+ int32_t key_len) {
CalcEncryptKey(m_pEncryptDict, password, pass_size, key, key_len,
bIgnoreEncryptMeta, m_pParser->GetIDArray());
CFX_ByteString ukey =
@@ -460,10 +456,9 @@ FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(
}
return FALSE;
}
-CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(
- const uint8_t* owner_pass,
- uint32_t pass_size,
- int32_t key_len) {
+CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass,
+ uint32_t pass_size,
+ int32_t key_len) {
CFX_ByteString okey = m_pEncryptDict->GetStringBy("O");
uint8_t passcode[32];
uint32_t i;
@@ -509,11 +504,10 @@ CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(
}
return CFX_ByteString(okeybuf, len);
}
-FX_BOOL CPDF_StandardSecurityHandler::CheckOwnerPassword(
- const uint8_t* password,
- uint32_t pass_size,
- uint8_t* key,
- int32_t key_len) {
+FX_BOOL CPDF_SecurityHandler::CheckOwnerPassword(const uint8_t* password,
+ uint32_t pass_size,
+ uint8_t* key,
+ int32_t key_len) {
CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len);
if (CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), FALSE, key,
key_len)) {
@@ -522,18 +516,18 @@ FX_BOOL CPDF_StandardSecurityHandler::CheckOwnerPassword(
return CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), TRUE,
key, key_len);
}
-FX_BOOL CPDF_StandardSecurityHandler::IsMetadataEncrypted() {
+FX_BOOL CPDF_SecurityHandler::IsMetadataEncrypted() {
return m_pEncryptDict->GetBooleanBy("EncryptMetadata", TRUE);
}
-void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
- CPDF_Array* pIdArray,
- const uint8_t* user_pass,
- uint32_t user_size,
- const uint8_t* owner_pass,
- uint32_t owner_size,
- FX_BOOL bDefault,
- uint32_t type) {
+void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
+ CPDF_Array* pIdArray,
+ const uint8_t* user_pass,
+ uint32_t user_size,
+ const uint8_t* owner_pass,
+ uint32_t owner_size,
+ FX_BOOL bDefault,
+ uint32_t type) {
int cipher = 0, key_len = 0;
if (!LoadDict(pEncryptDict, type, cipher, key_len)) {
return;
@@ -620,29 +614,28 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
pEncryptDict->SetAtString("U", CFX_ByteString(digest, 32));
}
}
-void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
- CPDF_Array* pIdArray,
- const uint8_t* user_pass,
- uint32_t user_size,
- const uint8_t* owner_pass,
- uint32_t owner_size,
- uint32_t type) {
+void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
+ CPDF_Array* pIdArray,
+ const uint8_t* user_pass,
+ uint32_t user_size,
+ const uint8_t* owner_pass,
+ uint32_t owner_size,
+ uint32_t type) {
OnCreate(pEncryptDict, pIdArray, user_pass, user_size, owner_pass, owner_size,
TRUE, type);
}
-void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
- CPDF_Array* pIdArray,
- const uint8_t* user_pass,
- uint32_t user_size,
- uint32_t type) {
+void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
+ CPDF_Array* pIdArray,
+ const uint8_t* user_pass,
+ uint32_t user_size,
+ uint32_t type) {
OnCreate(pEncryptDict, pIdArray, user_pass, user_size, NULL, 0, FALSE, type);
}
-void CPDF_StandardSecurityHandler::AES256_SetPassword(
- CPDF_Dictionary* pEncryptDict,
- const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- const uint8_t* key) {
+void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
+ const uint8_t* password,
+ uint32_t size,
+ FX_BOOL bOwner,
+ const uint8_t* key) {
uint8_t sha[128];
CRYPT_SHA1Start(sha);
CRYPT_SHA1Update(sha, key, 32);
@@ -686,11 +679,10 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(
FX_Free(aes);
pEncryptDict->SetAtString(bOwner ? "OE" : "UE", CFX_ByteString(digest1, 32));
}
-void CPDF_StandardSecurityHandler::AES256_SetPerms(
- CPDF_Dictionary* pEncryptDict,
- uint32_t permissions,
- FX_BOOL bEncryptMetadata,
- const uint8_t* key) {
+void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict,
+ uint32_t permissions,
+ FX_BOOL bEncryptMetadata,
+ const uint8_t* key) {
uint8_t buf[16];
buf[0] = (uint8_t)permissions;
buf[1] = (uint8_t)(permissions >> 8);
diff --git a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h b/core/fpdfapi/fpdf_parser/cpdf_security_handler.h
index dfbf6a34f9..645c97698a 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h
+++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.h
@@ -4,30 +4,34 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_SECURITY_HANDLER_H_
-#define CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_SECURITY_HANDLER_H_
+#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_SECURITY_HANDLER_H_
+#define CORE_FPDFAPI_FPDF_PARSER_CPDF_SECURITY_HANDLER_H_
-#include "core/fpdfapi/fpdf_parser/ipdf_security_handler.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-class CPDF_Array;
+#define FXCIPHER_NONE 0
+#define FXCIPHER_RC4 1
+#define FXCIPHER_AES 2
+#define FXCIPHER_AES2 3
#define PDF_ENCRYPT_CONTENT 0
-class CPDF_StandardSecurityHandler : public IPDF_SecurityHandler {
+class CPDF_Array;
+class CPDF_CryptoHandler;
+class CPDF_Dictionary;
+class CPDF_Parser;
+
+class CPDF_SecurityHandler {
public:
- CPDF_StandardSecurityHandler();
- ~CPDF_StandardSecurityHandler() override;
-
- // IPDF_SecurityHandler:
- FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) override;
- uint32_t GetPermissions() override;
- FX_BOOL GetCryptInfo(int& cipher,
- const uint8_t*& buffer,
- int& keylen) override;
- FX_BOOL IsMetadataEncrypted() override;
- IPDF_CryptoHandler* CreateCryptoHandler() override;
+ CPDF_SecurityHandler();
+ ~CPDF_SecurityHandler();
+
+ FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict);
+ uint32_t GetPermissions();
+ FX_BOOL GetCryptInfo(int& cipher, const uint8_t*& buffer, int& keylen);
+ FX_BOOL IsMetadataEncrypted();
+ CPDF_CryptoHandler* CreateCryptoHandler();
void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray,
@@ -102,4 +106,4 @@ class CPDF_StandardSecurityHandler : public IPDF_SecurityHandler {
int m_KeyLen;
};
-#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_SECURITY_HANDLER_H_
+#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_SECURITY_HANDLER_H_
diff --git a/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h b/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h
deleted file mode 100644
index 689d44b81b..0000000000
--- a/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_CRYPTO_HANDLER_H_
-#define CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_CRYPTO_HANDLER_H_
-
-#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
-
-class CPDF_StandardCryptoHandler : public IPDF_CryptoHandler {
- public:
- CPDF_StandardCryptoHandler();
- ~CPDF_StandardCryptoHandler() override;
-
- // IPDF_CryptoHandler
- FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
- IPDF_SecurityHandler* pSecurityHandler) override;
- uint32_t DecryptGetSize(uint32_t src_size) override;
- void* DecryptStart(uint32_t objnum, uint32_t gennum) override;
- FX_BOOL DecryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf) override;
- FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) override;
- uint32_t EncryptGetSize(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size) override;
- FX_BOOL EncryptContent(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) override;
-
- FX_BOOL Init(int cipher, const uint8_t* key, int keylen);
-
- protected:
- virtual void CryptBlock(FX_BOOL bEncrypt,
- uint32_t objnum,
- uint32_t gennum,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size);
- virtual void* CryptStart(uint32_t objnum, uint32_t gennum, FX_BOOL bEncrypt);
- virtual FX_BOOL CryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt);
- virtual FX_BOOL CryptFinish(void* context,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt);
-
- uint8_t m_EncryptKey[32];
- int m_KeyLen;
- int m_Cipher;
- uint8_t* m_pAESContext;
-};
-
-#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_CRYPTO_HANDLER_H_
diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp
index 889b58e928..5e1c05b2a1 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp
@@ -9,6 +9,7 @@
#include <vector>
#include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
#include "core/fpdfapi/fpdf_parser/cpdf_null.h"
#include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
@@ -19,7 +20,6 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_ext.h"
#include "third_party/base/numerics/safe_math.h"
@@ -646,7 +646,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
const CFX_ByteStringC kEndStreamStr("endstream");
const CFX_ByteStringC kEndObjStr("endobj");
- IPDF_CryptoHandler* pCryptoHandler =
+ CPDF_CryptoHandler* pCryptoHandler =
objnum == (uint32_t)m_MetadataObjnum ? nullptr : m_pCryptoHandler.get();
if (!pCryptoHandler) {
FX_BOOL bSearchForKeyword = TRUE;
@@ -985,6 +985,6 @@ FX_FILESIZE CPDF_SyntaxParser::FindTag(const CFX_ByteStringC& tag,
}
void CPDF_SyntaxParser::SetEncrypt(
- std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler) {
+ std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) {
m_pCryptoHandler = std::move(pCryptoHandler);
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h
index 04fe6f4fec..63992a85ab 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h
+++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h
@@ -11,12 +11,12 @@
#include "core/fxcrt/include/fx_basic.h"
+class CPDF_CryptoHandler;
class CPDF_Dictionary;
class CPDF_IndirectObjectHolder;
class CPDF_Object;
class CPDF_Stream;
class IFX_FileRead;
-class IPDF_CryptoHandler;
class CPDF_SyntaxParser {
public:
@@ -49,7 +49,7 @@ class CPDF_SyntaxParser {
FX_FILESIZE limit);
FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit);
- void SetEncrypt(std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler);
+ void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler);
FX_BOOL ReadBlock(uint8_t* pBuf, uint32_t size);
FX_BOOL GetCharAt(FX_FILESIZE pos, uint8_t& ch);
@@ -88,7 +88,7 @@ class CPDF_SyntaxParser {
uint8_t* m_pFileBuf;
uint32_t m_BufSize;
FX_FILESIZE m_BufOffset;
- std::unique_ptr<IPDF_CryptoHandler> m_pCryptoHandler;
+ std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler;
uint8_t m_WordBuffer[257];
uint32_t m_WordSize;
};
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_parser.h b/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
index 45aca8f21a..5331ccafb1 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
@@ -14,15 +14,15 @@
#include "core/fxcrt/include/fx_basic.h"
class CPDF_Array;
+class CPDF_CryptoHandler;
class CPDF_Dictionary;
class CPDF_Document;
class CPDF_IndirectObjectHolder;
class CPDF_Object;
+class CPDF_SecurityHandler;
class CPDF_StreamAcc;
class CPDF_SyntaxParser;
class IFX_FileRead;
-class IPDF_CryptoHandler;
-class IPDF_SecurityHandler;
class CPDF_Parser {
public:
@@ -63,7 +63,7 @@ class CPDF_Parser {
bool IsVersionUpdated() const { return m_bVersionUpdated; }
bool IsObjectFreeOrNull(uint32_t objnum) const;
FX_BOOL IsFormStream(uint32_t objnum, FX_BOOL& bForm);
- IPDF_CryptoHandler* GetCryptoHandler();
+ CPDF_CryptoHandler* GetCryptoHandler();
IFX_FileRead* GetFileAccess() const;
FX_FILESIZE GetObjectOffset(uint32_t objnum) const;
@@ -123,7 +123,7 @@ class CPDF_Parser {
CPDF_Dictionary* m_pEncryptDict;
FX_FILESIZE m_LastXRefOffset;
FX_BOOL m_bXRefStream;
- std::unique_ptr<IPDF_SecurityHandler> m_pSecurityHandler;
+ std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler;
CFX_ByteString m_bsRecipient;
CFX_ByteString m_FilePath;
CFX_ByteString m_Password;
diff --git a/core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h b/core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h
deleted file mode 100644
index ea45a6b9cc..0000000000
--- a/core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PARSER_IPDF_CRYPTO_HANDLER_H_
-#define CORE_FPDFAPI_FPDF_PARSER_IPDF_CRYPTO_HANDLER_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CPDF_Dictionary;
-class IPDF_SecurityHandler;
-
-class IPDF_CryptoHandler {
- public:
- virtual ~IPDF_CryptoHandler();
-
- virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
- IPDF_SecurityHandler* pSecurityHandler) = 0;
-
- virtual uint32_t DecryptGetSize(uint32_t src_size) = 0;
- virtual void* DecryptStart(uint32_t objnum, uint32_t gennum) = 0;
- virtual FX_BOOL DecryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf) = 0;
-
- virtual FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) = 0;
- virtual uint32_t EncryptGetSize(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size) = 0;
-
- virtual FX_BOOL EncryptContent(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) = 0;
-
- void Decrypt(uint32_t objnum, uint32_t version, CFX_ByteString& str);
-};
-
-#endif // CORE_FPDFAPI_FPDF_PARSER_IPDF_CRYPTO_HANDLER_H_
diff --git a/core/fpdfapi/fpdf_parser/ipdf_security_handler.h b/core/fpdfapi/fpdf_parser/ipdf_security_handler.h
deleted file mode 100644
index e7eb822a83..0000000000
--- a/core/fpdfapi/fpdf_parser/ipdf_security_handler.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PARSER_IPDF_SECURITY_HANDLER_H_
-#define CORE_FPDFAPI_FPDF_PARSER_IPDF_SECURITY_HANDLER_H_
-
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_Parser;
-class CPDF_Dictionary;
-class IPDF_CryptoHandler;
-
-#define FXCIPHER_NONE 0
-#define FXCIPHER_RC4 1
-#define FXCIPHER_AES 2
-#define FXCIPHER_AES2 3
-
-class IPDF_SecurityHandler {
- public:
- virtual ~IPDF_SecurityHandler();
- virtual FX_BOOL OnInit(CPDF_Parser* pParser,
- CPDF_Dictionary* pEncryptDict) = 0;
-
- virtual uint32_t GetPermissions() = 0;
- virtual FX_BOOL GetCryptInfo(int& cipher,
- const uint8_t*& buffer,
- int& keylen) = 0;
-
- virtual FX_BOOL IsMetadataEncrypted() = 0;
- virtual IPDF_CryptoHandler* CreateCryptoHandler() = 0;
-};
-
-#endif // CORE_FPDFAPI_FPDF_PARSER_IPDF_SECURITY_HANDLER_H_