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


C# Cryptography.DSA类代码示例

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


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

示例1: VerifySignature

		internal bool VerifySignature (DSA dsa) 
		{
			if (signatureOID != "1.2.840.10040.4.3")
				throw new CryptographicException ("Unsupported hash algorithm: " + signatureOID);
			DSASignatureDeformatter v = new DSASignatureDeformatter (dsa);
			// only SHA-1 is supported
			v.SetHashAlgorithm ("SHA1");
			ASN1 sign = new ASN1 (signature);
			if ((sign == null) || (sign.Count != 2))
				return false;
			// parts may be less than 20 bytes (i.e. first bytes were 0x00)
			byte[] part1 = sign [0].Value;
			byte[] part2 = sign [1].Value;
			byte[] sig = new byte [40];
			// parts may be less than 20 bytes (i.e. first bytes were 0x00)
			// parts may be more than 20 bytes (i.e. first byte > 0x80, negative)
			int s1 = System.Math.Max (0, part1.Length - 20);
			int e1 = System.Math.Max (0, 20 - part1.Length);
			Buffer.BlockCopy (part1, s1, sig, e1, part1.Length - s1);
			int s2 = System.Math.Max (0, part2.Length - 20);
			int e2 = System.Math.Max (20, 40 - part2.Length);
			Buffer.BlockCopy (part2, s2, sig, e2, part2.Length - s2);
			return v.VerifySignature (Hash, sig);
		}
开发者ID:carrie901,项目名称:mono,代码行数:24,代码来源:X509CRL.cs

示例2: DSAKeyValue

		public DSAKeyValue (DSA key) 
		{
			dsa = key;
		}
开发者ID:Xipas,项目名称:Symplified.Auth,代码行数:4,代码来源:DSAKeyValue.cs

示例3: DSASignatureDeformatterTest

	public DSASignatureDeformatterTest () 
	{
		// key generation is VERY long so one time is enough
		dsa = DSA.Create ();
		rsa = RSA.Create ();
	}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:6,代码来源:DSASignatureDeformatterTest.cs

示例4: SetKey

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

            _dsaKey = (DSA)key;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:DSASignatureFormatter.cs

示例5: DSASignatureFormatter

        public DSASignatureFormatter(AsymmetricAlgorithm key) : this()
        {
            if (key == null)
                throw new ArgumentNullException(nameof(key));

            _dsaKey = (DSA)key;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:DSASignatureFormatter.cs

示例6: SetKey

 public override void SetKey(AsymmetricAlgorithm key)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     this._dsaKey = (DSA) key;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:DSASignatureDeformatter.cs

示例7: DSASignatureDeformatter

 public DSASignatureDeformatter(AsymmetricAlgorithm key) : this()
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     this._dsaKey = (DSA) key;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:DSASignatureDeformatter.cs

示例8: SetUp

	public void SetUp () 
	{
		sig = new SignatureDescription();
		// key generation is VERY long so one time is enough
		if (dsa == null)
			dsa = DSA.Create ();
		if (rsa == null)
			rsa = RSA.Create ();
	}
开发者ID:sushihangover,项目名称:playscript,代码行数:9,代码来源:SignatureDescriptionTest.cs

示例9: SetUp

		public void SetUp () 
		{
			if (rsa == null) {
				rsa = RSA.Create ();
				rsa.ImportParameters (AllTests.GetRsaKey (true));
			}
			if (dsa == null)
				dsa = DSA.Create ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:RSAPKCS1SignatureFormatterTest.cs

示例10: SetKey

	// Set the key to use to compute the signature.
	public override void SetKey(AsymmetricAlgorithm key)
			{
				if(!(key is DSA))
				{
					throw new CryptographicException
						(_("Crypto_NeedsDSA"));
				}
				keyContainer = (DSA)key;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:10,代码来源:DSASignatureFormatter.cs

示例11: SetKey

		public override void SetKey (AsymmetricAlgorithm key)
		{
			if (key != null) {
				// this will throw a InvalidCastException if this isn't
				// a DSA keypair
				dsa = (DSA) key;
			}
			else
				throw new ArgumentNullException ("key");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:10,代码来源:DSASignatureDeformatter.cs

示例12: SetUp

		public void SetUp () 
		{
			shaSignature [0] = 0x51;
			md5Signature [0] = 0xB4;

			if (rsa == null)
				rsa = RSA.Create ();
			if (dsa == null)
				dsa = DSA.Create ();
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:10,代码来源:RSAPKCS1SignatureDeformatterTest.cs

示例13: make_pubkey

        /// <summary>
        ///     Create a public key block from a private key.
        /// </summary>
        /// <param name="privateKey">The <see cref="DSA" /> PrivateKey.</param>
        /// <returns>The <see cref="DSACryptoServiceProvider" /> PublicKey.</returns>
        public static DSACryptoServiceProvider make_pubkey(DSA privateKey)
        {
            var publicKey = new DSACryptoServiceProvider(1024);
            publicKey.ImportParameters(privateKey.ExportParameters(false));

            if (!publicKey.PublicOnly)
            {
                publicKey.Dispose();
                throw new Exception("PublicKey contains PrivateKey information, cancelling.");
            }

            return publicKey;
        }
开发者ID:eXcomm,项目名称:otr-1,代码行数:18,代码来源:BasePrivateKey.cs

示例14: SetKey

		public override void SetKey (AsymmetricAlgorithm key)
		{
			if (key != null) {
				// this will throw a InvalidCastException if this isn't
				// a DSA keypair
				dsa = (DSA) key;
			}
#if NET_2_0
			else
				throw new ArgumentNullException ("key");
#else
			// null is accepted in 1.0/1.1
#endif
		}
开发者ID:runefs,项目名称:Marvin,代码行数:14,代码来源:DSASignatureDeformatter.cs

示例15: Encode

			static public byte[] Encode (DSA dsa) 
			{
				DSAParameters param = dsa.ExportParameters (true);
				return ASN1Convert.FromUnsignedBigInteger (param.X).GetBytes ();
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:5,代码来源:PKCS8.cs


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