background image
Microsoft Windows 7 Kernel Mode Cryptographic Primitives Library (cng.sys) Security Policy Document
This Security Policy is non-proprietary and may be reproduced only in its original entirety (without revision)
18
ULONG cbSecret,
ULONG dwFlags);
The BCryptCreateHash() function creates a hash object with an optional key. The optional key is used for
HMAC and AES GMAC.
hAlgorithm [in, out] is the handle of an algorithm provider created by using the
BCryptOpenAlgorithmProvider function. The algorithm that was specified when the provider was created
must support the hash interface.
phHash [out] is a pointer to a BCRYPT_HASH_HANDLE value that receives a handle that represents the
hash object. This handle is used in subsequent hashing functions, such as the BCryptHashData function.
When you have finished using this handle, release it by passing it to the BCryptDestroyHash function.
pbHashObject [out] is a pointer to a buffer that receives the hash object. The cbHashObject parameter
contains the size of this buffer. The required size of this buffer can be obtained by calling the
BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH property. This will provide the size of
the hash object for the specified algorithm. This memory can only be freed after the hash handle is
destroyed.
cbHashObject [in] contains the size, in bytes, of the pbHashObject buffer.
pbSecret [in, optional] is a pointer to a buffer that contains the key to use for the hash. The cbSecret
parameter contains the size of this buffer. If no key should be used with the hash, set this parameter to
NULL. This key only applies to the HMAC and AES GMAC algorithms.
cbSecret [in, optional] contains the size, in bytes, of the pbSecret buffer. If no key should be used with
the hash, set this parameter to zero.
dwFlags [in] is not currently used and must be zero.
5.7.2 BCryptHashData
NTSTATUS WINAPI BCryptHashData(
BCRYPT_HASH_HANDLE hHash,
PUCHAR pbInput,
ULONG cbInput,
ULONG dwFlags);
The BCryptHashData() function performs a one way hash on a data buffer. Call the BCryptFinishHash()
function to finalize the hashing operation to get the hash result.
5.7.3 BCryptDuplicateHash
NTSTATUS WINAPI BCryptDuplicateHash(
BCRYPT_HASH_HANDLE hHash,
BCRYPT_HASH_HANDLE *phNewHash,
PUCHAR pbHashObject,
ULONG cbHashObject,
ULONG dwFlags);
The BCryptDuplicateHash()function duplicates an existing hash object. The duplicate hash object contains
all state and data that was hashed to the point of duplication.
5.7.4 BCryptFinishHash
NTSTATUS WINAPI BCryptFinishHash(
BCRYPT_HASH_HANDLE hHash,
PUCHAR pbOutput,
ULONG cbOutput,
ULONG dwFlags);
The BCryptFinishHash() function retrieves the hash value for the data accumulated from prior calls to
BCryptHashData() function.
5.7.5 BCryptDestroyHash
NTSTATUS WINAPI BCryptDestroyHash(