PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY callback function (wincrypt.h)
The PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY callback function generates the symmetric key used to encrypt content for an enveloped message. This function is called by the CryptMsgOpenToEncode function when it initializes the CMSG_CONTENT_ENCRYPT_INFO structure.
Syntax
PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY PfnCmsgGenContentEncryptKey;
BOOL PfnCmsgGenContentEncryptKey(
[in, out] PCMSG_CONTENT_ENCRYPT_INFO pContentEncryptInfo,
[in] DWORD dwFlags,
void *pvReserved
)
{...}
Parameters
[in, out] pContentEncryptInfo
A pointer to a CMSG_CONTENT_ENCRYPT_INFO structure that contains the key.
[in] dwFlags
This value is not used. Set it to zero.
pvReserved
This parameter is reserved and must be NULL.
Return value
If the function succeeds, the return value is nonzero (TRUE).
If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError.
Remarks
You can use OID Support Functions to deploy this callback function. Wincrypt.h defines the following constants for this purpose.
You must define different callback functions for CAPI1 keys and Cryptography API: Next Generation (CNG) keys. Both functions have the same signature but use different object identifiers (OIDs). Which function is called depends on the value of the fCNG member of the CMSG_CONTENT_ENCRYPT_INFO structure pointed to by the pContentEncryptInfo parameter. The following table shows the relationship between the callback function and the value of the fCNG member.
fCNG value | Constant | Definition |
---|---|---|
FALSE | CMSG_OID_GEN_CONTENT_ENCRYPT_KEY_FUNC or CMSG_OID_CAPI1_GEN_CONTENT_ENCRYPT_KEY_FUNC | "CryptMsgDllGenContentEncryptKey" |
TRUE | CMSG_OID_CNG_GEN_CONTENT_ENCRYPT_KEY_FUNC | "CryptMsgDllCNGGenContentEncryptKey" |
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps only] |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | wincrypt.h |