summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
Diffstat (limited to 'core/include')
-rw-r--r--core/include/fpdfapi/cpdf_parser.h4
-rw-r--r--core/include/fpdfapi/fpdf_parser.h86
-rw-r--r--core/include/fpdfapi/fpdf_serial.h4
-rw-r--r--core/include/fpdfapi/ipdf_crypto_handler.h45
-rw-r--r--core/include/fpdfapi/ipdf_security_handler.h4
5 files changed, 52 insertions, 91 deletions
diff --git a/core/include/fpdfapi/cpdf_parser.h b/core/include/fpdfapi/cpdf_parser.h
index 80a1107743..4ec8d988e0 100644
--- a/core/include/fpdfapi/cpdf_parser.h
+++ b/core/include/fpdfapi/cpdf_parser.h
@@ -14,7 +14,6 @@
#include "core/include/fxcrt/fx_basic.h"
class CPDF_Array;
-class CPDF_CryptoHandler;
class CPDF_Dictionary;
class CPDF_Document;
class CPDF_IndirectObjectHolder;
@@ -22,6 +21,7 @@ class CPDF_Object;
class CPDF_StreamAcc;
class CPDF_SyntaxParser;
class IFX_FileRead;
+class IPDF_CryptoHandler;
class IPDF_SecurityHandler;
class CPDF_Parser {
@@ -63,7 +63,7 @@ class CPDF_Parser {
bool IsVersionUpdated() const { return m_bVersionUpdated; }
bool IsObjectFreeOrNull(FX_DWORD objnum) const;
FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm);
- CPDF_CryptoHandler* GetCryptoHandler();
+ IPDF_CryptoHandler* GetCryptoHandler();
IFX_FileRead* GetFileAccess() const;
FX_FILESIZE GetObjectOffset(FX_DWORD objnum) const;
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index 705587c513..9504061fcf 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -17,7 +17,7 @@
class CFX_Font;
class CFX_Matrix;
class CPDF_ColorSpace;
-class CPDF_CryptoHandler;
+class IPDF_CryptoHandler;
class CPDF_Document;
class CPDF_DocPageData;
class CPDF_DocRenderData;
@@ -45,90 +45,6 @@ class IPDF_SecurityHandler;
// Indexed by 8-bit char code, contains unicode code points.
extern const FX_WORD PDFDocEncoding[256];
-class CPDF_CryptoHandler {
- public:
- virtual ~CPDF_CryptoHandler() {}
-
- virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
- IPDF_SecurityHandler* pSecurityHandler) = 0;
-
- virtual FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0;
-
- virtual void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0;
-
- virtual FX_BOOL DecryptStream(void* context,
- const uint8_t* src_buf,
- FX_DWORD src_size,
- CFX_BinaryBuf& dest_buf) = 0;
-
- virtual FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) = 0;
-
- virtual FX_DWORD EncryptGetSize(FX_DWORD objnum,
- FX_DWORD version,
- const uint8_t* src_buf,
- FX_DWORD src_size) = 0;
-
- virtual FX_BOOL EncryptContent(FX_DWORD objnum,
- FX_DWORD version,
- const uint8_t* src_buf,
- FX_DWORD src_size,
- uint8_t* dest_buf,
- FX_DWORD& dest_size) = 0;
-
- void Decrypt(FX_DWORD objnum, FX_DWORD version, CFX_ByteString& str);
-};
-
-class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler {
- public:
- CPDF_StandardCryptoHandler();
- ~CPDF_StandardCryptoHandler() override;
-
- // CPDF_CryptoHandler
- FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
- IPDF_SecurityHandler* pSecurityHandler) override;
- FX_DWORD DecryptGetSize(FX_DWORD src_size) override;
- void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum) override;
- FX_BOOL DecryptStream(void* context,
- const uint8_t* src_buf,
- FX_DWORD src_size,
- CFX_BinaryBuf& dest_buf) override;
- FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) override;
- FX_DWORD EncryptGetSize(FX_DWORD objnum,
- FX_DWORD version,
- const uint8_t* src_buf,
- FX_DWORD src_size) override;
- FX_BOOL EncryptContent(FX_DWORD objnum,
- FX_DWORD version,
- const uint8_t* src_buf,
- FX_DWORD src_size,
- uint8_t* dest_buf,
- FX_DWORD& dest_size) override;
-
- FX_BOOL Init(int cipher, const uint8_t* key, int keylen);
-
- protected:
- virtual void CryptBlock(FX_BOOL bEncrypt,
- FX_DWORD objnum,
- FX_DWORD gennum,
- const uint8_t* src_buf,
- FX_DWORD src_size,
- uint8_t* dest_buf,
- FX_DWORD& dest_size);
- virtual void* CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt);
- virtual FX_BOOL CryptStream(void* context,
- const uint8_t* src_buf,
- FX_DWORD 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;
-};
CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig);
CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig);
diff --git a/core/include/fpdfapi/fpdf_serial.h b/core/include/fpdfapi/fpdf_serial.h
index ccbea36404..6ed3756803 100644
--- a/core/include/fpdfapi/fpdf_serial.h
+++ b/core/include/fpdfapi/fpdf_serial.h
@@ -44,7 +44,7 @@ class CPDF_Creator {
FX_BOOL m_bStandardSecurity;
- CPDF_CryptoHandler* m_pCryptoHandler;
+ IPDF_CryptoHandler* m_pCryptoHandler;
FX_BOOL m_bNewCrypto;
FX_BOOL m_bEncryptMetadata;
@@ -86,7 +86,7 @@ class CPDF_Creator {
void InitID(FX_BOOL bDefault = TRUE);
int32_t WriteStream(const CPDF_Object* pStream,
FX_DWORD objnum,
- CPDF_CryptoHandler* pCrypto);
+ IPDF_CryptoHandler* pCrypto);
int32_t m_iStage;
FX_DWORD m_dwFlags;
diff --git a/core/include/fpdfapi/ipdf_crypto_handler.h b/core/include/fpdfapi/ipdf_crypto_handler.h
new file mode 100644
index 0000000000..6a09a02278
--- /dev/null
+++ b/core/include/fpdfapi/ipdf_crypto_handler.h
@@ -0,0 +1,45 @@
+// 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_INCLUDE_FPDFAPI_IPDF_CRYPTO_HANDLER_H_
+#define CORE_INCLUDE_FPDFAPI_IPDF_CRYPTO_HANDLER_H_
+
+#include "core/include/fxcrt/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 FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0;
+ virtual void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0;
+ virtual FX_BOOL DecryptStream(void* context,
+ const uint8_t* src_buf,
+ FX_DWORD src_size,
+ CFX_BinaryBuf& dest_buf) = 0;
+
+ virtual FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) = 0;
+ virtual FX_DWORD EncryptGetSize(FX_DWORD objnum,
+ FX_DWORD version,
+ const uint8_t* src_buf,
+ FX_DWORD src_size) = 0;
+
+ virtual FX_BOOL EncryptContent(FX_DWORD objnum,
+ FX_DWORD version,
+ const uint8_t* src_buf,
+ FX_DWORD src_size,
+ uint8_t* dest_buf,
+ FX_DWORD& dest_size) = 0;
+
+ void Decrypt(FX_DWORD objnum, FX_DWORD version, CFX_ByteString& str);
+};
+
+#endif // CORE_INCLUDE_FPDFAPI_IPDF_CRYPTO_HANDLER_H_
diff --git a/core/include/fpdfapi/ipdf_security_handler.h b/core/include/fpdfapi/ipdf_security_handler.h
index 699cf38c3a..4dce7c6963 100644
--- a/core/include/fpdfapi/ipdf_security_handler.h
+++ b/core/include/fpdfapi/ipdf_security_handler.h
@@ -11,7 +11,7 @@
class CPDF_Parser;
class CPDF_Dictionary;
-class CPDF_CryptoHandler;
+class IPDF_CryptoHandler;
#define FXCIPHER_NONE 0
#define FXCIPHER_RC4 1
@@ -30,7 +30,7 @@ class IPDF_SecurityHandler {
int& keylen) = 0;
virtual FX_BOOL IsMetadataEncrypted() = 0;
- virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0;
+ virtual IPDF_CryptoHandler* CreateCryptoHandler() = 0;
};
#endif // CORE_INCLUDE_FPDFAPI_IPDF_SECURITY_HANDLER_H_