當前位置: 首頁>>代碼示例>>C#>>正文


C# AsymmetricKeyParameter類代碼示例

本文整理匯總了C#中AsymmetricKeyParameter的典型用法代碼示例。如果您正苦於以下問題:C# AsymmetricKeyParameter類的具體用法?C# AsymmetricKeyParameter怎麽用?C# AsymmetricKeyParameter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AsymmetricKeyParameter類屬於命名空間,在下文中一共展示了AsymmetricKeyParameter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DefaultTlsAgreementCredentials

        public DefaultTlsAgreementCredentials(Certificate certificate, AsymmetricKeyParameter privateKey)
        {
            if (certificate == null)
                throw new ArgumentNullException("certificate");
            if (certificate.IsEmpty)
                throw new ArgumentException("cannot be empty", "certificate");
            if (privateKey == null)
                throw new ArgumentNullException("privateKey");
            if (!privateKey.IsPrivate)
                throw new ArgumentException("must be private", "privateKey");

            if (privateKey is DHPrivateKeyParameters)
            {
                mBasicAgreement = new DHBasicAgreement();
                mTruncateAgreement = true;
            }
            else if (privateKey is ECPrivateKeyParameters)
            {
                mBasicAgreement = new ECDHBasicAgreement();
                mTruncateAgreement = false;
            }
            else
            {
                throw new ArgumentException("type not supported: " + privateKey.GetType().FullName, "privateKey");
            }

            this.mCertificate = certificate;
            this.mPrivateKey = privateKey;
        }
開發者ID:ALange,項目名稱:OutlookPrivacyPlugin,代碼行數:29,代碼來源:DefaultTlsAgreementCredentials.cs

示例2: CalculateRawSignature

		public virtual byte[] CalculateRawSignature(SecureRandom random,
			AsymmetricKeyParameter privateKey, byte[] md5andsha1)
		{
			ISigner s = MakeSigner(new NullDigest(), true, new ParametersWithRandom(privateKey, random));
			s.BlockUpdate(md5andsha1, 0, md5andsha1.Length);
			return s.GenerateSignature();
		}
開發者ID:Xanagandr,項目名稱:DisaOpenSource,代碼行數:7,代碼來源:TlsRsaSigner.cs

示例3: VerifyRawSignature

		public virtual bool VerifyRawSignature(byte[] sigBytes, AsymmetricKeyParameter publicKey,
			byte[] md5andsha1)
		{
			ISigner s = MakeSigner(new NullDigest(), false, publicKey);
			s.BlockUpdate(md5andsha1, 0, md5andsha1.Length);
			return s.VerifySignature(sigBytes);
		}
開發者ID:Xanagandr,項目名稱:DisaOpenSource,代碼行數:7,代碼來源:TlsRsaSigner.cs

示例4: VerifyRawSignature

		public bool VerifyRawSignature(byte[] sigBytes, AsymmetricKeyParameter publicKey, byte[] md5andsha1)
		{
			ISigner s = MakeSigner(new NullDigest(), false, publicKey);
			// Note: Only use the SHA1 part of the hash
			s.BlockUpdate(md5andsha1, 16, 20);
			return s.VerifySignature(sigBytes);
		}
開發者ID:ktw,項目名稱:OutlookPrivacyPlugin,代碼行數:7,代碼來源:TlsDsaSigner.cs

示例5: VerifyRawSignature

 public override bool VerifyRawSignature(SignatureAndHashAlgorithm algorithm, byte[] sigBytes,
     AsymmetricKeyParameter publicKey, byte[] hash)
 {
     ISigner signer = MakeSigner(algorithm, true, false, publicKey);
     signer.BlockUpdate(hash, 0, hash.Length);
     return signer.VerifySignature(sigBytes);
 }
開發者ID:JohnMalmsteen,項目名稱:mobile-apps-tower-defense,代碼行數:7,代碼來源:TlsRsaSigner.cs

示例6: GenerateRawSignature

 public virtual byte[] GenerateRawSignature(SecureRandom random,
     AsymmetricKeyParameter privateKey, byte[] md5AndSha1)
 {
     IAsymmetricBlockCipher engine = CreateRsaImpl();
     engine.Init(true, new ParametersWithRandom(privateKey, random));
     return engine.ProcessBlock(md5AndSha1, 0, md5AndSha1.Length);
 }
開發者ID:htlp,項目名稱:itextsharp,代碼行數:7,代碼來源:TlsRsaSigner.cs

示例7: VerifyRawSignature

 public virtual bool VerifyRawSignature(byte[] sigBytes, AsymmetricKeyParameter publicKey,
     byte[] md5AndSha1)
 {
     IAsymmetricBlockCipher engine = CreateRsaImpl();
     engine.Init(false, publicKey);
     byte[] signed = engine.ProcessBlock(sigBytes, 0, sigBytes.Length);
     return Arrays.ConstantTimeAreEqual(signed, md5AndSha1);
 }
開發者ID:htlp,項目名稱:itextsharp,代碼行數:8,代碼來源:TlsRsaSigner.cs

示例8: CalculateRawSignature

 public virtual byte[] CalculateRawSignature(SecureRandom random,
     AsymmetricKeyParameter privateKey, byte[] md5andsha1)
 {
     ISigner sig = new GenericSigner(new Pkcs1Encoding(new RsaBlindedEngine()), new NullDigest());
     sig.Init(true, new ParametersWithRandom(privateKey, random));
     sig.BlockUpdate(md5andsha1, 0, md5andsha1.Length);
     return sig.GenerateSignature();
 }
開發者ID:karino2,項目名稱:wikipediaconv,代碼行數:8,代碼來源:TlsRsaSigner.cs

示例9: CalculateRawSignature

		public virtual byte[] CalculateRawSignature(SecureRandom random,
			AsymmetricKeyParameter privateKey, byte[] md5andsha1)
		{
			ISigner s = MakeSigner(new NullDigest(), true, new ParametersWithRandom(privateKey, random));
			// Note: Only use the SHA1 part of the hash
			s.BlockUpdate(md5andsha1, 16, 20);
			return s.GenerateSignature();
		}
開發者ID:ktw,項目名稱:OutlookPrivacyPlugin,代碼行數:8,代碼來源:TlsDsaSigner.cs

示例10: GenerateRawSignature

 public override byte[] GenerateRawSignature(SignatureAndHashAlgorithm algorithm,
     AsymmetricKeyParameter privateKey, byte[] hash)
 {
     ISigner signer = MakeSigner(algorithm, true, true,
         new ParametersWithRandom(privateKey, this.mContext.SecureRandom));
     signer.BlockUpdate(hash, 0, hash.Length);
     return signer.GenerateSignature();
 }
開發者ID:JohnMalmsteen,項目名稱:mobile-apps-tower-defense,代碼行數:8,代碼來源:TlsRsaSigner.cs

示例11: GenerateAgreement

        /// <exception cref="IOException"></exception>
        public override byte[] GenerateAgreement(AsymmetricKeyParameter peerPublicKey)
        {
            mBasicAgreement.Init(mPrivateKey);
            BigInteger agreementValue = mBasicAgreement.CalculateAgreement(peerPublicKey);

            if (mTruncateAgreement)
            {
                return BigIntegers.AsUnsignedByteArray(agreementValue);
            }

            return BigIntegers.AsUnsignedByteArray(mBasicAgreement.GetFieldSize(), agreementValue);
        }
開發者ID:ALange,項目名稱:OutlookPrivacyPlugin,代碼行數:13,代碼來源:DefaultTlsAgreementCredentials.cs

示例12: GenerateAgreement

        public virtual byte[] GenerateAgreement(AsymmetricKeyParameter serverPublicKey)
        {
            basicAgreement.Init(clientPrivateKey);
            BigInteger agreementValue = basicAgreement.CalculateAgreement(serverPublicKey);

            if (truncateAgreement)
            {
                return BigIntegers.AsUnsignedByteArray(agreementValue);
            }

            return BigIntegers.AsUnsignedByteArray(basicAgreement.GetFieldSize(), agreementValue);
        }
開發者ID:MBrekhof,項目名稱:pleiobox-clients,代碼行數:12,代碼來源:DefaultTlsAgreementCredentials.cs

示例13: VerifyRawSignature

 public override bool VerifyRawSignature(SignatureAndHashAlgorithm algorithm, byte[] sigBytes,
     AsymmetricKeyParameter publicKey, byte[] hash)
 {
     ISigner signer = MakeSigner(algorithm, true, false, publicKey);
     if (algorithm == null)
     {
         // Note: Only use the SHA1 part of the (MD5/SHA1) hash
         signer.BlockUpdate(hash, 16, 20);
     }
     else
     {
         signer.BlockUpdate(hash, 0, hash.Length);
     }
     return signer.VerifySignature(sigBytes);
 }
開發者ID:andibadra,項目名稱:bc-csharp,代碼行數:15,代碼來源:TlsDsaSigner.cs

示例14: GenerateRawSignature

 public override byte[] GenerateRawSignature(SignatureAndHashAlgorithm algorithm,
     AsymmetricKeyParameter privateKey, byte[] hash)
 {
     ISigner signer = MakeSigner(algorithm, true, true,
         new ParametersWithRandom(privateKey, this.mContext.SecureRandom));
     if (algorithm == null)
     {
         // Note: Only use the SHA1 part of the (MD5/SHA1) hash
         signer.BlockUpdate(hash, 16, 20);
     }
     else
     {
         signer.BlockUpdate(hash, 0, hash.Length);
     }
     return signer.GenerateSignature();
 }
開發者ID:andibadra,項目名稱:bc-csharp,代碼行數:16,代碼來源:TlsDsaSigner.cs

示例15: DefaultTlsSignerCredentials

        public DefaultTlsSignerCredentials(TlsClientContext context,
            Certificate clientCertificate, AsymmetricKeyParameter clientPrivateKey)
        {
            if (clientCertificate == null)
            {
                throw new ArgumentNullException("clientCertificate");
            }
            if (clientCertificate.Length == 0)
            {
                throw new ArgumentException("cannot be empty", "clientCertificate");
            }
            if (clientPrivateKey == null)
            {
                throw new ArgumentNullException("clientPrivateKey");
            }
            if (!clientPrivateKey.IsPrivate)
            {
                throw new ArgumentException("must be private", "clientPrivateKey");
            }

            if (clientPrivateKey is RsaKeyParameters)
            {
                clientSigner = new TlsRsaSigner();
            }
            else if (clientPrivateKey is DsaPrivateKeyParameters)
            {
                clientSigner = new TlsDssSigner();
            }
            else if (clientPrivateKey is ECPrivateKeyParameters)
            {
                clientSigner = new TlsECDsaSigner();
            }
            else
            {
                throw new ArgumentException("type not supported: "
                    + clientPrivateKey.GetType().FullName, "clientPrivateKey");
            }

            this.context = context;
            this.clientCert = clientCertificate;
            this.clientPrivateKey = clientPrivateKey;
        }
開發者ID:MBrekhof,項目名稱:pleiobox-clients,代碼行數:42,代碼來源:DefaultTlsSignerCredentials.cs


注:本文中的AsymmetricKeyParameter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。