Back to the WFC main page
$Revision: 31 $
Description
This class handles most of the Crypto API functionality.
Data Members
None.
Methods
void Close( void )
-
Closes the session.
BOOL CreateHash( const CCryptographicAlgorithm& which_algorithm_you_want_the_key_for,
const CCryptographicKey& key_for_algorithms_that_need_it,
CCryptographicHash& destination_hash,
DWORD flags = 0 )
-
Creates a hasher for use with a specified algorithm.
BOOL CreateKey( const CCryptographicAlgorithm& which_algorithm_you_want_the_key_for,
CCryptographicKey& destination_key,
DWORD flags = CRYPT_EXPORTABLE,
WORD number_of_bits_in_key = 0 )
-
Creates an encryption key for use with a specified algorithm.
BOOL CreateKeySet( LPCTSTR container_name = NULL,
LPCTSTR provider_name = NULL,
DWORD provider_type = RsaFull )
-
Creates a key set (needed to Open the crypto).
BOOL DeriveKey( const CCryptographicAlgorithm& algorithm,
const CCryptographicHash& hash,
CCryptographicKey& key,
DWORD flags = keyflagExportable )
-
This function is the same as CreateKey(),
except that the generated session keys are derived from base data instead
of being random. Another difference is that the DeriveKey()
method cannot be used to generate public/private key pairs.
void Dump( CDumpContext& dump_context ) const
-
Present only in the Debug builds.
void EnumerateAlgorithms( DWORD& enumerator )
-
Initializes an enumerator to list the algorithms
this provider provides.
BOOL GenerateRandomBytes( CByteArray& bytes, DWORD number_of_bytes = 0 )
-
Generates a set of random bytes. if
number_of_bytes
is
zero, the bytes in bytes
will be overwritten with random bytes.
BOOL GetNext( DWORD& enumerator, CCryptographicAlgorithm& algorithm )
-
Used to walk the list of enumerated thingies.
BOOL GetParameter( const DWORD what_to_get, CByteArray& buffer, const DWORD flags )
-
Retrieves information about the crypto.
what_to_get
may be one of the following:
- parameterEnumerateAlgorithms
- parameterEnumerateContainers
- parameterImplementationType
- parameterName
- parameterVersion
- parameterCurrentKeyContainerName
- parameterClientWindowHandle
BOOL GetUserKey( DWORD which_user_key_to_get, CCryptographicKey& key )
-
Retrieves a user's key.
which_user_key_to_get
varies from
provider to provider but it will almost always be one of the following:
- AT_KEYEXCHANGE
- AT_SIGNATURE
BOOL ImportKey( CByteArray& exported_key_data,
CCryptographicKey& key,
DWORD format = CCryptographicKey::formatSimple,
DWORD flags = 0 )
-
This used to transfer a cryptographic key from a key blob to the service
provider.
BOOL Open( LPCTSTR container_name = NULL,
LPCTSTR provider_name = NULL,
DWORD provider_type = RsaFull,
DWORD flags = 0
-
Opens a session with the crypto. It will automatically create
a key set if needed.
BOOL SetDefault( const CString& name, DWORD type )
-
Sets the default provider.
Example
Sorry.
API's Used
- CryptAcquireContext
- CryptCreateHash
- CryptDeriveKey
- CryptGenKey
- CryptGenRandom
- CryptGetProvParam
- CryptGetUserKey
- CryptImportKey
- CryptReleaseContext
- CryptSetProvider
Copyright, 2000, Samuel R. Blackburn
$Workfile: CCryptographicProvider.cpp $
$Modtime: 1/04/00 5:09a $