当前位置: 首页>>代码示例>>C#>>正文


C# AsymmetricAlgorithm类代码示例

本文整理汇总了C#中AsymmetricAlgorithm的典型用法代码示例。如果您正苦于以下问题:C# AsymmetricAlgorithm类的具体用法?C# AsymmetricAlgorithm怎么用?C# AsymmetricAlgorithm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AsymmetricAlgorithm类属于命名空间,在下文中一共展示了AsymmetricAlgorithm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetHashAlgorithmEnum

 /// <summary>
 /// Gets the hash algorithm for a given asymmetric algorithm.
 /// </summary>
 /// <param name="algorithm">The algorithm.</param>
 /// <returns>A hash algorithm.</returns>
 internal static HashAlgorithm GetHashAlgorithmEnum(AsymmetricAlgorithm algorithm)
 {
     switch (algorithm)
     {
         case AsymmetricAlgorithm.DsaSha1:
         case AsymmetricAlgorithm.RsaOaepSha1:
         case AsymmetricAlgorithm.RsaSignPkcs1Sha1:
         case AsymmetricAlgorithm.RsaSignPssSha1:
             return HashAlgorithm.Sha1;
         case AsymmetricAlgorithm.DsaSha256:
         case AsymmetricAlgorithm.RsaOaepSha256:
         case AsymmetricAlgorithm.EcdsaP256Sha256:
         case AsymmetricAlgorithm.RsaSignPkcs1Sha256:
         case AsymmetricAlgorithm.RsaSignPssSha256:
             return HashAlgorithm.Sha256;
         case AsymmetricAlgorithm.EcdsaP384Sha384:
         case AsymmetricAlgorithm.RsaOaepSha384:
         case AsymmetricAlgorithm.RsaSignPkcs1Sha384:
         case AsymmetricAlgorithm.RsaSignPssSha384:
             return HashAlgorithm.Sha384;
         case AsymmetricAlgorithm.EcdsaP521Sha512:
         case AsymmetricAlgorithm.RsaOaepSha512:
         case AsymmetricAlgorithm.RsaSignPkcs1Sha512:
         case AsymmetricAlgorithm.RsaSignPssSha512:
             return HashAlgorithm.Sha512;
         default:
             throw new NotSupportedException();
     }
 }
开发者ID:martijn00,项目名称:PCLCrypto,代码行数:34,代码来源:AsymmetricKeyAlgorithmProviderFactory.cs

示例2: SetKey

        public override void SetKey(AsymmetricAlgorithm key)
        {
            if (key == null)
                throw new ArgumentNullException(nameof(key));

            _rsaKey = (RSA)key;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:RSAOAEPKeyExchangeFormatter.cs

示例3: RSAOAEPKeyExchangeFormatter

        public RSAOAEPKeyExchangeFormatter(AsymmetricAlgorithm key)
        {
            if (key == null)
                throw new ArgumentNullException(nameof(key));

            _rsaKey = (RSA)key;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:RSAOAEPKeyExchangeFormatter.cs

示例4: OpenAlgorithm

        /// <inheritdoc />
        public IAsymmetricKeyAlgorithmProvider OpenAlgorithm(AsymmetricAlgorithm algorithm)
        {
            switch (algorithm)
            {
#if DESKTOP
                case AsymmetricAlgorithm.DsaSha1:
                case AsymmetricAlgorithm.DsaSha256:
                case AsymmetricAlgorithm.EcdsaP256Sha256:
                case AsymmetricAlgorithm.EcdsaP384Sha384:
                case AsymmetricAlgorithm.EcdsaP521Sha512:
                    return new CngAsymmetricKeyAlgorithmProvider(algorithm);
#endif
#if !SILVERLIGHT || WINDOWS_PHONE
                case AsymmetricAlgorithm.RsaOaepSha1:
                case AsymmetricAlgorithm.RsaOaepSha256:
                case AsymmetricAlgorithm.RsaOaepSha384:
                case AsymmetricAlgorithm.RsaOaepSha512:
                case AsymmetricAlgorithm.RsaPkcs1:
                case AsymmetricAlgorithm.RsaSignPkcs1Sha1:
                case AsymmetricAlgorithm.RsaSignPkcs1Sha256:
                case AsymmetricAlgorithm.RsaSignPkcs1Sha384:
                case AsymmetricAlgorithm.RsaSignPkcs1Sha512:
                case AsymmetricAlgorithm.RsaSignPssSha1:
                case AsymmetricAlgorithm.RsaSignPssSha256:
                case AsymmetricAlgorithm.RsaSignPssSha384:
                case AsymmetricAlgorithm.RsaSignPssSha512:
                    return new RsaAsymmetricKeyAlgorithmProvider(algorithm);
#endif
                default:
                    throw new NotSupportedException();
            }
        }
开发者ID:martijn00,项目名称:PCLCrypto,代码行数:33,代码来源:AsymmetricKeyAlgorithmProviderFactory.cs

示例5: LegalKeySizes

    public void LegalKeySizes(AsymmetricAlgorithm name, int minSize, int maxSize, int stepSize)
    {
        IAsymmetricKeyAlgorithmProvider provider = WinRTCrypto.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(name);
        var result = provider.LegalKeySizes;
        Assert.NotNull(result);
        Assert.NotEmpty(result);

        Action<int> attemptKeySize = size =>
        {
            provider.CreateKeyPair(size).Dispose();
        };

        var range = result.Single();
        Assert.Equal(minSize, range.MinSize);
        Assert.Equal(maxSize, range.MaxSize);
        Assert.Equal(stepSize, range.StepSize);
    }
开发者ID:martijn00,项目名称:PCLCrypto,代码行数:17,代码来源:AsymmetricKeyAlgorithmProviderTests.cs

示例6: HttpConnection

		public HttpConnection (Socket sock, EndPointListener epl, bool secure, X509Certificate2 cert, AsymmetricAlgorithm key)
		{
			this.sock = sock;
			this.epl = epl;
			this.secure = secure;
			this.key = key;
			if (secure == false) {
				stream = new NetworkStream (sock, false);
			} else {
				SslServerStream ssl_stream = new SslServerStream (new NetworkStream (sock, false), cert, false, true, false);
				ssl_stream.PrivateKeyCertSelectionDelegate += OnPVKSelection;
				ssl_stream.ClientCertValidationDelegate += OnClientCertificateValidation;
				stream = ssl_stream;
			}
			timer = new Timer (OnTimeout, null, Timeout.Infinite, Timeout.Infinite);
			Init ();
		}
开发者ID:GirlD,项目名称:mono,代码行数:17,代码来源:HttpConnection.cs

示例7: AsymmetricEncryption

    public void AsymmetricEncryption(AsymmetricAlgorithm algorithmName)
    {
        var algorithm = WinRTCrypto.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(algorithmName);

        foreach (var keySize in algorithm.LegalKeySizes.SelectMany(k => k))
        {
            try
            {
                this.logger.WriteLine($"Testing {algorithmName} with {keySize} bit key.");
                using (var key = algorithm.CreateKeyPair(keySize))
                {
                }

                break;
            }
            catch (ArgumentException)
            {
                // WinRT does not provide legal key sizes, and doesn't allow small RSA keys.
                // It throws ArgumentException in this case. We can remove the skip on ArgumentException
                // after we switch WinRT over to using BCrypt directly.
                this.logger.WriteLine("Key size rejected. Please fix LegalKeySizes to report key sizes that actually work.");
            }
        }
    }
开发者ID:martijn00,项目名称:PCLCrypto,代码行数:24,代码来源:PlatformSupport.cs

示例8: SetKey

 public abstract void SetKey(AsymmetricAlgorithm key);
开发者ID:geoffkizer,项目名称:corefx,代码行数:1,代码来源:AsymmetricKeyExchangeDeformatter.cs

示例9: RSAPKCS1KeyExchangeFormatter

 public RSAPKCS1KeyExchangeFormatter(AsymmetricAlgorithm key)
 {
 }
开发者ID:Pengfei-Gao,项目名称:source-Insight-3-for-centos7,代码行数:3,代码来源:RSAPKCS1KeyExchangeFormatter.cs

示例10: AsymmetricKeyAlgorithmProvider

 /// <summary>
 /// Initializes a new instance of the <see cref="AsymmetricKeyAlgorithmProvider"/> class.
 /// </summary>
 /// <param name="algorithm">The algorithm.</param>
 public AsymmetricKeyAlgorithmProvider(AsymmetricAlgorithm algorithm)
 {
     this.algorithm = algorithm;
     this.platform = Platform.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(GetAlgorithmName(algorithm));
 }
开发者ID:gitter-badger,项目名称:PCLCrypto,代码行数:9,代码来源:AsymmetricKeyAlgorithmProvider.cs

示例11: SetKey

 // Methods
 public virtual void SetKey(AsymmetricAlgorithm key)
 {
 }
开发者ID:Pengfei-Gao,项目名称:source-Insight-3-for-centos7,代码行数:4,代码来源:RSAPKCS1SignatureDeformatter.cs

示例12: LogVerifySignedInfo

        /// <summary>
        ///     Log the verification parameters when verifying the SignedInfo section of a signature using an
        ///     asymmetric key
        /// </summary>
        /// <param name="signedXml">SignedXml object doing the verification</param>
        /// <param name="key">key being used to verify the signed info</param>
        /// <param name="signatureDescription">type of signature description class used</param>
        /// <param name="hashAlgorithm">type of hash algorithm used</param>
        /// <param name="asymmetricSignatureDeformatter">type of signature deformatter used</param>
        /// <param name="actualHashValue">hash value of the signed info</param>
        /// <param name="signatureValue">raw signature value</param>
        internal static void LogVerifySignedInfo(SignedXml signedXml,
                                                 AsymmetricAlgorithm key,
                                                 SignatureDescription signatureDescription,
                                                 HashAlgorithm hashAlgorithm,
                                                 AsymmetricSignatureDeformatter asymmetricSignatureDeformatter,
                                                 byte[] actualHashValue,
                                                 byte[] signatureValue) {
            Debug.Assert(signedXml != null, "signedXml != null");
            Debug.Assert(signatureDescription != null, "signatureDescription != null");
            Debug.Assert(hashAlgorithm != null, "hashAlgorithm != null");
            Debug.Assert(asymmetricSignatureDeformatter != null, "asymmetricSignatureDeformatter != null");

            if (InformationLoggingEnabled) {
                string logMessage = String.Format(CultureInfo.InvariantCulture,
                                                  SecurityResources.GetResourceString("Log_VerifySignedInfoAsymmetric"),
                                                  GetKeyName(key),
                                                  signatureDescription.GetType().Name,
                                                  hashAlgorithm.GetType().Name,
                                                  asymmetricSignatureDeformatter.GetType().Name);
                WriteLine(signedXml,
                          TraceEventType.Information,
                          SignedXmlDebugEvent.VerifySignedInfo,
                          logMessage);
            }

            if (VerboseLoggingEnabled) {
                string hashLog = String.Format(CultureInfo.InvariantCulture,
                                               SecurityResources.GetResourceString("Log_ActualHashValue"),
                                               FormatBytes(actualHashValue));
                WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, hashLog);

                string signatureLog = String.Format(CultureInfo.InvariantCulture,
                                                    SecurityResources.GetResourceString("Log_RawSignatureValue"),
                                                    FormatBytes(signatureValue));
                WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, signatureLog);
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:48,代码来源:SignedXmlDebugLog.cs

示例13: CreateFormatter

        public override AsymmetricSignatureFormatter CreateFormatter(AsymmetricAlgorithm key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            RSAPKCS1SignatureFormatter formatter = new RSAPKCS1SignatureFormatter(key);
            formatter.SetHashAlgorithm("SHA256");
            return formatter;
        }
开发者ID:Mahendrasiddappa,项目名称:Binary_server,代码行数:11,代码来源:program-repro-misc-validation-and-canon.cs

示例14: DSASignatureDeformatter

	public DSASignatureDeformatter(AsymmetricAlgorithm key) {}
开发者ID:Pengfei-Gao,项目名称:source-Insight-3-for-centos7,代码行数:1,代码来源:DSASignatureDeformatter.cs

示例15: PublicKey

		internal PublicKey (Mono.Security.X509.X509Certificate certificate)
		{
			if (certificate.KeyAlgorithm == "1.2.840.113549.1.1.1") {
				_key = certificate.RSA;
			}
			else {
				_key = certificate.DSA;
			}

			_oid = new Oid (certificate.KeyAlgorithm);
			_keyValue = new AsnEncodedData (_oid, certificate.PublicKey);
			_params = new AsnEncodedData (_oid, certificate.KeyAlgorithmParameters);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:13,代码来源:PublicKey.cs


注:本文中的AsymmetricAlgorithm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。