Esempio n. 1
0
 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));
         }
     }
 }
Esempio n. 2
0
 public static IEnumerable <CngAlgorithm> GetSupportedAlgorithms(this CngProvider provider,
                                                                 NCryptAlgorithmOperations operations)
 {
     using (SafeNCryptProviderHandle providerHandle = provider.OpenProvider())
     {
         foreach (NCryptNative.NCryptAlgorithmName algorithm in NCryptNative.EnumerateAlgorithms(providerHandle, operations))
         {
             yield return(new CngAlgorithm(algorithm.pszName));
         }
     }
 }
        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);
            }
        }
        public static IEnumerable <CngAlgorithm> GetSupportedAlgorithms(this CngProvider provider,
                                                                        NCryptAlgorithmOperations operations)
        {
            using (SafeNCryptProviderHandle providerHandle = provider.OpenProvider())
            {
                NCryptNative.NCryptAlgorithmName[] algorithmNames = NCryptNative.EnumerateAlgorithms(providerHandle, operations);
                CngAlgorithm[] algorithms = new CngAlgorithm[algorithmNames.Length];

                for (int i = 0; i < algorithmNames.Length; ++i)
                {
                    algorithms[i] = new CngAlgorithm(algorithmNames[i].pszName);
                }

                return(algorithms);
            }
        }