win32crypt.CryptDecodeMessage

dict = CryptDecodeMessage(EncodedBlob, DecryptPara , VerifyPara , MsgTypeFlags , SignerIndex , PrevInnerContentType , ReturnData )

Decodes and decrypts a message, and verifies its signatures

Parameters

EncodedBlob : buffer

Data to be decoded

DecryptPara : dict

PyCRYPT_DECRYPT_MESSAGE_PARA containing decryption parms

VerifyPara=None : dict

PyCRYPT_VERIFY_MESSAGE_PARA containing signature verification parms

MsgTypeFlags=CMSG_ALL_FLAGS : int

Combination of CMSG_DATA_FLAG, CMSG_SIGNED_FLAG, CMSG_ENVELOPED_FLAG, CMSG_SIGNED_AND_ENVELOPED_FLAG, or CMSG_HASHED_FLAG

SignerIndex=0 : int

Index of the signer to verify, ignored if message is not signed.

PrevInnerContentType=0 : int

Content type returned from previous call, used during subsequent pass on a nested message

ReturnData=True : boolean

Indicates if decoded data should be returned.

Comments

Only one level of encoding is interpreted. Some types of messages will need multiple calls to completely decode. For example, to decode a message created by win32crypt::CryptSignAndEncryptMessage, one pass with CMSG_ENVELOPED_FLAG and a second pass using CMSG_SIGNED_FLAG are required to recover the original message text.

Return Value

Output params are returned as a dict containing:
{MsgType:int},   ##Type of message decoded, one of CMSG_DATA,CMSG_SIGNED,CMSG_ENVELOPED,CMSG_SIGNED_AND_ENVELOPED,CMSG_HASHED
InnerContentType:int,   ##Type of decoded content returned, uses same set of values as MsgType. CMSG_DATA indicates unencoded data.
Decoded:str,   ##The decoded data, will be None if ReturnData is False.
XchgCert:PyCERT_CONTEXT,   ##Certificate used to decode message
SignerCert:PyCERT_CONTEXT}   ##Certificate used to sign message