internal static NCryptAlgorithmName[] EnumerateAlgorithms(SafeNCryptProviderHandle provider, NCryptAlgorithmOperations operations) { Debug.Assert(provider != null && !provider.IsClosed && !provider.IsInvalid, "Invalid provider"); uint algorithmCount = 0; SafeNCryptBuffer algorithmBuffer = null; try { // Ask CNG for the list of algorithms ErrorCode enumStatus = UnsafeNativeMethods.NCryptEnumAlgorithms(provider, operations, out algorithmCount, out algorithmBuffer, 0); if (enumStatus != ErrorCode.Success) { throw new CryptographicException((int)enumStatus); } // Copy the algorithm names into a managed array NCryptAlgorithmName[] algorithms = new NCryptAlgorithmName[algorithmCount]; for (uint i = 0; i < algorithms.Length; ++i) { algorithms[i] = algorithmBuffer.ReadArray <NCryptAlgorithmName>(i); } return(algorithms); } finally { if (algorithmBuffer != null) { algorithmBuffer.Dispose(); } } }
public static extern unsafe SECURITY_STATUS NCryptEnumAlgorithms( SafeProviderHandle hProvider, AlgorithmOperations dwAlgOperations, out int pdwAlgCount, out NCryptAlgorithmName* ppAlgList, NCryptEnumAlgorithmsFlags dwFlags = NCryptEnumAlgorithmsFlags.None);