FSPDF_SECURITYHANDLER Struct Reference

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...
 

Detailed Description

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.

Member Data Documentation

FS_LPVOID FSPDF_SECURITYHANDLER::clientData

User-defined data.

Note
Caller can use this field to track controls.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]fileHandle 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]filterPointer to a FSCRT_BSTR structure to specify filter value.
[in]subFilterPointer to a FSCRT_BSTR structure to specify sub filter value.
[in]encryptInfoPointer 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]contextA 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.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]decryptorPointer to internal structure of the started decryptor context.
[in]encDataBufPointer to a source (encrypted) data.
[in]encDataLenLength (number of bytes) of the source data.
[out]decDataBufPointer 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]decDataLenPointer 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.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]contextPointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext.
[in]objNumPDF object number for the object being encrypted.
[in]genNumPDF generation number for the object being encrypted.
[in]srcBufPointer to a source data block.
[in]srcLenThe size in bytes of the source data.
[out]dstBufPointer 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]dstLenPointer 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.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]decryptorPointer to internal structure of the created filter.
[out]decDataBufPointer to a buffer which contains decrypted data.
[in,out]decDataLenPointer 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.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]contextPointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext.
[out]cipherPointer to an integer that receives cipher identifier. It would be one of the following macro definitions:
[out]keyBufPointer 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]keyLenPointer 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.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]contextPointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext.
[in]dataSizeSize of source data which is an encrypted data block.
[out]decryptedSizeEstimation size of decrypted data.
Returns
FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]contextPointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext.
[in]objNumPDF object number for the object we are encrypting.
[in]genNumPDF generation number for the object we are encrypting.
[in]srcBufPointer to a source data block.
[in]srcLenThe size in bytes of the source data.
[out]encryptedSizeSize 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.
FS_RESULT(* FSPDF_SECURITYHANDLER::GetUserPermissions) (FS_LPVOID clientData, FS_LPVOID context, FS_DWORD userPermission, FS_DWORD *newPermission)

Get permissions of user for context.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]contextPointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext.
[in]userPermissionOriginal 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]newPermissionA 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.
FS_RESULT(* FSPDF_SECURITYHANDLER::IsOwner) (FS_LPVOID clientData, FS_LPVOID context, FS_BOOL *isOwner)

Get identity type: owner or user.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]contextPointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext.
[out]isOwnerTRUE 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.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]contextPointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext.
Returns
FSCRT_ERRCODE_SUCCESS for success.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
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.

Parameters
[in]clientDataPointer to the user-supplied data.
[in]contextPointer to context handle which is created by callback function FSPDF_SECURITYHANDLER::CreateContext.
[in]objNumPDF object number for the object we are decrypting.
[in]genNumPDF version number for the object we are decrypting.
[out]decryptorImplementation 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:

Foxit Corporation