Go to the documentation of this file.
15 #ifndef FS_SECURITY_H_
16 #define FS_SECURITY_H_
32 class CustomSecurityCallback;
33 class RMSSecurityCallback;
63 typedef enum _CipherType {
77 #ifndef __EMSCRIPTEN_RENDER__
296 typedef enum _ModifyFlag {
487 #if (_FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_ || defined(SWIG) || defined(__EMSCRIPTEN__)) && !defined(_SWIG_JAVA_) && !defined(_SWIG_DOTNET_) && !defined(_SWIG_PYTHON_) && !defined(_OC_) && !defined(_SWIG_MACOC_) && !defined(_SWIG_NODEJS_) && !defined(_SWIG_GO_) && !defined(_FSDK_NO_OPENSSL_)
488 struct CertPermission;
490 class Envelope :
public Base {
498 Envelope(
const void* buffer,
size_t size);
504 Envelope(
const char* cert_file_path);
512 Envelope(
const char* certFilePath,
const CertPermission* permission);
524 Envelope(
const Envelope& other);
542 String GetDecryptionKey(
const char* p12_file_path,
const String& password);
545 enum PRINT_PERMISSION
552 enum CHANGE_PERMISSION
555 CHANGE_INSERTDELROTATE,
557 CHANGE_COMMENTSFORMFILL,
558 CHANGE_ANYEXCEPTEXTRACT
561 enum PROPERTITY_PERMISSION
563 PERMISSION_PRINTING = 0,
564 PERMISSION_CHANGEDOC,
565 PERMISSION_DOCASSEMBLY,
566 PERMISSION_CONTENTCOPY,
567 PERMISSION_CONTENTCOPYACCESS,
568 PERMISSION_PAGEEXTRACT,
575 struct CertPermission
580 bEnableTextAccess =
false;
581 printPer = PRINT_NONE;
582 changePer = CHANGE_NONE;
586 bool bEnableTextAccess;
588 PRINT_PERMISSION printPer;
589 CHANGE_PERMISSION changePer;
613 #if (_FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_ || defined(SWIG) || defined(__EMSCRIPTEN__)) && !defined(_SWIG_JAVA_) && !defined(_SWIG_DOTNET_) && !defined(_SWIG_PYTHON_) && !defined(_OC_) && !defined(_SWIG_MACOC_) && !defined(_SWIG_NODEJS_) && !defined(_SWIG_GO_) && !defined(_FSDK_NO_OPENSSL_)
627 #endif // (_FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_ || defined(SWIG)) && !defined(_SWIG_JAVA_) && !defined(_SWIG_DOTNET_) && !defined(_OC_) && !defined(_SWIG_MACOC_) && !defined(_SWIG_GO_)
1359 virtual bool IsOwner(
const PDFDoc& document,
const char* sub_filter) = 0;
1454 virtual void*
CreateContext(
const char* filter,
const char* sub_filter,
const char* encrypt_info) = 0;
1490 virtual bool IsOwner(
const void* context) = 0;
1538 virtual void*
StartDecryptor(
const void* context,
int obj_num,
int gen_num) = 0;
1578 const void* src_data,
uint32 src_data_len) = 0;
1595 virtual bool EncryptData(
const void* context,
int obj_num,
int gen_num,
1596 const void* src_data,
uint32 src_data_len,
1597 void* out_dst_buffer,
uint32* out_dst_buffer_len) = 0;
1644 #endif // FS_SECURITY_H_
virtual uint32 GetDecryptedSize(const void *context, uint32 src_data_size)=0
A callback function used to get the estimated decrypted data size.
SecurityHandler::CipherType cipher
Cipher type. Please refer to values starting from SecurityHandler::e_CipherRC4 and this should be one...
Definition: fs_security.h:270
bool IsEmpty() const
Check whether current object is empty or not.
virtual String FinishDecryptor(void *decryptor)=0
A callback function used to finish the decryption.
bool operator==(const SecurityHandler &other)
Equal operator.
RMSEncryptData(bool is_encrypt_metadata, const char *publish_license, const StringArray &server_eul_list, float irm_version=1.0)
Constructor, with parameters.
Definition: fs_security.h:1057
virtual void * CreateContext(const char *filter, const char *sub_filter, const char *encrypt_info)=0
A callback function used to create context for encryption and decryption.
String filter
The filter name of a custom security callback object. It should not be an empty string.
Definition: fs_security.h:981
virtual SecurityHandler::CipherType GetCipherType(const PDFDoc &document, const char *sub_filter)=0
A callback function used to get the cipher type for encryption algorithm.
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:213
bool operator==(const DRMEncryptData &other) const
Equal operator.
Definition: fs_security.h:724
CustomEncryptData(bool is_encrypt_metadata, const String &filter, const String &sub_filter)
Constructor, with parameters.
Definition: fs_security.h:900
virtual uint32 GetEncryptedSize(const void *context, int obj_num, int gen_num, const void *src_data, uint32 src_data_len)=0
A callback function used to get the estimated encrypted size.
RMSSecurityHandler()
Constructor.
virtual PDFDoc::EncryptType GetSecurityType()
Get the encryption type of security callback.
Definition: fs_security.h:1442
If set, user password and owner password will be modified during encryption process.
Definition: fs_security.h:300
DRMSecurityHandler()
Constructor function.
Definition: fs_security.h:1628
CertificateEncryptData(const CertificateEncryptData &other)
Constructor, with another certificate encrypt data object.
Definition: fs_security.h:393
bool operator==(const CertificateEncryptData &other) const
Equal operator.
Definition: fs_security.h:420
Definition: fs_basictypes.h:229
virtual PDFDoc::EncryptType GetSecurityType()
Get the encryption type of current security callback.
Definition: fs_security.h:1314
size_t GetSize() const
Get the size of elements in current array.
CustomEncryptData(const CustomEncryptData &other)
Constructor, with another custom encrypt data object.
Definition: fs_security.h:917
Definition: fs_security.h:365
CertificateSecurityHandler()
Constructor.
bool is_encrypt_metadata
A boolean value to decide whether to encrypt metadata or not. true means to encrypt metadata,...
Definition: fs_security.h:260
virtual String GetInitialKey(const PDFDoc &document, const char *sub_filter)=0
A callback function used to get the initial key to decrypt the DRM protected document.
virtual void * StartDecryptor(const void *context, int obj_num, int gen_num)=0
A callback function used to start a decryption.
String sub_filter
The sub filter name that specifies the syntax of the encryption dictionary contents....
Definition: fs_security.h:983
CustomEncryptData & operator=(const CustomEncryptData &other)
Assign operator.
Definition: fs_security.h:929
bool Initialize(const StdEncryptData &encrypt_data, const String &user_password, const String &owner_password)
(Not support AES-256) Initialize current standard security handler.
bool operator!=(const SecurityHandler &other)
Not equal operator.
bool is_owner
A boolean value to decide whether current user is owner or not. true means current user is owner,...
Definition: fs_security.h:801
Header file for common definitions and classes.
bool operator!=(const DRMEncryptData &other) const
Not equal operator.
Definition: fs_security.h:739
virtual String GetDecryptionKey(const void *envelope_buffer, uint32 envelope_length)=0
A callback function used to get the key for decrypting certificate protected PDF document.
Definition: fx_basic.h:1297
virtual String DecryptData(const void *decryptor, const void *encrypted_data, uint32 encrypted_data_len)=0
A callback function used to decrypt the encrypted data.
File reading interface.
Definition: fx_stream.h:587
Use RC4 encryption algorithm, with the key length between 5 bytes and 16 bytes.
Definition: fs_security.h:67
bool SetDRMValue(const char *key, const WString &value)
Set the DRM value for a specified parameter.
Definition: fs_security.h:1027
Definition: fs_security.h:1433
virtual PDFDoc::EncryptType GetSecurityType()
Get the encryption type of current security handler.
virtual PDFDoc::EncryptType GetSecurityType()
Get the encryption type of security callback.
Definition: fs_security.h:1291
StdEncryptData & operator=(const StdEncryptData &other)
Assign operator.
Definition: fs_security.h:192
Encryption type: Foxit DRM encryption.
Definition: fs_pdfdoc.h:809
Definition: fs_security.h:991
virtual PDFDoc::EncryptType GetSecurityType()
Get the encryption type of security callback.
Definition: fs_security.h:1637
void Set(bool is_encrypt_metadata, uint32 user_permissions, SecurityHandler::CipherType cipher, int key_length)
Set value.
Definition: fs_security.h:249
virtual bool IsOwner(const void *context)=0
A callback function used to check if current user is the owner of the PDF document.
Definition: fs_security.h:602
SecurityHandler()
Constructor.
CustomSecurityHandler()
Constructor.
void Set(bool is_encrypt_metadata, const String &sub_filter, SecurityHandler::CipherType cipher, int key_length, bool is_owner, uint32 user_permissions)
Set value.
Definition: fs_security.h:768
String publish_license
The Encoded Publishing License issued from server to the Content publisher, in ASCII encoding....
Definition: fs_security.h:1198
ModifyFlag
(Only for AES-256) Enumeration for modify flag used to decide which security data or password will be...
Definition: fs_security.h:296
CipherType
Enumeration for Encryption Algorithm.
Definition: fs_security.h:63
virtual bool EncryptData(const void *context, int obj_num, int gen_num, const void *src_data, uint32 src_data_len, void *out_dst_buffer, uint32 *out_dst_buffer_len)=0
A callback function used to get encrypted data.
void Set(bool is_encrypt_metadata, const String &filter, const String &sub_filter)
Set value.
Definition: fs_security.h:969
Definition: fs_security.h:890
If set, user permissions and "is encrypt metadata" values (which are defined in StdEncryptData) will ...
Definition: fs_security.h:298
DRMEncryptData(bool is_encrypt_metadata, const String &sub_filter, SecurityHandler::CipherType cipher, int key_length, bool is_owner, uint32 user_permissions)
Constructor, with parameters.
Definition: fs_security.h:667
virtual uint32 GetUserPermissions(const PDFDoc &document, const char *sub_filter)=0
A callback function used to get the current user permissions.
Definition: fs_security.h:1277
Definition: fs_security.h:1305
RMSEncryptData(const RMSEncryptData &other)
Constructor, with another RMS encrypt data object.
Definition: fs_security.h:1079
BYTE STRING CLASS.
Definition: fx_string.h:317
bool is_encrypt_metadata
A boolean value to decide whether to encrypt metadata or not. true means to encrypt metadata,...
Definition: fs_security.h:474
StdEncryptData(bool is_encrypt_metadata, uint32 user_permissions, SecurityHandler::CipherType cipher, int key_length)
Constructor, with parameters.
Definition: fs_security.h:158
virtual PDFDoc::EncryptType GetSecurityType()
Get the encryption type of security callback.
Definition: fs_security.h:1348
RMSEncryptData & operator=(const RMSEncryptData &other)
Assign operator.
Definition: fs_security.h:1093
Encryption type: Microsoft RMS encryption.
Definition: fs_pdfdoc.h:813
bool Initialize(const CustomEncryptData &encrypt_data, const CustomSecurityCallback *callback, const char *encrypt_info="")
Initialize current custom security handler.
int key_length
The key length, in bytes.
Definition: fs_security.h:280
DRMEncryptData()
Constructor.
Definition: fs_security.h:678
Unknown encryption type.
Definition: fs_pdfdoc.h:801
virtual ~SecurityHandler()
Destructor.
CertificateEncryptData(bool is_encrypt_metadata, SecurityHandler::CipherType cipher, const StringArray &envelopes)
Constructor, with parameters.
Definition: fs_security.h:377
SecurityHandler::CipherType cipher
Cipher type. Please refer to values starting from SecurityHandler::e_CipherRC4 and this should be one...
Definition: fs_security.h:479
bool Initialize(const DRMEncryptData &encrypt_data, const char *file_id, const String &initial_key)
Initialize current DRM security handler.
Definition: fs_security.h:137
DRMEncryptData & operator=(const DRMEncryptData &other)
Assign operator.
Definition: fs_security.h:707
StdEncryptData()
Constructor.
Definition: fs_security.h:167
Definition: fs_security.h:288
bool operator==(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are equal.
Definition: fs_basictypes.h:128
virtual void Release()=0
A callback function used to release current callback object itself.
virtual uint32 GetKeyLength(const PDFDoc &document, const char *sub_filter)=0
A callback function used to get the length of cipher key.
StringArray server_eul_list
A string array that contains pairs of strings to represent content of a dictionary object which is en...
Definition: fs_security.h:1212
float irm_version
Microsoft IRM version. It should be above 1. If input version is below 1, Foxit PDF SDK will use 1 as...
Definition: fs_security.h:1217
EncryptType
Enumeration for encryption type.
Definition: fs_pdfdoc.h:799
virtual bool IsOwner(const PDFDoc &document, const char *sub_filter)=0
A callback function used to check if current user is the owner of the PDF document.
bool operator!=(const CustomEncryptData &other) const
Not equal operator.
Definition: fs_security.h:955
bool Initialize(const CertificateEncryptData &encrypt_data, const String &encrypt_key)
Initialize current certificate security handler.
Foxit namespace.
Definition: fs_taggedpdf.h:27
Definition: fs_security.h:56
bool VerifyEncryptionParams()
Verify encryption parameters.
void Set(bool is_encrypt_metadata, SecurityHandler::CipherType cipher, const StringArray &envelopes)
Set value.
Definition: fs_security.h:464
DRMEncryptData(const DRMEncryptData &other)
Constructor, with another DRM encrypt data object.
Definition: fs_security.h:691
StringArray envelopes
A string array which specifies an array of certificate envelopes. This array should contains one or m...
Definition: fs_security.h:484
Definition: fs_security.h:1230
StdEncryptData(const StdEncryptData &other)
Constructor, with another standard encrypt data object.
Definition: fs_security.h:178
WString GetDRMValue(const char *key)
Get the DRM value for a specified parameter.
virtual SecurityHandler::CipherType GetCipher(const void *context)=0
A callback function used to get the cipher type.
Encryption type: digital certificate encryption.
Definition: fs_pdfdoc.h:807
bool operator!=(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are not equal.
Definition: fs_basictypes.h:140
CertificateEncryptData()
Constructor.
Definition: fs_security.h:384
Header file for PDF document related definitions and classes.
If set, only owner password will be modified during encryption process.
Definition: fs_security.h:302
virtual uint32 GetUserPermissions(const void *context, uint32 user_permission)=0
A callback function used to get the user permissions.
virtual bool ReleaseContext(void *context)=0
A callback function used to release the context for encryption and decryption.
CustomEncryptData()
Constructor.
Definition: fs_security.h:907
Definition: fs_pdfdoc.h:776
virtual String GetEncryptKey(const void *context)=0
A callback function used to get the encryption key.
bool is_encrypt_metadata
A boolean value to decide whether to encrypt metadata or not. true means to encrypt metadata,...
Definition: fs_security.h:979
Not use encryption algorithm.
Definition: fs_security.h:65
bool operator==(const CustomEncryptData &other) const
Equal operator.
Definition: fs_security.h:943
bool is_encrypt_metadata
A boolean value to decide whether to encrypt metadata or not. true means to encrypt metadata,...
Definition: fs_security.h:1187
uint32 user_permissions
The user permissions. Please refer to values starting from PDFDoc::e_PermPrint and this can be one or...
Definition: fs_security.h:806
SecurityHandler & operator=(const SecurityHandler &other)
Assign operator.
bool Initialize(const RMSEncryptData &encrypt_data, const RMSSecurityCallback *callback)
Initialize current Microsoft RMS security handler.
Definition: fs_security.h:646
bool operator!=(const RMSEncryptData &other) const
Not equal operator.
Definition: fs_security.h:1128
virtual bool UseStandardCryptoMethod(const void *context)
A callback function to check if to use standard crypto method or custom crypto method.
Definition: fs_security.h:1614
bool operator==(const StdEncryptData &other) const
Equal operator.
Definition: fs_security.h:207
Use AES encryption algorithm, with the key length be 16 bytes (as AES-128) or 32 bytes (as AES-256,...
Definition: fs_security.h:72
Encryption type: customized encryption.
Definition: fs_pdfdoc.h:811
virtual String GetFileID(const PDFDoc &document, const char *sub_filter)=0
A callback function used to get the file identity string.
bool is_encrypt_metadata
A boolean value to decide whether to encrypt metadata or not. true means to encrypt metadata,...
Definition: fs_security.h:782
bool operator!=(const CertificateEncryptData &other) const
Not equal operator.
Definition: fs_security.h:439
StdSecurityHandler()
Constructor.
WIDE STRING CLASS.
Definition: fx_string.h:1461
void SetAES256ModifyFlags(uint32 modify_flags)
(Only for AES-256) Set modify flags to decide which security data or password will be modified during...
Definition: fs_security.h:814
String sub_filter
The sub filter name that specifies the syntax of the encryption dictionary contents.
Definition: fs_security.h:784
RMSEncryptData()
Constructor.
Definition: fs_security.h:1069
int key_length
The key length, in bytes. For SecurityHandler::e_CipherRC4 cipher, this value should be between 5 an...
Definition: fs_security.h:796
Definition: fs_security.h:1339
bool operator!=(const StdEncryptData &other) const
Not equal operator.
Definition: fs_security.h:221
void Set(bool is_encrypt_metadata, const char *publish_license, const StringArray &server_eul_list, float irm_version=1.0)
Set value.
Definition: fs_security.h:1172
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:195
bool InitializeW(const StdEncryptData &encrypt_data, const WString &user_password, const WString &owner_password)
(Only for AES-256) Initialize current standard security handler.
CertificateEncryptData & operator=(const CertificateEncryptData &other)
Assign operator.
Definition: fs_security.h:406
Definition: fs_basictypes.h:451
bool operator==(const RMSEncryptData &other) const
Equal operator.
Definition: fs_security.h:1108
uint32 user_permissions
The user permissions. Please refer to values starting from PDFDoc::e_PermPrint and this should be one...
Definition: fs_security.h:265
SecurityHandler::CipherType cipher
Cipher type. Please refer to values starting from SecurityHandler::e_CipherRC4 and this should be one...
Definition: fs_security.h:789
@2026 Foxit Software Incorporated. All rights reserved.