Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function installs a previously acquired HCRYPTPROVcontext to be used as a default context. The values of two input parameters, wDefaultTypeand pvDefaultPara, specify where the default context is used.
Syntax
BOOL WINAPI CryptInstallDefaultContext( HCRYPTPROV hCryptProv, DWORD dwDefaultType, const void* pvDefaultPara, DWORD dwFlags, void* pvReserved, HCRYPTDEFAULTCONTEXT* phDefaultContext ); |
Parameters
- hCryptProv
-
[in] HCRYPTPROVhandle to be used as the default context. This handle must have already been created using the CryptAcquireContextfunction.
- dwDefaultType
-
[in] Specifies the use of the default provider handle. The following table shows the possible values for this parameter.
Value Description CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID
Installs a default HCRYPTPROVhandle used to verify a certificate signature. pvDefaultParapoints to the szOIDvalue of the certificate signature algorithm; for example, szOID_OIWSEC_md5RSA. If pvDefaultParais NULL, the HCRYPTPROVhandle is used to verify all certificate signatures. The pvDefaultParaparameter cannot be NULL when CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG is set.
CRYPT_DEFAULT_CONTEXT_MULTI_CERT_SIGN_OID
Same as CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID. However, the default HCRYPT2PROVstructure is to be used for multiple signature szOIDvalues. The pvDefaultParaparameter points to a CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARAstructure containing an array of szOIDpointers.
- pvDefaultPara
-
[in] Pointer to the szOIDvalue of the certificate signature algorithm or to an array of szOIDvalues defined in the CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARAstructure. It can be NULL if the dwDefaultTypeparameter is CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID and the default HCRYPTPROVvalue is used to verify all certificate signatures.
- dwFlags
-
[in] Specifies the way that the provider is freed. The following table shows possible values for this parameter.
Value Description CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG
The hCryptProvvalue is freed automatically when the process ends. The hCryptProvvalue is not freed by a call to the CryptUninstallDefaultContextfunction if the function is called before process or thread exit.
CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG
The hCryptProvvalue is applicable to all threads in the process. This is the default flag.
- pvReserved
-
[in] Reserved for future use.
- phDefaultContext
-
[out] Pointer to the handle of the new default context.
Return Value
If the function succeeds, the return value is nonzero, or TRUE, and the phDefaultContextparameter is updated with the handle to be passed to the CryptUninstallDefaultContextfunction.
If the function fails, the return value is zero, or FALSE.
For extended error information, call the GetLastErrorfunction.
Remarks
By default, the installed HCRYPTPROVvalue is only applicable to the current thread. Set CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG to allow the HCRYPTPROVvalue to be used by all threads in the current process.
The installed HCRYPTPROVvalues are stack-ordered, thus the last installed HCRYPTPROVvalue is checked first. All thread-installed HCRYPTPROVvalues are checked before any process HCRYPTPROVvalues.
The installed HCRYPTPROVvalue remains available for default usage until the CryptUninstallDefaultContextfunction is called or the thread or process exits.
If CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG is set, then the HCRYPTPROVvalue is freed by the CryptReleaseContextfunction at thread or process exit. The provider is not re-freed if the CryptUninstallDefaultContextfunction was previously called.
Requirements
Header | wincrypt.h |
Library | crypt32.lib |
Windows Embedded CE | Windows CE 3.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |