| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "../fxcrt/fx_system.h" | 10 #include "../fxcrt/fx_system.h" |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 virtual FX_BOOL IsMetadataEncrypted() { return TRUE; } | 540 virtual FX_BOOL IsMetadataEncrypted() { return TRUE; } |
| 541 | 541 |
| 542 virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0; | 542 virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0; |
| 543 | 543 |
| 544 virtual CPDF_StandardSecurityHandler* GetStandardHandler() { return NULL; } | 544 virtual CPDF_StandardSecurityHandler* GetStandardHandler() { return NULL; } |
| 545 }; | 545 }; |
| 546 #define PDF_ENCRYPT_CONTENT 0 | 546 #define PDF_ENCRYPT_CONTENT 0 |
| 547 class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler { | 547 class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler { |
| 548 public: | 548 public: |
| 549 CPDF_StandardSecurityHandler(); | 549 CPDF_StandardSecurityHandler(); |
| 550 ~CPDF_StandardSecurityHandler() override; |
| 550 | 551 |
| 551 virtual ~CPDF_StandardSecurityHandler(); | 552 // CPDF_SecurityHandler |
| 552 virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict); | 553 FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) override; |
| 553 virtual FX_DWORD GetPermissions(); | 554 FX_DWORD GetPermissions() override; |
| 554 virtual FX_BOOL IsOwner() { return m_bOwner; } | 555 FX_BOOL IsOwner() override { return m_bOwner; } |
| 555 virtual FX_BOOL GetCryptInfo(int& cipher, | 556 FX_BOOL GetCryptInfo(int& cipher, |
| 556 const uint8_t*& buffer, | 557 const uint8_t*& buffer, |
| 557 int& keylen); | 558 int& keylen) override; |
| 558 virtual FX_BOOL IsMetadataEncrypted(); | 559 FX_BOOL IsMetadataEncrypted() override; |
| 559 virtual CPDF_CryptoHandler* CreateCryptoHandler(); | 560 CPDF_CryptoHandler* CreateCryptoHandler() override; |
| 560 virtual CPDF_StandardSecurityHandler* GetStandardHandler() { return this; } | 561 CPDF_StandardSecurityHandler* GetStandardHandler() override { return this; } |
| 561 | 562 |
| 562 void OnCreate(CPDF_Dictionary* pEncryptDict, | 563 void OnCreate(CPDF_Dictionary* pEncryptDict, |
| 563 CPDF_Array* pIdArray, | 564 CPDF_Array* pIdArray, |
| 564 const uint8_t* user_pass, | 565 const uint8_t* user_pass, |
| 565 FX_DWORD user_size, | 566 FX_DWORD user_size, |
| 566 const uint8_t* owner_pass, | 567 const uint8_t* owner_pass, |
| 567 FX_DWORD owner_size, | 568 FX_DWORD owner_size, |
| 568 FX_DWORD type = PDF_ENCRYPT_CONTENT); | 569 FX_DWORD type = PDF_ENCRYPT_CONTENT); |
| 569 | 570 |
| 570 void OnCreate(CPDF_Dictionary* pEncryptDict, | 571 void OnCreate(CPDF_Dictionary* pEncryptDict, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 const uint8_t* src_buf, | 677 const uint8_t* src_buf, |
| 677 FX_DWORD src_size, | 678 FX_DWORD src_size, |
| 678 uint8_t* dest_buf, | 679 uint8_t* dest_buf, |
| 679 FX_DWORD& dest_size) = 0; | 680 FX_DWORD& dest_size) = 0; |
| 680 | 681 |
| 681 void Decrypt(FX_DWORD objnum, FX_DWORD version, CFX_ByteString& str); | 682 void Decrypt(FX_DWORD objnum, FX_DWORD version, CFX_ByteString& str); |
| 682 }; | 683 }; |
| 683 class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler { | 684 class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler { |
| 684 public: | 685 public: |
| 685 CPDF_StandardCryptoHandler(); | 686 CPDF_StandardCryptoHandler(); |
| 687 ~CPDF_StandardCryptoHandler() override; |
| 686 | 688 |
| 687 virtual ~CPDF_StandardCryptoHandler(); | 689 // CPDF_CryptoHandler |
| 690 FX_BOOL Init(CPDF_Dictionary* pEncryptDict, |
| 691 CPDF_SecurityHandler* pSecurityHandler) override; |
| 692 FX_DWORD DecryptGetSize(FX_DWORD src_size) override; |
| 693 void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum) override; |
| 694 FX_BOOL DecryptStream(void* context, |
| 695 const uint8_t* src_buf, |
| 696 FX_DWORD src_size, |
| 697 CFX_BinaryBuf& dest_buf) override; |
| 698 FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) override; |
| 699 FX_DWORD EncryptGetSize(FX_DWORD objnum, |
| 700 FX_DWORD version, |
| 701 const uint8_t* src_buf, |
| 702 FX_DWORD src_size) override; |
| 703 FX_BOOL EncryptContent(FX_DWORD objnum, |
| 704 FX_DWORD version, |
| 705 const uint8_t* src_buf, |
| 706 FX_DWORD src_size, |
| 707 uint8_t* dest_buf, |
| 708 FX_DWORD& dest_size) override; |
| 688 | 709 |
| 689 FX_BOOL Init(int cipher, const uint8_t* key, int keylen); | 710 FX_BOOL Init(int cipher, const uint8_t* key, int keylen); |
| 690 virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, | |
| 691 CPDF_SecurityHandler* pSecurityHandler); | |
| 692 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size); | |
| 693 virtual void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum); | |
| 694 virtual FX_BOOL DecryptStream(void* context, | |
| 695 const uint8_t* src_buf, | |
| 696 FX_DWORD src_size, | |
| 697 CFX_BinaryBuf& dest_buf); | |
| 698 virtual FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf); | |
| 699 virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, | |
| 700 FX_DWORD version, | |
| 701 const uint8_t* src_buf, | |
| 702 FX_DWORD src_size); | |
| 703 virtual FX_BOOL EncryptContent(FX_DWORD objnum, | |
| 704 FX_DWORD version, | |
| 705 const uint8_t* src_buf, | |
| 706 FX_DWORD src_size, | |
| 707 uint8_t* dest_buf, | |
| 708 FX_DWORD& dest_size); | |
| 709 | 711 |
| 710 protected: | 712 protected: |
| 711 virtual void CryptBlock(FX_BOOL bEncrypt, | 713 virtual void CryptBlock(FX_BOOL bEncrypt, |
| 712 FX_DWORD objnum, | 714 FX_DWORD objnum, |
| 713 FX_DWORD gennum, | 715 FX_DWORD gennum, |
| 714 const uint8_t* src_buf, | 716 const uint8_t* src_buf, |
| 715 FX_DWORD src_size, | 717 FX_DWORD src_size, |
| 716 uint8_t* dest_buf, | 718 uint8_t* dest_buf, |
| 717 FX_DWORD& dest_size); | 719 FX_DWORD& dest_size); |
| 718 virtual void* CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt); | 720 virtual void* CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 PDF_DATAAVAIL_PAGE, | 905 PDF_DATAAVAIL_PAGE, |
| 904 PDF_DATAAVAIL_PAGE_LATERLOAD, | 906 PDF_DATAAVAIL_PAGE_LATERLOAD, |
| 905 PDF_DATAAVAIL_RESOURCES, | 907 PDF_DATAAVAIL_RESOURCES, |
| 906 PDF_DATAAVAIL_DONE, | 908 PDF_DATAAVAIL_DONE, |
| 907 PDF_DATAAVAIL_ERROR, | 909 PDF_DATAAVAIL_ERROR, |
| 908 PDF_DATAAVAIL_LOADALLFILE, | 910 PDF_DATAAVAIL_LOADALLFILE, |
| 909 PDF_DATAAVAIL_TRAILER_APPEND | 911 PDF_DATAAVAIL_TRAILER_APPEND |
| 910 }; | 912 }; |
| 911 | 913 |
| 912 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 914 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
| OLD | NEW |