public Entry(string hashAlgorithmId, BCryptOpenAlgorithmProviderFlags flags, SafeBCryptAlgorithmHandle handle) : this() { HashAlgorithmId = hashAlgorithmId; Flags = flags; Handle = handle; }
public BCryptHashAlgorithm(CngAlgorithm algorithm, string implementation) { if (!BCryptNative.BCryptSupported) { throw new PlatformNotSupportedException(System.SR.GetString("Cryptography_PlatformNotSupported")); } this.m_algorithmHandle = BCryptNative.OpenAlgorithm(algorithm.Algorithm, implementation); this.Initialize(); }
public BCryptHashAlgorithm(CngAlgorithm algorithm, string implementation) { Contract.Requires(algorithm != null); Contract.Requires(!String.IsNullOrEmpty(implementation)); Contract.Ensures(m_algorithmHandle != null && !m_algorithmHandle.IsInvalid && !m_algorithmHandle.IsClosed); Contract.Ensures(m_hashHandle != null && !m_hashHandle.IsInvalid && !m_hashHandle.IsClosed); // Make sure CNG is supported on this platform if (!BCryptNative.BCryptSupported) { throw new PlatformNotSupportedException(SR.GetString(SR.Cryptography_PlatformNotSupported)); } if (_algorithmCache == null) { _algorithmCache = new BCryptAlgorithmHandleCache(); } m_algorithmHandle = _algorithmCache.GetCachedAlgorithmHandle(algorithm.Algorithm, implementation); Initialize(); }
internal static extern NTSTATUS BCryptOpenAlgorithmProvider(out SafeBCryptAlgorithmHandle phAlgorithm, string pszAlgId, string pszImplementation, BCryptOpenAlgorithmProviderFlags dwFlags);
internal static extern NTSTATUS BCryptCreateHash(SafeBCryptAlgorithmHandle hAlgorithm, out SafeBCryptHashHandle phHash, IntPtr pbHashObject, int cbHashObject, [In, Out] byte[] pbSecret, int cbSecret, BCryptCreateHashFlags dwFlags);
public void Dispose() { Contract.Ensures(m_hashHandle == null || m_hashHandle.IsClosed); Contract.Ensures(m_algorithmHandle == null || m_algorithmHandle.IsClosed); if (m_hashHandle != null) { m_hashHandle.Dispose(); } if (m_algorithmHandle != null) { m_algorithmHandle = null; } }