コード例 #1
0
        /// <summary>
        /// Gets named registered Cryptographic Service Provider (CSP) or Key Storage Provider (KSP), its
        /// information and supported cryptographic algorithms.
        /// </summary>
        /// <param name="name">Cryptographic provider name.</param>
        /// <exception cref="PlatformNotSupportedException">
        /// Current platform does not support key storage providers (prior to Windows Vista).
        /// </exception>
        /// <returns>Specified provider information. Method returns null if provider is not found.</returns>
        public static CspProviderInfo GetProviderInfo(String name)
        {
            if (!CryptographyUtils.TestCNGCompat())
            {
                throw new PlatformNotSupportedException();
            }
            var providers = new CCspInformations();

            providers.AddAvailableCsps();
            try {
                ICspInformation provider = providers.ItemByName[name];
                return(new CspProviderInfo(provider));
            } catch {
                return(null);
            }
        }
コード例 #2
0
ファイル: CspObject.cs プロジェクト: njmube/pkix.net
 internal CspObject(ICspInformation csp) {
     Name = csp.Name;
     Type = (ProviderTypeEnum)csp.Type;
     //Algorithms = new ProviderAlgorithm(csp.CspAlgorithms);
     IsHardware = csp.IsHardwareDevice;
     IsSoftware = csp.IsSoftwareDevice;
     IsRemovable = csp.IsRemovable;
     IsSmartCard = csp.IsSmartCard;
     IsLegacy = csp.LegacyCsp;
     HardwareRNG = csp.HasHardwareRandomNumberGenerator;
     KeyContainerLength = csp.MaxKeyContainerNameLength;
     KeySpec = (X509KeySpecFlags)csp.KeySpec;
     Version = csp.Version;
     IsValid = csp.Valid;
     Algorithms = (from ICspAlgorithm alg in csp.CspAlgorithms select new ProviderAlgorithm(alg)).ToArray();
 }
コード例 #3
0
 internal CspProviderInfo(ICspInformation csp)
 {
     Name               = csp.Name;
     Type               = (CspProviderType)csp.Type;
     IsHardware         = csp.IsHardwareDevice;
     IsSoftware         = csp.IsSoftwareDevice;
     IsRemovable        = csp.IsRemovable;
     IsSmartCard        = csp.IsSmartCard;
     IsLegacy           = csp.LegacyCsp;
     HardwareRNG        = csp.HasHardwareRandomNumberGenerator;
     KeyContainerLength = csp.MaxKeyContainerNameLength;
     KeySpec            = (X509KeySpecFlags)csp.KeySpec;
     Version            = csp.Version;
     IsValid            = csp.Valid;
     _algorithms.AddRange(from ICspAlgorithm alg in csp.CspAlgorithms select new CspProviderAlgorithmInfo(alg));
     CryptographyUtils.ReleaseCom(csp);
 }