Skip to content

Latest commit

 

History

History
168 lines (127 loc) · 6.4 KB

nf-wincrypt-cryptsigncertificate.md

File metadata and controls

168 lines (127 loc) · 6.4 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:wincrypt.CryptSignCertificate
CryptSignCertificate function (wincrypt.h)
The CryptSignCertificate function signs the "to be signed" information in the encoded signed content.
CryptSignCertificate
CryptSignCertificate function [Security]
_crypto2_cryptsigncertificate
security.cryptsigncertificate
wincrypt/CryptSignCertificate
security\cryptsigncertificate.htm
security
27578149-e5c0-47e5-8309-0d0ed7075d13
12/05/2018
CryptSignCertificate, CryptSignCertificate function [Security], _crypto2_cryptsigncertificate, security.cryptsigncertificate, wincrypt/CryptSignCertificate
wincrypt.h
Windows
Windows XP [desktop apps only]
Windows Server 2003 [desktop apps only]
Crypt32.lib
Crypt32.dll
Windows
19H1
CryptSignCertificate
wincrypt/CryptSignCertificate
c++
APIRef
kbSyntax
DllExport
Crypt32.dll
CryptSignCertificate

CryptSignCertificate function

-description

The CryptSignCertificate function signs the "to be signed" information in the encoded signed content.

-parameters

-param hBCryptKey [in]

Handle of the CSP that does the signature. This handle must be 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 the NCRYPT_KEY_HANDLE handle of a CNG CSP.

-param dwKeySpec [in]

Identifies the private key to use from the provider's container. It can be AT_KEYEXCHANGE or AT_SIGNATURE. This parameter is ignored if an NCRYPT_KEY_HANDLE is used in the hCryptProvOrNCryptKey parameter.

-param dwCertEncodingType [in]

Specifies the encoding type used. 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

Currently defined encoding types are:

  • X509_ASN_ENCODING
  • PKCS_7_ASN_ENCODING

-param pbEncodedToBeSigned [in]

A pointer to the encoded content to be signed.

-param cbEncodedToBeSigned [in]

The size, in bytes, of the encoded content, pbEncodedToBeSigned.

-param pSignatureAlgorithm [in]

A pointer to a CRYPT_ALGORITHM_IDENTIFIER structure with a pszObjId member set to one of the following:

  • szOID_RSA_MD5RSA
  • szOID_RSA_SHA1RSA
  • szOID_X957_SHA1DSA
  • szOID_RSA_SSA_PSS
  • szOID_ECDSA_SPECIFIED
If the signature algorithm is a hash algorithm, the signature contains only the un-encrypted hash octets. A private key is not used to encrypt the hash. dwKeySpec is not used and hCryptProvOrNCryptKey can be NULL if an appropriate default CSP can be used for hashing.

-param pvHashAuxInfo [in]

Not currently used. Must be NULL.

-param pbSignature [out]

A pointer to a buffer to receive the signed hash of the content.

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.

-param pcbSignature [in, out]

A pointer to a DWORD that contains the size, in bytes, of the buffer pointed to by the pbSignature parameter. When the function returns, the DWORD contains the number of bytes stored or to be stored in the buffer.

Note  When processing the data returned in the buffer, applications must use the actual size of the data returned. The actual size can be slightly smaller than the size of the buffer specified on input. (On input, buffer sizes are usually specified large enough to ensure that the largest possible output data will fit in the buffer.) On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.
 

-returns

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.

Note  Errors from the called functions CryptCreateHash, CryptSignHash and CryptHashData might be propagated to this function.
 
This function has the following error codes.
Return code Description
ERROR_MORE_DATA
If the buffer specified by the pbSignature 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 pcbSignature.
NTE_BAD_ALGID
The signature algorithm's object identifier (OID) does not map to a known or supported hash algorithm.

-see-also

CryptSignAndEncodeCertificate

Data Management Functions