static CspCNGCollection m_enumcngprovs() { UInt32 pImplCount = 0; IntPtr ppImplList = IntPtr.Zero; IntPtr phProvider = IntPtr.Zero; StringBuilder SB = new StringBuilder(); Hashtable interfaces = get_interfaces(); CspCNGCollection csps = new CspCNGCollection(); UInt32 retn = nCrypt.NCryptEnumStorageProviders(ref pImplCount, ref ppImplList, 0); if (retn != 0) { throw new Win32Exception(unchecked ((Int32)retn)); } IntPtr pvInput = ppImplList; for (Int32 index = 0; index < pImplCount; index++) { nCrypt2.NCryptProviderName Name = (nCrypt2.NCryptProviderName)Marshal.PtrToStructure(ppImplList, typeof(nCrypt2.NCryptProviderName)); ppImplList = (IntPtr)((UInt64)ppImplList + (UInt32)Marshal.SizeOf(typeof(nCrypt2.NCryptProviderName))); SB.Append(Name.pszName + ","); } String[] names = SB.ToString().Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); nCrypt.NCryptFreeBuffer(pvInput); foreach (String pszProviderName in names) { ALG_ID_CNGCollection algs = new ALG_ID_CNGCollection(); retn = nCrypt.NCryptOpenStorageProvider(ref phProvider, pszProviderName, 0); if (retn == 0) { Int32 pdwAlgCount = 0; IntPtr ppAlgList = IntPtr.Zero; retn = nCrypt.NCryptEnumAlgorithms(phProvider, 0, ref pdwAlgCount, ref ppAlgList, 0); if (retn != 0) { throw new Win32Exception(unchecked ((Int32)retn)); } pvInput = ppAlgList; for (Int32 index = 0; index < pdwAlgCount; index++) { nCrypt2.NCryptAlgorithmName AlgId = (nCrypt2.NCryptAlgorithmName)Marshal.PtrToStructure(ppAlgList, typeof(nCrypt2.NCryptAlgorithmName)); algs.Add(get_cngalgparams(AlgId, interfaces)); ppAlgList = (IntPtr)((UInt64)ppAlgList + (UInt32)Marshal.SizeOf(typeof(nCrypt2.NCryptAlgorithmName))); } nCrypt.NCryptFreeBuffer(pvInput); } csps.Add(new CspCNG(pszProviderName, String.Empty, algs)); } return(csps); }
internal CspCNGCollectionEnumerator(CspCNGCollection entries) { m_entries = entries; m_current = -1; }