The CryptMsgGetParam function gets a parameter after encoding/decoding a cryptographic message. This function is called after the final CryptMsgUpdate. For an encoded message, only the CMSG_CONTENT_PARAM and CMSG_COMPUTED_HASH_PARAM are valid.
#include <wincrypt.h>
BOOL WINAPI CryptMsgGetParam(
HCRYPTMSG hCryptMsg, // in
DWORD dwParamType, // in
DWORD dwIndex, // in
void *pvData, // out
DWORD *pcbData // in/out
);
Applicable only to encode.
pvData points to the buffer receiving the encoded bytes.
Applicable only to decode.
pvData points to a DWORD, which receives the count.
To get all the Certificates, repetitively call CryptMsgGetParam, while varying dwIndex from 0 to (CertCount - 1), where CertCount is the value obtained from a previous call to CryptMsgGetParam with dwParamType set to CMSG_CERT_COUNT_PARAM.
Applicable only to decode.
pvData points to an array of the certificate's encoded bytes.
Applicable for a HASHED message.
For HASHED, this parameter may be used for either encoding or decoding a message.
Applicable to both encode and decode.
pvData points to an array of bytes.
When a message has been opened to decode, this parameter is used to retrieve the inner content. If the message is enveloped and the inner type is data, the decrypted content is returned if you have already called CryptMsgControl to decrypt it. If the inner type is not data, the encoded blob is returned, which requires further decoding. If the message is not enveloped, and if the inner content is of type DATA, the returned data is the contents octets of the inner content.
Applicable to both encode and decode.
For encode, pvData points to the buffer receiving the encoded bytes.
For decode, pvData points to the buffer receiving the inner content. If the type is CMSG_DATA, the contents octets are returned. If the type is not CMSG_DATA, the encoded inner content is returned.
Applicable only to decode.
pvData points to a DWORD, which receives the count.
To get all the CRLs, repetitively call CryptMsgGetParam, while varying dwIndex from 0 to (CrlCount - 1), where CrlCount is the value obtained from a previous call to CryptMsgGetParam with dwParamType set to CMSG_CRL_COUNT_PARAM.
Applicable only to decode.
pvData points to an array of the CRL's encoded bytes.
Applicable only to decode.
pvData points to a buffer that receives the encoded bytes.
Applicable only to decode.
pvData points to a buffer receiving the encoded bytes.
Applicable only to decode.
pvData points to a buffer receiving the encrypted digest bytes.
Applicable only to decode.
pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
Applicable only to decode.
pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
Applicable only to decode.
pvData points to an array of bytes.
Applicable only to decode. Not applicable to messages of type DATA.
pvData points to the buffer receiving the object identifier string.
Applicable only to decode.
pvData points to a DWORD, which receives the count.
Applicable only to decode.
pvData points to a DWORD, which receives the count.
To get the CERT_INFO for all the recipients, repetitively call CryptMsgGetParam, while varying dwIndex from 0 to (RecipientCount - 1), where RecipientCount is the value obtained from a previous call to CryptMsgGetParam with dwParamType set to CMSG_RECIPIENT_COUNT_PARAM.
Only the following fields have been updated in the CERT_INFO struct: Issuer, SerialNumber.
Applicable only to decode.
pvData points to a CERT_INFO struct.
To get all the authenticated attributes for a given signer, call CryptMsgGetParam, with dwIndex equal to that signer's index.
Applicable only to decode.
pvData points to a CRYPT_ATTRIBUTES struct.
Only the following fields contain valid data in the CERT_INFO struct returned: Issuer and SerialNumber.
Applicable only to decode.
pvData points to a CERT_INFO struct.
Applicable only to decode.
pvData points to a DWORD which receives the count.
To get the hash algorithm for a given signer, call CryptMsgGetParam, with dwIndex equal to that signer's index.
Applicable only to decode.
pvData points to a CRYPT_ALGORITHM_IDENTIFIER struct.
Applicable only to decode.
pvData points to a CMSG_SIGNER_INFO struct.
To get the unauthenticated attributes for a given signer, call CryptMsgGetParam, with dwIndex equal to that signer's index.
Applicable only to decode.
pvData points to a CRYPT_ATTRIBUTES struct.
Applicable only to decode.
pvData points to a DWORD which receives the message type.
This parameter can be NULL to set the size of this information for memory allocation purposes. For more information, see Common In/Out Parameter Conventions.
If the function fails, the return value is FALSE (zero). If it succeeds, the return value is TRUE (non-zero).
To retrieve extended error information, use the GetLastError function.
The following table lists the error codes most commonly returned by the GetLastError function.
Error code | Description |
---|---|
CRYPT_E_ATTRIBUTES_MISSING | The message does not contain the requested attributes. |
CRYPT_E_INVALID_INDEX | The index value is not valid. |
CRYPT_E_INVALID_MSG_TYPE | The message type is invalid. |
CRYPT_E_NOT_DECRYPTED | The message content has not been decrypted yet. |
CRYPT_E_OID_FORMAT | The object identifier is badly formatted. |
CRYPT_E_OSS_ERROR | OSS Certificate encode/decode error code base. Note, to get the OSS error subtract CRYPT_E_OSS_ERROR from the returned error and see asn1code.h for details on the error. |
CRYPT_E_UNEXPECTED_ENCODING | The message is not encoded as expected. |
E_INVALIDARG | One or more arguments are invalid. |
ERROR_MORE_DATA | The specified is not large enough to hold the returned data. |
Propagated errors that may be encountered: | For dwParamType == CMSG_COMPUTED_HASH_PARAM an error can be propagated from: CryptGetHashParam |
See Signed Message Example Code.
See Enveloped Message Example 1.
See Hashed Message Example Code.
Windows NT: Requires version 4.0 SP3 or later. Available also in IE 3.02 and later.
Windows: Requires Windows 98 (or Windows 95 with IE 3.02 or later).
Windows CE: Unsupported.
Header: Declared in wincrypt.h.
Import Library: Use crypt32.lib.
CryptMsgUpdate, CryptMsgOpenToDecode, CryptMsgOpenToEncode