Setting the User Default CSP

One user default CSP can be specified for each CSP type. This entry is used when an application calls the CryptAcquireContext function with only a CSP type specified.

The user defaults are stored in the Registry's HKEY_CURRENT_USER window, so the CSP Setup program can set this value only if the actual end user is currently logged on to the computer. In any case, the end user should be consulted and/or informed whenever the user default CSP is changed.

The user default CSP is to be set via the CryptSetProvider function, which internally sets the following Registry entry:

HKEY_CURRENT_USER
Software
Microsoft
Cryptography
Providers
Type
<CSP type>
>Name:REG_SZ:<CSP name>

The "CSP type" portion of the key name must be in decimal format, and exactly 3 digits in length.

The "Name" entry must be set to the textual name of the CSP. This must exactly match the "CSP name" Registry key discussed earlier in this chapter.