28    {
   29        global::Interop.BCrypt.BCryptOpenAlgorithmProviderFlags bCryptOpenAlgorithmProviderFlags = global::Interop.BCrypt.BCryptOpenAlgorithmProviderFlags.None;
   30        if (isHmac)
   31        {
   33            bCryptOpenAlgorithmProviderFlags |= global::Interop.BCrypt.BCryptOpenAlgorithmProviderFlags.BCRYPT_ALG_HANDLE_HMAC_FLAG;
   34        }
   35        _hAlgorithm = global::Interop.BCrypt.BCryptAlgorithmCache.GetCachedBCryptAlgorithmHandle(hashAlgId, bCryptOpenAlgorithmProviderFlags, out 
_hashSize);
 
   37        global::Interop.BCrypt.NTSTATUS nTSTATUS = global::Interop.BCrypt.BCryptCreateHash(
_hAlgorithm, out phHash, 
IntPtr.
Zero, 0, 
key, (!(
key == 
null)) ? 
key.Length : 0, global::
Interop.BCrypt.BCryptCreateHashFlags.BCRYPT_HASH_REUSABLE_FLAG);
 
   38        switch (nTSTATUS)
   39        {
   40        case global::Interop.BCrypt.NTSTATUS.STATUS_INVALID_PARAMETER:
   43            break;
   44        default:
   45            phHash.Dispose();
   46            throw global::Interop.BCrypt.CreateCryptographicException(nTSTATUS);
   47        case global::Interop.BCrypt.NTSTATUS.STATUS_SUCCESS:
   50            break;
   51        }
   52    }
readonly SafeBCryptAlgorithmHandle _hAlgorithm
 
SafeBCryptHashHandle _hHash
 
static readonly IntPtr Zero