Csp C Library Reference
Csp
* This is a freeware class/C library/library.
Represents a cryptographic service provider for selecting encryption, hashing, and digital signing algorithms.
Create/Dispose
HCkCsp CkCsp_Create(void);
Creates an instance of the CkCsp object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.
void CkCsp_Dispose(HCkCsp handle);
Objects created by calling CkCsp_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.
C "Properties"
void CkCsp_getEncryptAlgorithm(HCkCsp cHandle, HCkString retval);
Returns the name of the currently selected encryption algorithm in the currently selected CSP.
long CkCsp_getEncryptAlgorithmID(HCkCsp cHandle);
Returns the ID of the currently selected encryption algorithm in the currently selected CSP.
long CkCsp_getEncryptNumBits(HCkCsp cHandle);
Returns the key-length of the currently selected encryption algorithm in the currently selected CSP.
void CkCsp_getHashAlgorithm(HCkCsp cHandle, HCkString retval);
Returns the name of the currently selected hash algorithm in the currently selected CSP.
long CkCsp_getHashAlgorithmID(HCkCsp cHandle);
Returns the ID of the currently selected hash algorithm in the currently selected CSP.
long CkCsp_getHashNumBits(HCkCsp cHandle);
Returns the bit length of the currently selected hash algorithm in the currently selected CSP.
void CkCsp_getKeyContainerName(HCkCsp cHandle, HCkString retval); void CkCsp_putKeyContainerName(HCkCsp cHandle, const char *newVal);
The name of the currently selected key container within the currently selected CSP. The default is typically the name of the current logged-in user.
void CkCsp_getLastErrorHtml(HCkCsp cHandle, HCkString retval);
Error information in HTML format for the last method called.
void CkCsp_getLastErrorText(HCkCsp cHandle, HCkString retval);
Error information in plain-text format for the last method called.
void CkCsp_getLastErrorXml(HCkCsp cHandle, HCkString retval);
Error information in XML format for the last method called.
BOOL CkCsp_getMachineKeyset(HCkCsp cHandle); void CkCsp_putMachineKeyset(HCkCsp cHandle, BOOL newVal);
To be documented soon...
long CkCsp_getNumEncryptAlgorithms(HCkCsp cHandle);
The number of encryption algorithms provided by the currently selected CSP.
long CkCsp_getNumHashAlgorithms(HCkCsp cHandle);
The number of hash algorithms provided by the currently selected CSP.
long CkCsp_getNumKeyContainers(HCkCsp cHandle);
The number of key containers provided by the currently selected CSP.
long CkCsp_getNumKeyExchangeAlgorithms(HCkCsp cHandle);
The number of key exchange algorithms provided by the currently selected CSP.
long CkCsp_getNumSignatureAlgorithms(HCkCsp cHandle);
The number of signature algorithms provided by the currently selected CSP.
void CkCsp_getProviderName(HCkCsp cHandle, HCkString retval); void CkCsp_putProviderName(HCkCsp cHandle, const char *newVal);
The currently selected CSP. To select another CSP, simply set this property to the name of the CSP, such as "Microsoft Enhanced Cryptographic Provider v1.0". If the CSP is not available on your machine, the property value will not change. The initial and default value for this property is "Microsoft Base Cryptographic Provider v1.0".
long CkCsp_getProviderType(HCkCsp cHandle);
This is an integer representing the type of CSP. (Chilkat uses it for internal use.)
BOOL CkCsp_getUtf8(HCkCsp cHandle); void CkCsp_putUtf8(HCkCsp cHandle, BOOL newVal);
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
C "Methods"
BOOL CkCsp_GetEncryptionAlgorithm(HCkCsp cHandle, long index, HCkString name);
Returns the name of the Nth encryption algorithm provided by the currently selected CSP. Indexing begins at 0.
long CkCsp_GetEncryptionNumBits(HCkCsp cHandle, long index);
Returns the key-length of the currently selected encryption algorithm in the currently selected CSP.
BOOL CkCsp_GetHashAlgorithm(HCkCsp cHandle, long index, HCkString name);
Returns the name of the currently selected hash algorithm in the currently selected CSP.
long CkCsp_GetHashNumBits(HCkCsp cHandle, long index);
Returns the bit length of the Nth hash algorithm provided by the currently selected CSP. Indexing begins at 0.
BOOL CkCsp_GetKeyContainerName(HCkCsp cHandle, long index, HCkString name);
Returns the Nth key container name in the currently selected CSP. Indexing begins at 0.
HCkStringArray CkCsp_GetKeyContainerNames(HCkCsp cHandle);
Returns a string array containing the names of all the key containers in the current CSP. Returns a null reference on failure
BOOL CkCsp_GetKeyExchangeAlgorithm(HCkCsp cHandle, long index, HCkString name);
Returns the Nth key exchange algorithm provided by the currently selected CSP. Indexing begins at 0.
long CkCsp_GetKeyExchangeNumBits(HCkCsp cHandle, long index);
Returns the bit length of the Nth key exchange algorithm provided by the currently selected CSP. Indexing begins at 0.
BOOL CkCsp_GetSignatureAlgorithm(HCkCsp cHandle, long index, HCkString name);
Returns the name of the Nth signature algorithm provided by the currently selected CSP. Indexing begins at 0.
long CkCsp_GetSignatureNumBits(HCkCsp cHandle, long index);
Returns the bit length of the Nth signature algorithm provided by the currently selected CSP. Indexing begins at 0.
BOOL CkCsp_HasEncryptAlgorithm(HCkCsp cHandle, const char *name, long numBits);
Returns true if the currently selected CSP contains an encryption algorithm matching the name and key length. Otherwise returns false.
BOOL CkCsp_HasHashAlgorithm(HCkCsp cHandle, const char *name, long numBits);
Returns true if the currently selected CSP contains a hash algorithm matching the name and bit length. Otherwise returns false.
BOOL CkCsp_SaveLastError(HCkCsp cHandle, const char *filename);
Saves the last error information to an XML formatted file.
long CkCsp_SetEncryptAlgorithm(HCkCsp cHandle, const char *name);
Selects an encryption algorithm. The return value is the key-length of the algorithm. If the algorithm is not available, the return value is 0. (There usually is not a need to explicitly select the key length, because the key length can be part of the name, such as "AES 128", or it is determined by the CSP. For example, the Microsoft Enhanced CSP will return a 128-bit key length for RC2, whereas the Base CSP will return a 40-bit key length.)
long CkCsp_SetHashAlgorithm(HCkCsp cHandle, const char *name);
Selects a hash algorithm. The return value is the bit-length of the algorithm. If the algorithm is not available, the return value is 0.
BOOL CkCsp_SetProviderMicrosoftBase(HCkCsp cHandle);
Sets the CSP to the Base Microsoft Cryptographic Provider, which is the default.
BOOL CkCsp_SetProviderMicrosoftEnhanced(HCkCsp cHandle);
Sets the CSP to the Enhanced Microsoft Cryptographic Provider.
BOOL CkCsp_SetProviderMicrosoftRsaAes(HCkCsp cHandle);
Sets the CSP to the Microsoft Cryptographic RSA/AES Prototype Provider.
BOOL CkCsp_SetProviderMicrosoftStrong(HCkCsp cHandle);
Sets the CSP to the Strong Microsoft Cryptographic Provider.
const char *CkCsp_encryptAlgorithm(HCkCsp cHandle);
Returns the name of the currently selected encryption algorithm in the currently selected CSP.
const char *CkCsp_getEncryptionAlgorithm(HCkCsp cHandle, long index);
Returns the name of the Nth encryption algorithm provided by the currently selected CSP. Indexing begins at 0.
const char *CkCsp_getHashAlgorithm(HCkCsp cHandle, long index);
Returns the name of the currently selected hash algorithm in the currently selected CSP.
const char *CkCsp_getKeyContainerName(HCkCsp cHandle, long index);
Returns the Nth key container name in the currently selected CSP. Indexing begins at 0.
const char *CkCsp_getKeyExchangeAlgorithm(HCkCsp cHandle, long index);
Returns the Nth key exchange algorithm provided by the currently selected CSP. Indexing begins at 0.
const char *CkCsp_getSignatureAlgorithm(HCkCsp cHandle, long index);
Returns the name of the Nth signature algorithm provided by the currently selected CSP. Indexing begins at 0.
const char *CkCsp_hashAlgorithm(HCkCsp cHandle);
Returns the name of the currently selected hash algorithm in the currently selected CSP.
const char *CkCsp_keyContainerName(HCkCsp cHandle);
The name of the currently selected key container within the currently selected CSP. The default is typically the name of the current logged-in user.
const char *CkCsp_lastErrorHtml(HCkCsp cHandle);
Error information in HTML format for the last method called.
const char *CkCsp_lastErrorText(HCkCsp cHandle);
Error information in plain-text format for the last method called.
const char *CkCsp_lastErrorXml(HCkCsp cHandle);
Error information in XML format for the last method called.
const char *CkCsp_providerName(HCkCsp cHandle);
The currently selected CSP. To select another CSP, simply set this property to the name of the CSP, such as "Microsoft Enhanced Cryptographic Provider v1.0". If the CSP is not available on your machine, the property value will not change. The initial and default value for this property is "Microsoft Base Cryptographic Provider v1.0".
|