internal static SafeBCryptAlgorithmHandle OpenAlgorithm(string algorithm, string implementation, AlgorithmProviderOptions options) { Debug.Assert(!String.IsNullOrEmpty(algorithm), "!String.IsNullOrEmpty(algorithm)"); Debug.Assert(!String.IsNullOrEmpty(implementation), "!String.IsNullOrEmpty(implementation)"); SafeBCryptAlgorithmHandle algorithmHandle = null; ErrorCode error = UnsafeNativeMethods.BCryptOpenAlgorithmProvider(out algorithmHandle, algorithm, implementation, options); if (error != ErrorCode.Success) { throw new CryptographicException((int)error); } return(algorithmHandle); }
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa375377(v=vs.85).aspx internal static extern ErrorCode BCryptCloseAlgorithmProvider(IntPtr hAlgorithm, AlgorithmProviderOptions dwFlags);
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa375479(v=vs.85).aspx internal static extern ErrorCode BCryptOpenAlgorithmProvider( [Out] out BCryptAlgorithmHandle phAlgorithm, [MarshalAs(UnmanagedType.LPWStr)] string pszAlgId, [MarshalAs(UnmanagedType.LPWStr)] string pszImplementation, AlgorithmProviderOptions dwFlags);
internal static extern ErrorCode BCryptOpenAlgorithmProvider([Out] out SafeBCryptAlgorithmHandle phAlgorithm, [MarshalAs(UnmanagedType.LPWStr)] string pszAlgId, [MarshalAs(UnmanagedType.LPWStr)] string pszImplementation, AlgorithmProviderOptions dwFlags);