Structure for custom security handler.
More...
#include <fpdf_security_r.h>
|
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) |
|
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.
- Note
- This structure holds a number of interfaces for customized security handlers.
Implementation of this interface is required to customize security handling. Function FSPDF_Security_RegisterHandler should be called to register this handler to the Foxit PDF SDK.
◆ clientData
User-defined data.
- Note
- Caller can use this field to track controls.
◆ CreateContext
@brief Foxit PDF SDK calls this interface to initialize context handle of a custom handler.
@param[in] clientData Pointer to the user-supplied data.
@param[in] file Handle to a <b>FSCRT_FILE</b> object.<br>
To open a PDF document and decrypt contents, it is the source file object.<br>
To write a PDF document and encrypt contents, it is the destination file object.
@param[in] filter Pointer to a ::FSCRT_BSTR structure to specify filter value.
@param[in] subFilter Pointer to a ::FSCRT_BSTR structure to specify sub filter value.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ DecryptData
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.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ EncryptData
Encrypt data.
Final encrypted data block should be output in parameter dstBuf.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ FinishDecryptor
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.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ GetCipherInfo
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.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
- Note
- If standard encryption and decryption is used, callback function FSPDF_SECURITYHANDLER::GetCipherInfo must be set.
◆ GetDecryptedSize
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.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ GetEncryptedSize
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.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ GetUserPermissions
Get permissions of user for context.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ IsOwner
Get identity type: owner or user.
- Parameters
-
[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. |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ ReleaseContext
Foxit PDF SDK calls this interface to release context handle of a custom handler.
- Parameters
-
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
◆ StartDecryptor
Start a decryptor context, for decrypting a data stream.
- Parameters
-
[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 |
- Returns
- FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
The documentation for this struct was generated from the following file: