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


C# Cryptography.DSAParameters类代码示例

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


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

示例1: DSASignHash

        /// <summary>
        /// 数字签名处理.
        /// </summary>
        /// <param name="HashToSign"></param>
        /// <param name="DSAKeyInfo"></param>
        /// <param name="HashAlg"></param>
        /// <returns></returns>
        public static byte[] DSASignHash(byte[] HashToSign, DSAParameters DSAKeyInfo, string HashAlg)
        {
            try
            {
                //Create a new instance of DSACryptoServiceProvider.
                DSACryptoServiceProvider DSA = new DSACryptoServiceProvider();

                //Import the key information.
                DSA.ImportParameters(DSAKeyInfo);

                //Create an DSASignatureFormatter object and pass it the
                //DSACryptoServiceProvider to transfer the private key.
                DSASignatureFormatter DSAFormatter = new DSASignatureFormatter(DSA);

                //Set the hash algorithm to the passed value.
                DSAFormatter.SetHashAlgorithm(HashAlg);

                //Create a signature for HashValue and return it.
                return DSAFormatter.CreateSignature(HashToSign);
            }
            catch (CryptographicException e)
            {
                Console.WriteLine(e.Message);

                return null;
            }
        }
开发者ID:mahuidong,项目名称:my-csharp-sample,代码行数:34,代码来源:DSACSPSample.cs

示例2: DSASignHash

        //-------------------------------------------------------------------------
        // Шифруем закрытым ключем Хеш-таблицу
        public static byte[] DSASignHash(byte[] HashToSign, DSAParameters DSAKeyInfo,
        string HashAlg)
        {
            byte[] sig = null;

            try
            {
            // Создаем новыый экземпляр класса
            using (DSACryptoServiceProvider DSA = new DSACryptoServiceProvider())
            {
                // Импортируем ключи, в данном случае закрытый ключ
                DSA.ImportParameters(DSAKeyInfo);

                // Создаем объект класса DSASignatureFormatter и передаем ему DSACryptoServiceProvider закрытый ключ
                DSASignatureFormatter DSAFormatter = new DSASignatureFormatter(DSA);

                // Устанавливаем алгоритм шифрования
                DSAFormatter.SetHashAlgorithm(HashAlg);

                // Создаем подпись для хеш-таблицы и возвращаем ее значение
                sig = DSAFormatter.CreateSignature(HashToSign);
            }
            }
            catch (CryptographicException e)
            {
            Console.WriteLine(e.Message);
            }

            return sig;
        }
开发者ID:1v1expert,项目名称:DSA,代码行数:32,代码来源:Program.cs

示例3: GetSignature

        /// <summary>
        /// Gets the signature.
        /// </summary>
        /// <param name="key">The key data bytes.</param>
        /// <returns></returns>
        public override byte[] GetSignature(IEnumerable<byte> key)
        {
            var data = key.ToArray();
            //using (var sha1 = new Renci.SshNet.Security.Cryptography.SHA1Hash())
            using (var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
            {
                using (var cs = new System.Security.Cryptography.CryptoStream(System.IO.Stream.Null, sha1, System.Security.Cryptography.CryptoStreamMode.Write))
                {
                    cs.Write(data, 0, data.Length);
                }

                var dsaKeyInfo = new System.Security.Cryptography.DSAParameters();

                dsaKeyInfo.X = this._privateKey.TrimLeadingZero().ToArray();
                dsaKeyInfo.P = this._p.TrimLeadingZero().ToArray();
                dsaKeyInfo.Q = this._q.TrimLeadingZero().ToArray();
                dsaKeyInfo.G = this._g.TrimLeadingZero().ToArray();

                using (var DSA = new System.Security.Cryptography.DSACryptoServiceProvider())
                {
                    DSA.ImportParameters(dsaKeyInfo);
                    var DSAFormatter = new DSASignatureFormatter(DSA);
                    DSAFormatter.SetHashAlgorithm("SHA1");

                    var signature = DSAFormatter.CreateSignature(sha1);

                    return new SignatureKeyData
                    {
                        AlgorithmName = this.Name,
                        Signature = signature,
                    }.GetBytes().ToArray();
                }
            }
        }
开发者ID:vitaly-rudenya,项目名称:couchbase-net-client,代码行数:39,代码来源:CryptoPrivateKeyDss.cs

示例4: DigitalSignatureAlgorithm_compare_parameters_generation_with_original_Pidgin_OffTheRecord_data

        public void DigitalSignatureAlgorithm_compare_parameters_generation_with_original_Pidgin_OffTheRecord_data()
        {
            // Arrange
            const string p =
                "AEC0FBB4CEA96EF8BDD0E91D1BA2F6641B6535CBDA8D739CC2898FE7B472865AB60AD2B1BAA2368603C7439E63BC2F2F33D422E70173F70DB738DF5979EAEAF3CAC343CBF711960E16786703C80DF0734D8330DC955DA84B521DAB5C729202F1244D805E6BF2CC7A7142CAD74BE5FFFC14B9CCB6CABB7DB10A8F2DDB4E82383F";
            const string q = "A2A2BC20E2D94C44C63608479C79068CE7914EF3";
            const string g =
                "69B9FC5A73F3F6EA3A86F8FA3A203F42DACDC3A1516002025E5765A9DCB975F348ACBBA2116230E19CE3FC5256546FD168A2940809BDA8655771967E9CD90AF44D2C20F97F448494213A775E23607F33C255A9A74E2A5FC7B4D50BAD024D7EFAC282E67332D51A5F69239011FE058D7E75E97A788FBD5B3BAD796B2C6D8C6C3E";
            const string y =
                "9931144F3059D92FCB2AAC03B130DAE43ED1EF30AA2F0E670C3974C3E80C7110D1A60210F92479D7F640C20E1F16E01B4A72FF8D45443B01EBE2D67DF49791CAC6191B159AC39446EB6A2EA597B6B678CC3157AECEAB12A804CF0772068A942EC819138EDD6005620FE746522FF408BBC8211ABD9D6016AA46EEC87F3F04CFA4";
            const string x = "48BFDA215C31A9F0B226B3DB11F862450A0F30DA"; /* private key */

            // Act
            var param = new DSAParameters();
            param.X = General.StringToByteArray(x);
            param.P = General.StringToByteArray(p);
            param.Q = General.StringToByteArray(q);
            param.G = General.StringToByteArray(g);
            param.Y = General.StringToByteArray(y);

            var dsa = new DSACryptoServiceProvider(1024);
            dsa.ImportParameters(param);
            DSAParameters output = dsa.ExportParameters(true);

            // Assert
            param.X.SequenceEqual(output.X).Should().BeTrue();
            param.P.SequenceEqual(output.P).Should().BeTrue();
            param.Q.SequenceEqual(output.Q).Should().BeTrue();
            param.G.SequenceEqual(output.G).Should().BeTrue();
            param.Y.SequenceEqual(output.Y).Should().BeTrue();
        }
开发者ID:eXcomm,项目名称:otr-1,代码行数:31,代码来源:DigitalSignatureAlgorithmTests.cs

示例5: DSAVerifyHash

        private static bool DSAVerifyHash(byte[] HashValue, byte[] SignedHashValue, DSAParameters publickeyinfo, string HashAlg)
        {
            bool verified = false;

            try
            {
                //Create a new instance of DSACryptoServiceProvider
                using(DSACryptoServiceProvider dsa = new DSACryptoServiceProvider())
                {
                    //Import the key information
                    dsa.ImportParameters(publickeyinfo);

                    // Create an DSASignatureDeformatter object and pass it the DSACryptoServiceProvider to transfer the private key.
                    //DSASignatureDeformatter dsaDeformatter = new DSASignatureDeformatter(dsa);

                    //Set the hash algorithm to the passed value.
                    //dsaDeformatter.SetHashAlgorithm(HashAlg);

                    //Verify signature and return the result
                               //Verify hashed files                        //Verify hashed data 
                    verified = dsa.VerifyData(HashValue, SignedHashValue); //dsaDeformatter.VerifySignature(HashValue, SignedHashValue);

                }
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return verified;
        }
开发者ID:Rafael-Miceli,项目名称:ProjectStudiesCert70-536,代码行数:31,代码来源:Program.cs

示例6: FromXmlString

		public override void FromXmlString (string xmlString) 
		{
			if (xmlString == null)
				throw new ArgumentNullException ("xmlString");
			
			DSAParameters dsaParams = new DSAParameters ();
			try {
				dsaParams.P = GetNamedParam (xmlString, "P");
				dsaParams.Q = GetNamedParam (xmlString, "Q");
				dsaParams.G = GetNamedParam (xmlString, "G");
				dsaParams.J = GetNamedParam (xmlString, "J");
				dsaParams.Y = GetNamedParam (xmlString, "Y");
				dsaParams.X = GetNamedParam (xmlString, "X");
				dsaParams.Seed = GetNamedParam (xmlString, "Seed");
				byte[] counter = GetNamedParam (xmlString, "PgenCounter");
				if (counter != null) {
					byte[] counter4b = new byte [4]; // always 4 bytes
					Buffer.BlockCopy (counter, 0, counter4b, 0, counter.Length);
					dsaParams.Counter = BitConverterLE.ToInt32 (counter4b, 0);
				}
				ImportParameters (dsaParams);
			}
			catch {
				ZeroizePrivateKey (dsaParams);
				throw;
			}
			finally	{
				ZeroizePrivateKey (dsaParams);
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:30,代码来源:DSA.cs

示例7: DSAVerifyHash

        //-------------------------------------------------------------------
        public static bool DSAVerifyHash(byte[] HashValue, byte[] SignedHashValue,
        DSAParameters DSAKeyInfo, string HashAlg)
        {
            bool verified = false;

            try
            {
            // Создаем новый экземпляр класса DSACryptoServiceProvider.
            using (DSACryptoServiceProvider DSA = new DSACryptoServiceProvider())
            {
                // Импортируем ключи
                DSA.ImportParameters(DSAKeyInfo);

                //Создаем объект класса DSASignatureFormatter и передаем ему DSACryptoServiceProvider закрытый ключ
                DSASignatureDeformatter DSADeformatter = new DSASignatureDeformatter(DSA);

                // Устанавливаем алгоритм шифрования
                DSADeformatter.SetHashAlgorithm(HashAlg);

                // Сверяем подписи и возвращаем результат
                verified = DSADeformatter.VerifySignature(HashValue, SignedHashValue);
            }
            }
            catch (CryptographicException e)
            {
            Console.WriteLine(e.Message);
            }

            return verified;
        }
开发者ID:1v1expert,项目名称:DSA,代码行数:31,代码来源:Program.cs

示例8: ImportParameters

            public override void ImportParameters(DSAParameters parameters)
            {
                if (parameters.P == null || parameters.Q == null || parameters.G == null || parameters.Y == null)
                    throw new ArgumentException(SR.Cryptography_InvalidDsaParameters_MissingFields);

                // J is not required and is not even used on CNG blobs. It should however be less than P (J == (P-1) / Q). This validation check
                // is just to maintain parity with DSACryptoServiceProvider, which also performs this check.
                if (parameters.J != null && parameters.J.Length >= parameters.P.Length)
                    throw new ArgumentException(SR.Cryptography_InvalidDsaParameters_MismatchedPJ);

                bool hasPrivateKey = parameters.X != null;

                int keySizeInBytes = parameters.P.Length;
                int keySizeInBits = keySizeInBytes * 8;

                if (parameters.G.Length != keySizeInBytes || parameters.Y.Length != keySizeInBytes)
                    throw new ArgumentException(SR.Cryptography_InvalidDsaParameters_MismatchedPGY);

                if (hasPrivateKey && parameters.X.Length != parameters.Q.Length)
                    throw new ArgumentException(SR.Cryptography_InvalidDsaParameters_MismatchedQX);

                byte[] blob;
                if (keySizeInBits <= MaxV1KeySize)
                {
                    GenerateV1DsaBlob(out blob, parameters, keySizeInBytes, hasPrivateKey);
                }
                else
                {
                    GenerateV2DsaBlob(out blob, parameters, keySizeInBytes, hasPrivateKey);
                }

                ImportKeyBlob(blob, hasPrivateKey);
            }
开发者ID:geoffkizer,项目名称:corefx,代码行数:33,代码来源:DSACng.ImportExport.cs

示例9: FromXmlString

 public override void FromXmlString(string xmlString)
 {
     if (xmlString == null)
     {
         throw new ArgumentNullException("xmlString");
     }
     DSAParameters parameters = new DSAParameters();
     SecurityElement topElement = new Parser(xmlString).GetTopElement();
     string inputBuffer = topElement.SearchForTextOfLocalName("P");
     if (inputBuffer == null)
     {
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString", new object[] { "DSA", "P" }));
     }
     parameters.P = Convert.FromBase64String(Utils.DiscardWhiteSpaces(inputBuffer));
     string str2 = topElement.SearchForTextOfLocalName("Q");
     if (str2 == null)
     {
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString", new object[] { "DSA", "Q" }));
     }
     parameters.Q = Convert.FromBase64String(Utils.DiscardWhiteSpaces(str2));
     string str3 = topElement.SearchForTextOfLocalName("G");
     if (str3 == null)
     {
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString", new object[] { "DSA", "G" }));
     }
     parameters.G = Convert.FromBase64String(Utils.DiscardWhiteSpaces(str3));
     string str4 = topElement.SearchForTextOfLocalName("Y");
     if (str4 == null)
     {
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString", new object[] { "DSA", "Y" }));
     }
     parameters.Y = Convert.FromBase64String(Utils.DiscardWhiteSpaces(str4));
     string str5 = topElement.SearchForTextOfLocalName("J");
     if (str5 != null)
     {
         parameters.J = Convert.FromBase64String(Utils.DiscardWhiteSpaces(str5));
     }
     string str6 = topElement.SearchForTextOfLocalName("X");
     if (str6 != null)
     {
         parameters.X = Convert.FromBase64String(Utils.DiscardWhiteSpaces(str6));
     }
     string str7 = topElement.SearchForTextOfLocalName("Seed");
     string str8 = topElement.SearchForTextOfLocalName("PgenCounter");
     if ((str7 != null) && (str8 != null))
     {
         parameters.Seed = Convert.FromBase64String(Utils.DiscardWhiteSpaces(str7));
         parameters.Counter = Utils.ConvertByteArrayToInt(Convert.FromBase64String(Utils.DiscardWhiteSpaces(str8)));
     }
     else if ((str7 != null) || (str8 != null))
     {
         if (str7 == null)
         {
             throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString", new object[] { "DSA", "Seed" }));
         }
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString", new object[] { "DSA", "PgenCounter" }));
     }
     this.ImportParameters(parameters);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:59,代码来源:DSA.cs

示例10: FromXmlString

        // We can provide a default implementation of FromXmlString because we require 
        // every DSA implementation to implement ImportParameters
        // All we have to do here is parse the XML. 
 
        public override void FromXmlString(String xmlString) {
            if (xmlString == null) throw new ArgumentNullException("xmlString"); 
            Contract.EndContractBlock();
            DSAParameters dsaParams = new DSAParameters();
            Parser p = new Parser(xmlString);
            SecurityElement topElement = p.GetTopElement(); 

            // P is always present 
            String pString = topElement.SearchForTextOfLocalName("P"); 
            if (pString == null) {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString","DSA","P")); 
            }
            dsaParams.P = Convert.FromBase64String(Utils.DiscardWhiteSpaces(pString));

            // Q is always present 
            String qString = topElement.SearchForTextOfLocalName("Q");
            if (qString == null) { 
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString","DSA","Q")); 
            }
            dsaParams.Q = Convert.FromBase64String(Utils.DiscardWhiteSpaces(qString)); 

            // G is always present
            String gString = topElement.SearchForTextOfLocalName("G");
            if (gString == null) { 
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString","DSA","G"));
            } 
            dsaParams.G = Convert.FromBase64String(Utils.DiscardWhiteSpaces(gString)); 

            // Y is always present 
            String yString = topElement.SearchForTextOfLocalName("Y");
            if (yString == null) {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString","DSA","Y"));
            } 
            dsaParams.Y = Convert.FromBase64String(Utils.DiscardWhiteSpaces(yString));
 
            // J is optional 
            String jString = topElement.SearchForTextOfLocalName("J");
            if (jString != null) dsaParams.J = Convert.FromBase64String(Utils.DiscardWhiteSpaces(jString)); 

            // X is optional -- private key if present
            String xString = topElement.SearchForTextOfLocalName("X");
            if (xString != null) dsaParams.X = Convert.FromBase64String(Utils.DiscardWhiteSpaces(xString)); 

            // Seed and PgenCounter are optional as a unit -- both present or both absent 
            String seedString = topElement.SearchForTextOfLocalName("Seed"); 
            String pgenCounterString = topElement.SearchForTextOfLocalName("PgenCounter");
            if ((seedString != null) && (pgenCounterString != null)) { 
                dsaParams.Seed = Convert.FromBase64String(Utils.DiscardWhiteSpaces(seedString));
                dsaParams.Counter = Utils.ConvertByteArrayToInt(Convert.FromBase64String(Utils.DiscardWhiteSpaces(pgenCounterString)));
            } else if ((seedString != null) || (pgenCounterString != null)) {
                if (seedString == null) { 
                    throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString","DSA","Seed"));
                } else { 
                    throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString","DSA","PgenCounter")); 
                }
            } 

            ImportParameters(dsaParams);
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:63,代码来源:dsa.cs

示例11: GetDsaPublicKey

        public static DsaPublicKeyParameters GetDsaPublicKey(DSAParameters dp)
        {
            DsaValidationParameters validationParameters = (dp.Seed != null) ? new DsaValidationParameters(dp.Seed, dp.Counter) : null;

            var parameters = new DsaParameters(new BigInteger(1, dp.P), new BigInteger(1, dp.Q), new BigInteger(1, dp.G), validationParameters);

            return new DsaPublicKeyParameters(new BigInteger(1, dp.Y), parameters);
        }
开发者ID:Xanagandr,项目名称:DisaOpenSource,代码行数:8,代码来源:DotNetUtilities.cs

示例12: GeneratePrivate

		public override PrivateKey GeneratePrivate (KeySpec key)
		{
			DSAPrivateKeySpec spec = (DSAPrivateKeySpec) key;
			DSAParameters dsp = new DSAParameters ();
			dsp.G = spec.GetG ().GetBytes ();
			dsp.P = spec.GetP ().GetBytes ();
			dsp.Q = spec.GetQ ().GetBytes ();
			dsp.X = spec.GetX ().GetBytes ();
			return new DSAPrivateKey (dsp);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:10,代码来源:KeyFactory.cs

示例13: CryptographyParams

 static CryptographyParams()
 {
     dsap = new DSAParameters();
     dsap.Counter = 380;
     dsap.G = new byte[] { 0x4E, 0x6F, 0xE7, 0x44, 0xDD, 0x60, 0x88, 0xFF, 0x2A, 0x72, 0x45, 0x70, 0xC3, 0x43, 0xE0, 0x9D, 0xCA, 0x11, 0x0F, 0x38, 0x06, 0xB2, 0xBE, 0x96, 0x72, 0xB8, 0xD2, 0xD5, 0xEB, 0xF7, 0xD3, 0xD2, 0x9B, 0xFE, 0x8A, 0x10, 0xFB, 0x93, 0xB1, 0x76, 0xBB, 0x7D, 0xAC, 0x6B, 0x0E, 0xAE, 0xD3, 0x9E, 0x73, 0xCA, 0x9C, 0x29, 0x01, 0x84, 0xA4, 0x97, 0xB4, 0x59, 0xA1, 0x65, 0x9F, 0xD6, 0x0B, 0x94 };
     dsap.J = new byte[] { 0xBB, 0x6C, 0x04, 0xD1, 0xCD, 0x7B, 0xDF, 0xB4, 0x4D, 0x70, 0xDC, 0x1E, 0xBD, 0xC8, 0xA3, 0x21, 0xB5, 0xA0, 0x80, 0xBC, 0xF1, 0xA6, 0x61, 0xBA, 0x51, 0x11, 0x15, 0xD4, 0x86, 0xEC, 0x28, 0x55, 0x7E, 0x2A, 0x21, 0xAD, 0xFF, 0x96, 0xEB, 0x8C, 0xB1, 0xF4, 0xA0, 0x5A };
     dsap.P = new byte[] { 0x81, 0x66, 0x5B, 0xF0, 0x6C, 0x13, 0x07, 0x62, 0xEC, 0x5E, 0xB8, 0x8E, 0xEE, 0x76, 0xF2, 0x32, 0x4C, 0x01, 0x7B, 0x81, 0x45, 0x08, 0x22, 0x5D, 0x79, 0x6F, 0x3B, 0x88, 0x07, 0x43, 0x75, 0x23, 0x9D, 0x62, 0xB6, 0x7F, 0xE5, 0xC4, 0x01, 0x4F, 0x63, 0xAE, 0x7B, 0x58, 0xA9, 0x2C, 0x70, 0xF3, 0x2A, 0xFD, 0x2E, 0x72, 0xF3, 0x90, 0x01, 0x6B, 0xCF, 0x68, 0xE5, 0x46, 0x54, 0xD5, 0xED, 0x8F };
     dsap.Q = new byte[] { 0xB0, 0xBF, 0x5B, 0x8F, 0xAD, 0xC5, 0x15, 0x3D, 0x52, 0x90, 0x1B, 0x7D, 0x58, 0x6A, 0x1F, 0x5E, 0x47, 0x09, 0xC7, 0x43 };
     dsap.Seed = new byte[] { 0xA0, 0x13, 0xA1, 0x17, 0x47, 0x9D, 0x0B, 0x7B, 0x2C, 0xA5, 0x70, 0x72, 0xF4, 0x88, 0x72, 0x89, 0x54, 0x12, 0x4C, 0x64 };
     dsap.Y = new byte[] { 0x20, 0xA5, 0x63, 0x06, 0xA2, 0x59, 0xA1, 0x2F, 0x6B, 0xE3, 0x49, 0x83, 0x29, 0x8D, 0x5A, 0xA7, 0x8B, 0x9E, 0xF8, 0x33, 0x32, 0xE9, 0xB5, 0xFB, 0x52, 0xF3, 0xD3, 0xB4, 0x7B, 0xEA, 0xDB, 0xC1, 0xB5, 0x8E, 0x89, 0x47, 0x29, 0x4C, 0xD9, 0x33, 0xD0, 0xA8, 0xDA, 0x1E, 0x93, 0x70, 0x80, 0x3D, 0x55, 0x60, 0x35, 0x95, 0x6F, 0xD9, 0xD4, 0xD1, 0x5E, 0x06, 0x41, 0x3E, 0x3E, 0xEC, 0xD6, 0x14 };
 }
开发者ID:andrey-kozyrev,项目名称:LinguaSpace,代码行数:11,代码来源:CryptographyParams.cs

示例14: GetDsaKeyPair

        public static AsymmetricCipherKeyPair GetDsaKeyPair(DSAParameters dp)
        {
            DsaValidationParameters validationParameters = (dp.Seed != null) ? new DsaValidationParameters(dp.Seed, dp.Counter) : null;

            var parameters = new DsaParameters(new BigInteger(1, dp.P), new BigInteger(1, dp.Q), new BigInteger(1, dp.G), validationParameters);

            var pubKey = new DsaPublicKeyParameters(new BigInteger(1, dp.Y), parameters);

            var privKey = new DsaPrivateKeyParameters(new BigInteger(1, dp.X), parameters);

            return new AsymmetricCipherKeyPair(pubKey, privKey);
        }
开发者ID:Xanagandr,项目名称:DisaOpenSource,代码行数:12,代码来源:DotNetUtilities.cs

示例15: AssertEquals

	// may also help for DSA descendants
	public void AssertEquals (string message, DSAParameters expectedKey, DSAParameters actualKey, bool checkPrivateKey) 
	{
		Assert.AreEqual (expectedKey.Counter, actualKey.Counter, message + " Counter");
		AssertEquals (message + " G", expectedKey.G, actualKey.G);
		AssertEquals (message + " J", expectedKey.J, actualKey.J);
		AssertEquals (message + " P", expectedKey.P, actualKey.P);
		AssertEquals (message + " Q", expectedKey.Q, actualKey.Q);
		AssertEquals (message + " Seed", expectedKey.Seed, actualKey.Seed);
		AssertEquals (message + " Y", expectedKey.Y, actualKey.Y);
		if (checkPrivateKey)
			AssertEquals (message + " X", expectedKey.X, actualKey.X);
	}
开发者ID:carrie901,项目名称:mono,代码行数:13,代码来源:DSACryptoServiceProviderTest.cs


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