CMSG_ENVELOPED_ENCODE_INFO structure (wincrypt.h)

The CMSG_ENVELOPED_ENCODE_INFO structure contains information needed to encode an enveloped message. It is passed to CryptMsgOpenToEncode if the dwMsgType parameter is CMSG_ENVELOPED.

Syntax

typedef struct _CMSG_ENVELOPED_ENCODE_INFO {
  DWORD                       cbSize;
  HCRYPTPROV_LEGACY           hCryptProv;
  CRYPT_ALGORITHM_IDENTIFIER  ContentEncryptionAlgorithm;
  void                        *pvEncryptionAuxInfo;
  DWORD                       cRecipients;
  PCERT_INFO                  *rgpRecipients;
  PCMSG_RECIPIENT_ENCODE_INFO rgCmsRecipients;
  DWORD                       cCertEncoded;
  PCERT_BLOB                  rgCertEncoded;
  DWORD                       cCrlEncoded;
  PCRL_BLOB                   rgCrlEncoded;
  DWORD                       cAttrCertEncoded;
  PCERT_BLOB                  rgAttrCertEncoded;
  DWORD                       cUnprotectedAttr;
  PCRYPT_ATTRIBUTE            rgUnprotectedAttr;
} CMSG_ENVELOPED_ENCODE_INFO, *PCMSG_ENVELOPED_ENCODE_INFO;

Members

cbSize

The size, in bytes, of this structure.

hCryptProv

This member is not used and should be set to NULL.

Windows Server 2003 and Windows XP:  Specifies a handle to the cryptographic service provider (CSP) used to do content encryption, recipient key encryption, and export. The private keys of the hCryptProv are not used.

This member's data type is HCRYPTPROV.

Unless there is a strong reason for passing in a specific cryptographic provider in hCryptProv, pass zero to use the default RSA or DSS provider.

ContentEncryptionAlgorithm

A CRYPT_ALGORITHM_IDENTIFIER structure that contains the signature algorithm type and any associated additional parameters in encoded form.

The pszObjId member of the structure specifies the algorithm used to encrypt the message contents.

The following encryption algorithms require an encoded eight byte initialization vector (IV) in the Parameters member of structure. For details, see CryptSetKeyParam.

Value Meaning
CALG_DES
szOID_OIWSEC_desCBC
CALG_3DES
szOID_RSA_DES_EDE3_CBC
 

If the cbData member of the Parameters member is zero, an Abstract Syntax Notation One (ASN.1) encoded OCTET STRING containing the IV is generated using CryptGenRandom.

The szOID_RSA_RC2CBC (CALG_RC2) algorithm requires the pbData member of Parameters to be an encoded CRYPT_RC2_CBC_PARAMETERS structure. If the cbData member of the Parameters member is zero, an ASN.1 encoded CRYPT_RC2_CBC_PARAMETERS is generated with a default value of 40 for the dwVersion member. This sets the default key length to 40 bits. This default key length can be overridden with pvEncryptionAuxInfo pointing to a CMSG_RC2_AUX_INFO structure containing the desired key length.

Note  On decryption, if an IV exists, CryptSetKeyParam is called with the IV before decryption begins.
 

pvEncryptionAuxInfo

A pointer to a structure depending on the encryption algorithm.

Value Meaning
RC2

CMSG_RC2_AUX_INFO

RC4

CMSG_RC4_AUX_INFO

SP3 or compatible

CMSG_SP3_COMPATIBLE_AUX_INFO

All other encryption algorithms
NULL

cRecipients

Number of elements in the rgpRecipients or rgCmsRecipients array.

rgpRecipients

An array of pointers to CERT_INFO structures, each containing a recipient's certificate Issuer, SerialNumber, and SubjectPublicKeyInfo. This array can only be used for recipients identified by their Issuer and serial number. If rgpRecipients is not NULL, rgCmsRecipients must be NULL.

rgCmsRecipients

Optional. An array of pointers to CMSG_RECIPIENT_ENCODE_INFO structures containing recipient information. If rgCmsRecipients is not NULL, rgpRecipients must be NULL. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this field.

cCertEncoded

Optional. A DWORD value that indicates the number of encoded certificates in the rgCertEncoded array. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this field.

rgCertEncoded

Optional. Array of CERT_BLOB structures. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this field.

cCrlEncoded

Optional. A DWORD value that indicates the number of encoded certificate revocation lists (CRLs) in the rgCRLEncoded array. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this field.

rgCrlEncoded

Optional. An array of CRL_BLOB structures. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this field.

cAttrCertEncoded

Optional. A DWORD value that indicates the number of encoded certificate attributes in the rgAttrCertEncoded array. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this field.

rgAttrCertEncoded

Optional. An array of CRYPT_ATTRIBUTE structures. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this member.

cUnprotectedAttr

Optional. A DWORD value that indicates the number of unprotected attributes in the rgUnprotectedAttr array. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this field.

rgUnprotectedAttr

Optional. An array of CRYPT_ATTRIBUTE structures. CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS must be defined to reference this field.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Header wincrypt.h

See also

CERT_INFO

CRYPT_ALGORITHM_IDENTIFIER