public static IEnumerable <CngKey> GetKeys(this CngProvider provider, CngKeyOpenOptions openOptions) { using (SafeNCryptProviderHandle providerHandle = provider.OpenProvider()) { foreach (var key in NCryptNative.EnumerateKeys(providerHandle, openOptions)) { yield return(CngKey.Open(key.pszName, provider)); } } }
public static IEnumerable <CngKey> GetKeys(this CngProvider provider, CngKeyOpenOptions openOptions) { using (SafeNCryptProviderHandle providerHandle = provider.OpenProvider()) { NCryptNative.NCryptKeyName[] keyNames = NCryptNative.EnumerateKeys(providerHandle, openOptions); CngKey[] keys = new CngKey[keyNames.Length]; for (int i = 0; i < keys.Length; ++i) { keys[i] = CngKey.Open(keyNames[i].pszName, provider); } return(keys); } }