This function performs the following operations:
- Calls CryptEncodeObject using lpszStructType to encode the "to be signed" information.
- Calls CryptSignCertificate to sign this encoded information.
- Calls CryptEncodeObject again, with lpszStructType set to X509_CERT, to further encode the resulting signed, encoded information.
BOOL CryptSignAndEncodeCertificate( BCRYPT_KEY_HANDLE hBCryptKey, DWORD dwKeySpec, DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm, const void *pvHashAuxInfo, BYTE *pbEncoded, DWORD *pcbEncoded );
A handle of the cryptographic service provider (CSP) to do the signature. This handle is an HCRYPTPROV handle that has been created by using the CryptAcquireContext function or an NCRYPT_KEY_HANDLE handle that has been created by using the NCryptOpenKey function. New applications should always pass in a NCRYPT_KEY_HANDLE handle of a CNG CSP.
Identifies the private key to use from the provider's container. This must be one of the following values. This parameter is ignored if a CNG key is passed in the hCryptProvOrNCryptKey parameter.
||Use the key exchange key.|
||Use the digital signature key.|
Specifies the encoding type used. This can be the following value.
||Specifies X.509 certificate encoding.|
A pointer to a null-terminated ANSI string that contains the type of data to be encoded and signed. The following predefined lpszStructType constants are used with encode operations.
||pvStructInfo is the address of a CRL_INFO structure.|
||pvStructInfo is the address of a CERT_REQUEST_INFO structure.|
||pvStructInfo is the address of a CERT_INFO structure.|
||pvStructInfo is the address of a CERT_KEYGEN_REQUEST_INFO structure.|
The address of a structure that contains the data to be signed and encoded. The format of this structure is determined by the lpszStructType parameter.
A pointer to a CRYPT_ALGORITHM_IDENTIFIER structure that contains the object identifier (OID) of the signature algorithm and any additional parameters needed. This function uses the following algorithm OIDs:
Reserved. Must be NULL.
A pointer to a buffer to receive the signed and encoded output.
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.
A pointer to a DWORD that contains the size, in bytes, of the buffer pointed to by the pbEncoded parameter. When the function returns, the DWORD contains the number of bytes stored or to be stored in the buffer.
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.
||If the buffer specified by the pbEncoded parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code and stores the required buffer size, in bytes, into the variable pointed to by pcbEncoded.|
||Invalid certificate encoding type. Currently only X509_ASN_ENCODING is supported.|
||The signature algorithm's OID does not map to a known or supported hash algorithm.|
||An error was encountered while encoding or decoding. The most likely cause of this error is the improper initialization of the fields in the structure pointed to by pvStructInfo.|
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|