CryptMsgCountersignEncoded function (wincrypt.h)

The CryptMsgCountersignEncoded function countersigns an existing PKCS #7 message signature. The pbCountersignature BYTE buffer it creates is a PKCS #7 encoded SignerInfo that can be used as an unauthenticated Countersignature attribute of a PKCS #9 signed-data or signed-and-enveloped-data message.

Syntax

BOOL CryptMsgCountersignEncoded(
  [in]      DWORD                    dwEncodingType,
  [in]      PBYTE                    pbSignerInfo,
  [in]      DWORD                    cbSignerInfo,
  [in]      DWORD                    cCountersigners,
  [in]      PCMSG_SIGNER_ENCODE_INFO rgCountersigners,
  [out]     PBYTE                    pbCountersignature,
  [in, out] PDWORD                   pcbCountersignature
);

Parameters

[in] dwEncodingType

Specifies the encoding type used. Currently, only X509_ASN_ENCODING and PKCS_7_ASN_ENCODING are being used; however, additional encoding types may be added in the future. For either current encoding type, use:

X509_ASN_ENCODING | PKCS_7_ASN_ENCODING.

[in] pbSignerInfo

A pointer to the encoded SignerInfo that is to be countersigned.

[in] cbSignerInfo

Count, in bytes, of the encoded SignerInfo data.

[in] cCountersigners

Number of countersigners in the rgCountersigners array.

[in] rgCountersigners

Array of countersigners' CMSG_SIGNER_ENCODE_INFO structures.

[out] pbCountersignature

A pointer to a buffer to receive an encoded PKCS #9 countersignature attribute.

On input, 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] pcbCountersignature

A pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pbCountersignature parameter. When the function returns, the variable pointed to by the pcbCountersignature parameter contains the number of bytes stored in the buffer.

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 table lists the error codes most commonly returned by the GetLastError function.

Return code Description
CRYPT_E_OID_FORMAT
The object identifier is badly formatted.
E_INVALIDARG
One or more arguments are not valid.
E_OUTOFMEMORY
Ran out of memory.
 

Propagated errors might be returned from one of the following functions:

If the function fails, GetLastError may return an Abstract Syntax Notation One (ASN.1) encoding/decoding error. For information about these errors, see ASN.1 Encoding/Decoding Return Values.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll

See also

CryptMsgCountersign

CryptMsgVerifyCountersignatureEncoded

Low-level Message Functions

Simplified Message Functions