Connecting to a CSP

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The following table shows functions an application can use to connect to a cryptographic service provider (CSP). These functions also enable applications to choose a specific CSP by name or get one with a specific set of properties.

Function Description

CryptAcquireContext

Acquires a handle to the current user key container within a particular CSP.

CryptGetProvParam

Retrieves CSP properties.

CryptReleaseContext

Frees the handle acquired by CryptAcquireContext.

CryptSetProvider

Specifies the user default CSP for a particular CSP type.

CryptSetProvParam

Specifies CSP properties.

Each time an application is run, the first CryptoAPI function an application calls is the CryptAcquireContext function. This function returns to the application a handle to a particular CSP. In addition, this handle specifies a particular key container within the CSP. If the CSP has just been installed and no key containers yet exist, CryptAcquireContext can also be used to create one.

When an application uses CryptAcquireContext to obtain a CSP handle, it specifies a CSP type and, optionally, a provider name. If both a type and a name are specified, the function searches for a CSP with the same type and name, loads it to memory, and returns a handle to the application.

When an application calls CryptAcquireContext specifying a CSP type, but no provider name, the function tries to find the provider name. It first searches a list of default providers associated with the current user, and, if that fails, it searches a list of default CSPs associated with your device.

Once CryptAcquireContext determines the provider name, it searches for the CSP, loads it to memory, and returns a handle to the application.

See Also

Concepts

Microsoft Cryptographic System

Other Resources

Cryptography
Certificates