| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
| 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 | 13 |
| 14 #include "core/include/fpdfapi/fpdf_objects.h" | 14 #include "core/include/fpdfapi/fpdf_objects.h" |
| 15 #include "core/include/fxcrt/fx_basic.h" | 15 #include "core/include/fxcrt/fx_basic.h" |
| 16 | 16 |
| 17 class CFX_Font; | 17 class CFX_Font; |
| 18 class CFX_Matrix; | 18 class CFX_Matrix; |
| 19 class CPDF_ColorSpace; | 19 class CPDF_ColorSpace; |
| 20 class CPDF_CryptoHandler; | 20 class IPDF_CryptoHandler; |
| 21 class CPDF_Document; | 21 class CPDF_Document; |
| 22 class CPDF_DocPageData; | 22 class CPDF_DocPageData; |
| 23 class CPDF_DocRenderData; | 23 class CPDF_DocRenderData; |
| 24 class CPDF_Font; | 24 class CPDF_Font; |
| 25 class CPDF_FontEncoding; | 25 class CPDF_FontEncoding; |
| 26 class CPDF_IccProfile; | 26 class CPDF_IccProfile; |
| 27 class CPDF_Image; | 27 class CPDF_Image; |
| 28 class CPDF_Object; | 28 class CPDF_Object; |
| 29 class CPDF_Parser; | 29 class CPDF_Parser; |
| 30 class CPDF_Pattern; | 30 class CPDF_Pattern; |
| 31 class CPDF_StandardSecurityHandler; | 31 class CPDF_StandardSecurityHandler; |
| 32 class CPDF_SyntaxParser; | 32 class CPDF_SyntaxParser; |
| 33 class IPDF_SecurityHandler; | 33 class IPDF_SecurityHandler; |
| 34 | 34 |
| 35 #define FPDFPERM_PRINT 0x0004 | 35 #define FPDFPERM_PRINT 0x0004 |
| 36 #define FPDFPERM_MODIFY 0x0008 | 36 #define FPDFPERM_MODIFY 0x0008 |
| 37 #define FPDFPERM_EXTRACT 0x0010 | 37 #define FPDFPERM_EXTRACT 0x0010 |
| 38 #define FPDFPERM_ANNOT_FORM 0x0020 | 38 #define FPDFPERM_ANNOT_FORM 0x0020 |
| 39 #define FPDFPERM_FILL_FORM 0x0100 | 39 #define FPDFPERM_FILL_FORM 0x0100 |
| 40 #define FPDFPERM_EXTRACT_ACCESS 0x0200 | 40 #define FPDFPERM_EXTRACT_ACCESS 0x0200 |
| 41 #define FPDFPERM_ASSEMBLE 0x0400 | 41 #define FPDFPERM_ASSEMBLE 0x0400 |
| 42 #define FPDFPERM_PRINT_HIGH 0x0800 | 42 #define FPDFPERM_PRINT_HIGH 0x0800 |
| 43 #define FPDF_PAGE_MAX_NUM 0xFFFFF | 43 #define FPDF_PAGE_MAX_NUM 0xFFFFF |
| 44 | 44 |
| 45 // Indexed by 8-bit char code, contains unicode code points. | 45 // Indexed by 8-bit char code, contains unicode code points. |
| 46 extern const FX_WORD PDFDocEncoding[256]; | 46 extern const FX_WORD PDFDocEncoding[256]; |
| 47 | 47 |
| 48 class CPDF_CryptoHandler { | |
| 49 public: | |
| 50 virtual ~CPDF_CryptoHandler() {} | |
| 51 | |
| 52 virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, | |
| 53 IPDF_SecurityHandler* pSecurityHandler) = 0; | |
| 54 | |
| 55 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0; | |
| 56 | |
| 57 virtual void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0; | |
| 58 | |
| 59 virtual FX_BOOL DecryptStream(void* context, | |
| 60 const uint8_t* src_buf, | |
| 61 FX_DWORD src_size, | |
| 62 CFX_BinaryBuf& dest_buf) = 0; | |
| 63 | |
| 64 virtual FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) = 0; | |
| 65 | |
| 66 virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, | |
| 67 FX_DWORD version, | |
| 68 const uint8_t* src_buf, | |
| 69 FX_DWORD src_size) = 0; | |
| 70 | |
| 71 virtual FX_BOOL EncryptContent(FX_DWORD objnum, | |
| 72 FX_DWORD version, | |
| 73 const uint8_t* src_buf, | |
| 74 FX_DWORD src_size, | |
| 75 uint8_t* dest_buf, | |
| 76 FX_DWORD& dest_size) = 0; | |
| 77 | |
| 78 void Decrypt(FX_DWORD objnum, FX_DWORD version, CFX_ByteString& str); | |
| 79 }; | |
| 80 | |
| 81 class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler { | |
| 82 public: | |
| 83 CPDF_StandardCryptoHandler(); | |
| 84 ~CPDF_StandardCryptoHandler() override; | |
| 85 | |
| 86 // CPDF_CryptoHandler | |
| 87 FX_BOOL Init(CPDF_Dictionary* pEncryptDict, | |
| 88 IPDF_SecurityHandler* pSecurityHandler) override; | |
| 89 FX_DWORD DecryptGetSize(FX_DWORD src_size) override; | |
| 90 void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum) override; | |
| 91 FX_BOOL DecryptStream(void* context, | |
| 92 const uint8_t* src_buf, | |
| 93 FX_DWORD src_size, | |
| 94 CFX_BinaryBuf& dest_buf) override; | |
| 95 FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) override; | |
| 96 FX_DWORD EncryptGetSize(FX_DWORD objnum, | |
| 97 FX_DWORD version, | |
| 98 const uint8_t* src_buf, | |
| 99 FX_DWORD src_size) override; | |
| 100 FX_BOOL EncryptContent(FX_DWORD objnum, | |
| 101 FX_DWORD version, | |
| 102 const uint8_t* src_buf, | |
| 103 FX_DWORD src_size, | |
| 104 uint8_t* dest_buf, | |
| 105 FX_DWORD& dest_size) override; | |
| 106 | |
| 107 FX_BOOL Init(int cipher, const uint8_t* key, int keylen); | |
| 108 | |
| 109 protected: | |
| 110 virtual void CryptBlock(FX_BOOL bEncrypt, | |
| 111 FX_DWORD objnum, | |
| 112 FX_DWORD gennum, | |
| 113 const uint8_t* src_buf, | |
| 114 FX_DWORD src_size, | |
| 115 uint8_t* dest_buf, | |
| 116 FX_DWORD& dest_size); | |
| 117 virtual void* CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt); | |
| 118 virtual FX_BOOL CryptStream(void* context, | |
| 119 const uint8_t* src_buf, | |
| 120 FX_DWORD src_size, | |
| 121 CFX_BinaryBuf& dest_buf, | |
| 122 FX_BOOL bEncrypt); | |
| 123 virtual FX_BOOL CryptFinish(void* context, | |
| 124 CFX_BinaryBuf& dest_buf, | |
| 125 FX_BOOL bEncrypt); | |
| 126 | |
| 127 uint8_t m_EncryptKey[32]; | |
| 128 int m_KeyLen; | |
| 129 int m_Cipher; | |
| 130 uint8_t* m_pAESContext; | |
| 131 }; | |
| 132 | 48 |
| 133 CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig); | 49 CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig); |
| 134 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); | 50 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); |
| 135 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); | 51 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); |
| 136 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, | 52 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, |
| 137 FX_BOOL bHex = FALSE); | 53 FX_BOOL bHex = FALSE); |
| 138 CFX_WideString PDF_DecodeText(const uint8_t* pData, FX_DWORD size); | 54 CFX_WideString PDF_DecodeText(const uint8_t* pData, FX_DWORD size); |
| 139 CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr); | 55 CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr); |
| 140 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1); | 56 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1); |
| 141 CFX_ByteString PDF_EncodeText(const CFX_WideString& str); | 57 CFX_ByteString PDF_EncodeText(const CFX_WideString& str); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 FX_DWORD src_size, | 226 FX_DWORD src_size, |
| 311 const CPDF_Dictionary* pDict, | 227 const CPDF_Dictionary* pDict, |
| 312 uint8_t*& dest_buf, | 228 uint8_t*& dest_buf, |
| 313 FX_DWORD& dest_size, | 229 FX_DWORD& dest_size, |
| 314 CFX_ByteString& ImageEncoding, | 230 CFX_ByteString& ImageEncoding, |
| 315 CPDF_Dictionary*& pImageParms, | 231 CPDF_Dictionary*& pImageParms, |
| 316 FX_DWORD estimated_size, | 232 FX_DWORD estimated_size, |
| 317 FX_BOOL bImageAcc); | 233 FX_BOOL bImageAcc); |
| 318 | 234 |
| 319 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 235 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
| OLD | NEW |