The CPGetProvParam function is called by applications to retrieve various data about the CSP.
BOOL CPGetProvParam(
HCRYPTPROV hProv, // in
DWORD dwParam, // in
BYTE *pbData, // out
DWORD *pdwDataLen, // in, out
DWORD dwFlags // in
);
If this parameter is NULL, then no parameter data should be copied. Instead, the required buffer size (in bytes) should be returned in pdwDataLen. This is not an error.
As noted in CryptGetProvParam (in the CryptoAPI), when one of the enumeration parameters is being read, the value returned in pdwDataLen should be the size of the largest item in the enumeration list.
If the buffer specified by pbData is not large enough to hold the requested data, the ERROR_MORE_DATA error code should be returned via the SetLastError function. In this case, the required buffer size must be returned in pdwDataLen.
If this function fails with any error code other than ERROR_MORE_DATA, zero should be returned in this parameter.
If this flag is set when a non-enumeration parameter is being read, the NTE_BAD_FLAGS error code should be returned.
Note The following flag values are specific to RSAbase use only. CSPs that use a hardware solution will not use these flags.
typedef DWORD SECURITY_INFORMATION;
Value | Meaning |
---|---|
OWNER_SECURITY_INFORMATION | Indicates the owner identifier of the object is being referenced. |
GROUP_SECURITY_INFORMATION | Indicates the primary group identifier of the object is being referenced. |
DACL_SECURITY_INFORMATION | Indicates the discretionary ACL of the object is being referenced. |
SACL_SECURITY_INFORMATION | Indicates the system ACL of the object is being referenced. |
If the function succeeds, TRUE should be returned; otherwise, return FALSE. When FALSE is returned, the appropriate error code (see the following table) must be set via SetLastError.
Error | Description |
---|---|
ERROR_MORE_DATA | The pbData buffer is not large enough to hold the requested data. |
ERROR_NO_MORE_ITEMS | The end of the enumeration list has been reached. No valid data has been placed in the pbData buffer. This error is returned only when dwParam equals PP_ENUMALGS or PP_ENUMCONTAINERS. |
NTE_BAD_FLAGS | The value of the dwFlags parameter is invalid. |
NTE_BAD_TYPE | The dwParam parameter specifies an unknown parameter number. |
NTE_BAD_UID | The context specified by hProv is invalid. |
The dwParam parameter can be set to one of the following values:
Applications will often use this string to acquire this key container in a subsequent session, by passing it into the pszContainer parameter of CryptAcquireContext (in the CryptoAPI).
If the CSP only supports one key container (for example, one based on a smartcard with limited memory), then key container names may not be used. If this is the case, a null string "\0" can be returned in the pbData buffer.
Applications read this parameter repeatedly in order to enumerate all of the key containers maintained by the CSP, in a manner similar to the PP_ENUMALGS parameter.
If the CSP supports only one key container, this parameter is often not supported. In this case, an NTE_BAD_TYPE error code should be returned.
The following implementation types are currently defined (in Wincrypt.h):
Applications will often use this CSP name in order to connect to the CSP in a subsequent session, by passing the name for the pszProvider parameter of CryptAcquireContext (in the CryptoAPI).
Note Since it is desirable to perpetuate the CSP name across versions for backward compatibility, you may want to use only general terms in the CSP name and avoid specifics such as version numbers.
Note The PP_KEYSET_SEC_DESCR flag is not supported under Microsoft Windows 95.
The dwFlags parameter is used to pass in the SECURITY_INFORMATION bit flags that indicate the requested security information. The pointer to the security descriptor is returned in the pbData parameter and the length of the security descriptor is returned in the pcbData parameter. It may be helpful to look at the documentation on RegGetKeySecurity and RegSetKeySecurity (WIN32 calls).
In the Win32 SDK in MSTOOLS\samples\win32\winnt\security\secperf is sample code showing how to manipulate NT ACLs.
Algorithm Identifiers
When enumerating algorithms (dwParam == PP_ENUMALGS), your application may need to determine the class of a particular algorithm. For example, you may want to display a list of encryption algorithms to the user and disregard the rest. This can be done with the GET_ALG_CLASS(x) macro. This macro takes an algorithm identifier as an argument and returns a code indicating the general class of algorithm that the identifier belongs to. Possible return values include:
ALG_CLASS_DATA_ENCRYPT
ALG_CLASS_HASH
ALG_CLASS_KEY_EXCHANGE
ALG_CLASS_SIGNATURE
The following table lists the algorithms supported by the Microsoft RSA Base Provider along with the class of each algorithm.
Name Identifier Class
"MD2" CALG_MD2 ALG_CLASS_HASH
"MD5" CALG_MD5 ALG_CLASS_HASH
"SHA" CALG_SHA ALG_CLASS_HASH
"MAC" CALG_MAC ALG_CLASS_HASH
"RSA_SIGN" CALG_RSA_SIGN ALG_CLASS_SIGNATURE
"RSA_KEYX" CALG_RSA_KEYX ALG_CLASS_KEY_EXCHANGE
"RC2" CALG_RC2 ALG_CLASS_DATA_ENCRYPT
"RC4" CALG_RC4 ALG_CLASS_DATA_ENCRYPT
If your application does not recognize an algorithm identifier, it is not recommended that you use the algorithm. Making use of an unknown cryptographic algorithm can sometimes produce unpredictable results.
CPAcquireContext, CPSetProvParam, CryptGetProvParam