CryptGetMessageSignerCount

The CryptGetMessageSignerCount function returns the count of signers in the signed message.

#include <wincrypt.h>
LONG WINAPI CryptGetMessageSignerCount(
  DWORD dwMsgEncodingType,    // in
  const BYTE pbSignedBlob,    // in
  DWORD *cbSignedBlob         // in
);
 

Parameters

dwMsgEncodingType
The type of encoding used on the message. Note that it is always acceptable to specify both the certificate and message encoding types, by combining them with a bitwise OR operation, as shown in the following example:
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING
 

However, it is required only to specify the message encoding here. Currently defined encoding types are shown in the following table:
Encoding type Value
X509_ASN_ENCODING 0x00000001
PKCS_7_ASN_ENCODING 0x00010000

pbSignedBlob
A pointer to the signed message.
cbSignedBlob
The size, in bytes, of the signed message.

Return Values

Returns the count of signers in the signed message. Returns a zero when there are no signers. Returns a minus one for an error, and updates LastError accordingly.

Call GetLastError to see the reason for any failures. This function has the following error codes.

Error code Description
E_INVALIDARG Invalid message encoding type. Currently only PKCS_7_ASN_ENCODING is supported.
CRYPT_E_OSS_ERROR Message ASN.1 decoding error. Note, to get the OSS error subtract CRYPT_E_OSS_ERROR from the returned error and see asn1code.h for details on the error.

Remarks

Use GetLastError to determine the reason for any errors.

Example

//-------------------------------------------------------------------
// CryptGetMessageSignerCount() - Getting the number of signers of
// a message.
//-------------------------------------------------------------------

// Assume that the application has a pointer (pbSignedBlob) to
// the signed message, and its size (cbSignedBlob).

DWORD dwMsgEncodingType = PKCS_7_ASN_ENCODING;
BYTE* pbSignedBlob;      // Initialized elsewhere
DWORD cbSignedBlob;      // Initialized elsewhere
LONG  lSignerCount = 0;
DWORD dwLastError = 0;

lSignerCount = CryptGetMessageSignerCount(
                dwMsgEncodingType,
                pbSignedBlob,
                cbSignedBlob);
if(lSignerCount < 0)
    dwLastError = GetLastError();
    // handle the error
 

QuickInfo

  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.

See Also

CryptVerifyMessageSignature