Structure for custom security handler. More...
#include <fpdf_security_r.h>
Public Attributes | |
FS_LPVOID | clientData |
User-defined data. More... | |
FS_RESULT(* | CreateContext )(FS_LPVOID clientData, FSCRT_FILE file, const FSCRT_BSTR *filter, const FSCRT_BSTR *subFilter, const FSCRT_BSTR *encryptInfo, FS_LPVOID *context) |
Foxit PDF SDK calls this interface to initialize context handle of a custom handler. More... | |
FS_RESULT(* | ReleaseContext )(FS_LPVOID clientData, FS_LPVOID context) |
Foxit PDF SDK calls this interface to release context handle of a custom handler. More... | |
FS_RESULT(* | GetUserPermissions )(FS_LPVOID clientData, FS_LPVOID context, FS_DWORD userPermission, FS_DWORD *newPermission) |
Get permissions of user for context. More... | |
FS_RESULT(* | IsOwner )(FS_LPVOID clientData, FS_LPVOID context, FS_BOOL *isOwner) |
Get identity type: owner or user. More... | |
FS_RESULT(* | GetCipherInfo )(FS_LPVOID clientData, FS_LPVOID context, FS_INT32 *cipher, FS_LPVOID keyBuf, FS_DWORD *keyLen) |
Get cipher information including encryption algorithm and key. More... | |
FS_RESULT(* | GetDecryptedSize )(FS_LPVOID clientData, FS_LPVOID context, FS_DWORD dataSize, FS_DWORD *decryptedSize) |
Get the estimation size of decrypted data for a source data block. More... | |
FS_RESULT(* | StartDecryptor )(FS_LPVOID clientData, FS_LPVOID context, FS_INT32 objNum, FS_INT32 genNum, FS_LPVOID *decryptor) |
Start a decryptor context, for decrypting a data stream. More... | |
FS_RESULT(* | DecryptData )(FS_LPVOID clientData, FS_LPVOID decryptor, FS_LPCVOID encDataBuf, FS_DWORD encDataLen, FS_LPVOID decDataBuf, FS_DWORD *decDataLen) |
Decrypted data to the decryptor. More... | |
FS_RESULT(* | FinishDecryptor )(FS_LPVOID clientData, FS_LPVOID decryptor, FS_LPVOID decDataBuf, FS_DWORD *decDataLen) |
Release internal structure of the started decryptor context. More... | |
FS_RESULT(* | GetEncryptedSize )(FS_LPVOID clientData, FS_LPVOID context, FS_INT32 objNum, FS_INT32 genNum, FS_LPCVOID srcBuf, FS_DWORD srcLen, FS_DWORD *encryptedSize) |
Get the size of encrypted data for a source data block. More... | |
FS_RESULT(* | EncryptData )(FS_LPVOID clientData, FS_LPVOID context, FS_INT32 objNum, FS_INT32 genNum, FS_LPCVOID srcBuf, FS_DWORD srcLen, FS_LPVOID dstBuf, FS_DWORD *dstLen) |
Encrypt data. More... | |
Structure for custom security handler.
FS_LPVOID FSPDF_SECURITYHANDLER::clientData |
User-defined data.
FS_RESULT(* FSPDF_SECURITYHANDLER::CreateContext) (FS_LPVOID clientData, FSCRT_FILE file, const FSCRT_BSTR *filter, const FSCRT_BSTR *subFilter, const FSCRT_BSTR *encryptInfo, FS_LPVOID *context) |
Foxit PDF SDK calls this interface to initialize context handle of a custom handler.
[in] | clientData | Pointer to the user-supplied data. |
[in] | file | Handle to a FSCRT_FILE object. To open a PDF document and decrypt contents, it is the source file object. To write a PDF document and encrypt contents, it is the destination file object. |
[in] | filter | Pointer to a FSCRT_BSTR structure to specify filter value. |
[in] | subFilter | Pointer to a FSCRT_BSTR structure to specify sub filter value. |
[in] | encryptInfo | Pointer to a FSCRT_BSTR structure to specify encryption info data. For Microsoft RMS, this should be publish license, which is Encoded Publishing License issued from server to the Content publisher. |
[out] | context | A pointer specifies a context handle. Return NULL if fails. |
FS_RESULT(* FSPDF_SECURITYHANDLER::DecryptData) (FS_LPVOID clientData, FS_LPVOID decryptor, FS_LPCVOID encDataBuf, FS_DWORD encDataLen, FS_LPVOID decDataBuf, FS_DWORD *decDataLen) |
Decrypted data to the decryptor.
For each encrypted data buffer, Foxit PDF SDK will call this function twice: first time to get the length of the decrypted data buffer, and second time to obtain the decrypted buffer.
So implementation of this interface should be prepared to deal with this situation.
[in] | clientData | Pointer to the user-supplied data. |
[in] | decryptor | Pointer to internal structure of the started decryptor context. |
[in] | encDataBuf | Pointer to a source (encrypted) data. |
[in] | encDataLen | Length (number of bytes) of the source data. |
[out] | decDataBuf | Pointer to a buffer which contains decrypted data. If it is NULL, parameter decDataLen should not be NULL and will be used to receive the required length of decrypted data buffer. |
[in,out] | decDataLen | Pointer to a FS_DWORD object.that receives length (number of bytes) of the decrypted data, and it should not be NULL. |
FS_RESULT(* FSPDF_SECURITYHANDLER::EncryptData) (FS_LPVOID clientData, FS_LPVOID context, FS_INT32 objNum, FS_INT32 genNum, FS_LPCVOID srcBuf, FS_DWORD srcLen, FS_LPVOID dstBuf, FS_DWORD *dstLen) |
Encrypt data.
Final encrypted data block should be output in parameter dstBuf.
[in] | clientData | Pointer to the user-supplied data. |
[in] | context | Pointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext. |
[in] | objNum | PDF object number for the object being encrypted. |
[in] | genNum | PDF generation number for the object being encrypted. |
[in] | srcBuf | Pointer to a source data block. |
[in] | srcLen | The size in bytes of the source data. |
[out] | dstBuf | Pointer to a buffer that receives the encrypted data. It should not be a NULL pointer. It should be allocated according to the size returned by callback function FSPDF_SECURITYHANDLER::GetEncryptedSize. |
[in,out] | dstLen | Pointer to a FS_DWORD object that receives the size in bytes of the encrypted data. |
FS_RESULT(* FSPDF_SECURITYHANDLER::FinishDecryptor) (FS_LPVOID clientData, FS_LPVOID decryptor, FS_LPVOID decDataBuf, FS_DWORD *decDataLen) |
Release internal structure of the started decryptor context.
This callback function is used to release the inernal handler structure, used as parameter decryptor. If there is any left-over data, it should be returned in this callback function. For the left-over data, Foxit PDF SDK will call this function twice: first time to receive the required length of the left-over data buffer, and second time to receive the left-over data buffer.
So implementation of this interface should be prepared to deal with this situation.
[in] | clientData | Pointer to the user-supplied data. |
[in] | decryptor | Pointer to internal structure of the created filter. |
[out] | decDataBuf | Pointer to a buffer which contains decrypted data. |
[in,out] | decDataLen | Pointer to a FS_DWORD object that receives length (number of bytes) of the decrypted data in parameter decDataBuf. |
FS_RESULT(* FSPDF_SECURITYHANDLER::GetCipherInfo) (FS_LPVOID clientData, FS_LPVOID context, FS_INT32 *cipher, FS_LPVOID keyBuf, FS_DWORD *keyLen) |
Get cipher information including encryption algorithm and key.
Foxit PDF SDK will call the function twice: first time to get the length of the buffer, and second time to obtain the key content. So implementation of this interface should be prepared to deal with this situation.
[in] | clientData | Pointer to the user-supplied data. |
[in] | context | Pointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext. |
[out] | cipher | Pointer to an integer that receives cipher identifier. It would be one of the following macro definitions: |
[out] | keyBuf | Pointer to a buffer to receive encryption key. If it is NULL, parameter keyLen should not be NULL and will be used to receive the required length of key buffer. |
[in,out] | keyLen | Pointer to a FS_DWORD object that receives the length (number of bytes) of key buffer, and it should not be NULL. To FSCRT_CIPHER_RC4 cipher, this parameter is between 5 and 16. To FSCRT_CIPHER_AES cipher, this parameter can be 16 or 32. |
FS_RESULT(* FSPDF_SECURITYHANDLER::GetDecryptedSize) (FS_LPVOID clientData, FS_LPVOID context, FS_DWORD dataSize, FS_DWORD *decryptedSize) |
Get the estimation size of decrypted data for a source data block.
If application does not want to do the estimation, parameter decryptedSize can always be set to 0 when this function returns.
[in] | clientData | Pointer to the user-supplied data. |
[in] | context | Pointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext. |
[in] | dataSize | Size of source data which is an encrypted data block. |
[out] | decryptedSize | Estimation size of decrypted data. |
FS_RESULT(* FSPDF_SECURITYHANDLER::GetEncryptedSize) (FS_LPVOID clientData, FS_LPVOID context, FS_INT32 objNum, FS_INT32 genNum, FS_LPCVOID srcBuf, FS_DWORD srcLen, FS_DWORD *encryptedSize) |
Get the size of encrypted data for a source data block.
This callback function is always called before callback function FSPDF_SECURITYHANDLER::EncryptData is used.
[in] | clientData | Pointer to the user-supplied data. |
[in] | context | Pointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext. |
[in] | objNum | PDF object number for the object we are encrypting. |
[in] | genNum | PDF generation number for the object we are encrypting. |
[in] | srcBuf | Pointer to a source data block. |
[in] | srcLen | The size in bytes of the source data. |
[out] | encryptedSize | Size of encrypted data. It should be equal to or be larger than the final encrypted data block. |
FS_RESULT(* FSPDF_SECURITYHANDLER::GetUserPermissions) (FS_LPVOID clientData, FS_LPVOID context, FS_DWORD userPermission, FS_DWORD *newPermission) |
Get permissions of user for context.
[in] | clientData | Pointer to the user-supplied data. |
[in] | context | Pointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext. |
[in] | userPermission | Original permission settings of the document. Please refer to macro definitions FSPDF_PERMISSION_XXX and this should be one or a combination of these macros. |
[out] | newPermission | A combination of permission flags. Please refer to macro definitions FSPDF_PERMISSION_XXX and this would be one or a combination of these macros. |
FS_RESULT(* FSPDF_SECURITYHANDLER::IsOwner) (FS_LPVOID clientData, FS_LPVOID context, FS_BOOL *isOwner) |
Get identity type: owner or user.
[in] | clientData | Pointer to the user-supplied data. |
[in] | context | Pointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext. |
[out] | isOwner | TRUE if decryption of the current PDF document is done by the owner, or FALSE decryption is done by the user. |
FS_RESULT(* FSPDF_SECURITYHANDLER::ReleaseContext) (FS_LPVOID clientData, FS_LPVOID context) |
Foxit PDF SDK calls this interface to release context handle of a custom handler.
[in] | clientData | Pointer to the user-supplied data. |
[in] | context | Pointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext. |
FS_RESULT(* FSPDF_SECURITYHANDLER::StartDecryptor) (FS_LPVOID clientData, FS_LPVOID context, FS_INT32 objNum, FS_INT32 genNum, FS_LPVOID *decryptor) |
Start a decryptor context, for decrypting a data stream.
[in] | clientData | Pointer to the user-supplied data. |
[in] | context | Pointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext. |
[in] | objNum | PDF object number for the object we are decrypting. |
[in] | genNum | PDF version number for the object we are decrypting. |
[out] | decryptor | Implementation should return a pointer to internal structure of the started decryptor context. Return NULL for failure |