CryptSignMessage function (wincrypt.h)
The CryptSignMessage function creates a hash of the specified content, signs the hash, and then encodes both the original message content and the signed hash.
Syntax
BOOL CryptSignMessage(
[in] PCRYPT_SIGN_MESSAGE_PARA pSignPara,
[in] BOOL fDetachedSignature,
[in] DWORD cToBeSigned,
[in] const BYTE * [] rgpbToBeSigned,
[in] DWORD [] rgcbToBeSigned,
[out] BYTE *pbSignedBlob,
[in, out] DWORD *pcbSignedBlob
);
Parameters
[in] pSignPara
A pointer to CRYPT_SIGN_MESSAGE_PARA structure containing the signature parameters.
[in] fDetachedSignature
TRUE if this is to be a detached signature. Otherwise, FALSE. If this parameter is set to TRUE, only the signed hash is encoded in pbSignedBlob. Otherwise, both rgpbToBeSigned and the signed hash are encoded.
[in] cToBeSigned
Count of the number of array elements in rgpbToBeSigned and rgcbToBeSigned. This parameter must be set to one unless fDetachedSignature is set to TRUE.
[in] rgpbToBeSigned
Array of pointers to buffers that contain the contents to be signed.
[in] rgcbToBeSigned
Array of sizes, in bytes, of the content buffers pointed to in rgpbToBeSigned.
[out] pbSignedBlob
A pointer to a buffer to receive the encoded signed hash, if fDetachedSignature is TRUE, or to both the encoded content and signed hash if fDetachedSignature is FALSE.
This parameter can be NULL to set the size of this information for memory allocation purposes. For more information, see Retrieving Data of Unknown Length.
[in, out] pcbSignedBlob
A pointer to a DWORD specifying the size, in bytes, of the pbSignedBlob buffer. When the function returns, this variable contains the size, in bytes, of the signed and encoded message.
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.
The following lists the error codes most commonly returned by the GetLastError function.
Return code | Description |
---|---|
|
If the buffer specified by the pbSignedBlob parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code, and stores the required buffer size, in bytes, into the variable pointed to by pcbSignedBlob. |
|
The message encoding type is not valid. Currently only PKCS_7_ASN_ENCODING is supported. The cbSize in *pSignPara is not valid. |
|
The pSigningCert in *pSignPara does not have a CERT_KEY_PROV_INFO_PROP_ID or CERT_KEY_CONTEXT_PROP_ID property. |
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 |
Library | Crypt32.lib |
DLL | Crypt32.dll |