CryptMsgUpdate (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This function adds contents to a cryptographic message. The use of this function allows messages to be constructed piece by piece through repetitive calls of CryptMsgUpdate. The added message content is either encoded or decoded depending on whether the message was opened with CryptMsgOpenToEncode or CryptMsgOpenToDecode.

BOOL WINAPI CryptMsgUpdate(
  HCRYPTMSG hCryptMsg,
  const BYTE* pbData,
  DWORD cbData,
  BOOL fFinal


[in] Cryptographic message handle of the message to be updated.
[in] Pointer to the buffer holding the data to be encoded or decoded.
[in] Number of bytes of data in the pbData buffer.
[in] Indicates that the last block of data for encoding or decoding is being processed. Correct usage of this flag is dependent upon whether the message that is being processed has detached data. The inclusion of detached data in a message is indicated by setting dwFlags to CMSG_DETACHED_FLAG in the call to the function that opened the message.

If CMSG_DETACHED_FLAG was not set and the message was opened using either CryptMsgOpenToDecode or CryptMsgOpenToEncode, fFinal is set to TRUE, and CryptMsgUpdate is only called once.

If the CMSG_DETACHED_FLAG flag was set and a message is opened using CryptMsgOpenToEncode, fFinal is set to TRUE only on the last call to CryptMsgUpdate.

If the CMSG_DETACHED_FLAG flag was set and a message is opened using CryptMsgOpenToDecode, fFinal is set to TRUE when the header is processed by a single call to CryptMsgUpdate. It is set to FALSE while processing the detached data in subsequent calls to CryptMsgUpdate until the last detached data block is to be processed. On the last call to CryptMsgUpdate, it is set to TRUE.

When detached data is decoded, the header and the content of a message are contained in different BLOBs. Each BLOB requires that fFinal be set to TRUE when the last call to the function is made for that BLOB.

Return Values

If the function succeeds, the return value is non-zero (TRUE).

If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError.

Errors encountered in the application defined callback function specified by pStreamInfo in CryptMsgOpenToDecode and CryptMsgOpenToEncode might be propagated to CryptMsgUpdate if streaming is used. If this happens, SetLastError is not called by CryptMsgUpdate after the callback returns This preserves any errors encountered under the control of the application. It is the responsibility of the callback function (or one of the APIs that it calls) to call SetLastError if an error occurs while the application is processing the streamed data.

The following table shows the error codes most commonly returned by the GetLastError function.

Return CodeDescription
CRYPT_E_INVALID_MSG_TYPEThe message type is invalid.
CRYPT_E_MSG_ERRORAn error was encountered doing a cryptographic operation.
CRYPT_E_OID_FORMATThe object identifier is badly formatted.
CRYPT_E_UNEXPECTED_ENCODINGThe message is not encoded as expected.
CRYPT_E_UNKNOWN_ALGOThe cryptographic algorithm is unknown.
E_INVALIDARGOne or more arguments are invalid.
E_OUTOFMEMORYRan out of memory.

Propagated errors might be encountered from any of the following functions:

If the function fails, GetLastError returns an ASN.1 encoding/decoding error.


OS Versions: Windows CE 5.0 and later.
Header: Wincrypt.h.
Link Library: Coredll.lib.

See Also

Cryptography Functions | CryptMsgGetParam | CryptMsgOpenToEncode | CryptMsgOpenToDecode

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.