BCryptHashData

BCryptHashData function

The BCryptHashData function performs a one way hash or Message Authentication Code (MAC) on a data buffer.

Syntax


NTSTATUS WINAPI BCryptHashData(
  _Inout_ BCRYPT_HASH_HANDLE hHash,
  _In_    PUCHAR             pbInput,
  _In_    ULONG              cbInput,
  _In_    ULONG              dwFlags
);

Parameters

hHash [in, out]

The handle of the hash or MAC object to use to perform the operation. This handle is obtained by calling the BCryptCreateHash function.

pbInput [in]

A pointer to a buffer that contains the data to process. The cbInput parameter contains the number of bytes in this buffer. This function does not modify the contents of this buffer.

cbInput [in]

The number of bytes in the pbInput buffer.

dwFlags [in]

A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero.

Return value

Returns a status code that indicates the success or failure of the function.

Possible return codes include, but are not limited to, the following.

Return codeDescription
STATUS_SUCCESS

The function was successful.

STATUS_INVALID_PARAMETER

One or more parameters are not valid.

STATUS_INVALID_HANDLE

The hash handle in the hHash parameter is not valid. After the BCryptFinishHash function has been called for a hash handle, that handle cannot be reused.

 

Remarks

To combine more than one buffer into the hash or MAC, you can call this function multiple times, passing a different buffer each time. To obtain the hash or MAC value, call the BCryptFinishHash function. After the BCryptFinishHash function has been called for a specified handle, that handle cannot be reused.

Depending on what processor modes a provider supports, BCryptHashData can be called either from user mode or kernel mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is DISPATCH_LEVEL, the handle provided in the hHash parameter must be derived from an algorithm handle returned by a provider that was opened by using the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptHashData function must refer to nonpaged (or locked) memory.

To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see WDK and Developer Tools.

Windows Server 2008 and Windows Vista:  To call this function in kernel mode, use Ksecdd.lib.

Requirements

Minimum supported client

Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 [desktop apps | Windows Store apps]

Header

Bcrypt.h

Library

Bcrypt.lib

DLL

Bcrypt.dll

See also

BCryptCreateHash
BCryptFinishHash

 

 

Show:
© 2016 Microsoft