Back to the WFC main page
$Revision: 24 $
Description
This class encapsulates cryptographic hashes. A "cryptographic hash" is
basically a checksum.
Constructors
CCryptographicHash()
CCryptographicHash( HCRYPTHASH source_handle, BOOL automatically_destroy = TRUE )
-
Constructs the object.
Methods
BOOL Destroy( void )
-
Destroys the hash.
BOOL FromHandle( HCRYPTHASH source_handle, BOOL automatically_destroy = TRUE )
-
Tells the class to start playing with the HCRYPTHASH provided.
BOOL GetAlgorithmIdentifier( DWORD& identifier )
-
Retrieves the identifier for the algorithm.
HCRYPTHASH GetHandle( void ) const
-
Returns the encapsulated HCRYPTHASH so you can play with the API directly.
BOOL GetLength( DWORD& block_length )
-
Retrieves the block length.
BOOL GetValue( CByteArray& hash_result )
-
Retrieves the hash itself.
BOOL GetParameter( const DWORD parameter_to_get, BYTE *buffer, DWORD& buffer_length, const DWORD flags = 0 )
-
Retrieves one of the following bits of information:
- parameterAlgorithmIdentifier
- parameterLength
- parameterValue
It is probably easier to call the helper functions, GetAlgorithmIdentifier(),
GetLength() or GetValue() than GetParameter().
BOOL Hash( CByteArray& data_to_compute_a_hash_on, DWORD flags = CRYPT_USERDATA )
BOOL Hash( const CCryptographicKey& key_to_hash, DWORD flags = 0 )
-
Computes the hash value from the data block (
data_to_compute_hash_on
)or
the CCryptographicKey (key_to_hash
) given. You can retrieve the hash via GetValue.
BOOL SetParameter( const DWORD parameter_to_set, BYTE *buffer, const DWORD flags = 0 )
-
Sets a parameter of the key. You can set one of these parameters:
BOOL SetValue( CByteArray& value )
-
Basically calls SetParameter() with parameterValue.
BOOL Sign( DWORD which_key_to_sign_with, CString& password, CByteArray& signature, DWORD flags = 0 )
-
After you've created the hash you must sign it. You
must supply a plain text password to be used in the signature.
BOOL VerifySignature( CByteArray& signature, CCryptographicKey& public_key_to_verify_with, CString& password, DWORD flags = 0 )
-
To verify the signature, you must supply
the exact same plain text password as the person who signed (using Sign()) the hash.
Example
Sorry.
API's Used
- CryptDestroyHash
- CryptGetHashParam
- CryptHashData
- CryptHashSessionKey
- CryptSetHashParam
- CryptSignHash
- CryptVerifySignature
Copyright, 2000, Samuel R. Blackburn
$Workfile: CCryptographicHash.cpp $
$Modtime: 1/04/00 5:09a $