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


C# Parameters.DHParameters類代碼示例

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


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

示例1: CalculatePrivate

        internal IBigInteger CalculatePrivate(
			DHParameters	dhParams,
			ISecureRandom	random)
        {
            int limit = dhParams.L;

            if (limit != 0)
            {
                return new BigInteger(limit, random).SetBit(limit - 1);
            }

            IBigInteger min = BigInteger.Two;
            int m = dhParams.M;
            if (m != 0)
            {
                min = BigInteger.One.ShiftLeft(m - 1);
            }

            IBigInteger max = dhParams.P.Subtract(BigInteger.Two);
            IBigInteger q = dhParams.Q;
            if (q != null)
            {
                max = q.Subtract(BigInteger.Two);
            }

            return BigIntegers.CreateRandomInRange(min, max, random);
        }
開發者ID:sanyaade-iot,項目名稱:Schmoose-BouncyCastle,代碼行數:27,代碼來源:DHKeyGeneratorHelper.cs

示例2: ComputeSharedSecret

 public static BigInteger ComputeSharedSecret(string A, AsymmetricKeyParameter bPrivateKey, DHParameters internalParameters)
 {
     var importedKey = new DHPublicKeyParameters(new BigInteger(A), internalParameters);
     var internalKeyAgree = AgreementUtilities.GetBasicAgreement("DH");
     internalKeyAgree.Init(bPrivateKey);
     return internalKeyAgree.CalculateAgreement(importedKey);
 }
開發者ID:WakeCaine,項目名稱:AuthProject,代碼行數:7,代碼來源:MainWindow.xaml.cs

示例3: GenerateKeys

 public static AsymmetricCipherKeyPair GenerateKeys(DHParameters parameters)
 {
     var keyGen = GeneratorUtilities.GetKeyPairGenerator("DH");
     var kgp = new DHKeyGenerationParameters(new SecureRandom(), parameters);
     keyGen.Init(kgp);
     return keyGen.GenerateKeyPair();
 }
開發者ID:WakeCaine,項目名稱:AuthProject,代碼行數:7,代碼來源:MainWindow.xaml.cs

示例4: DHKeyGenerationParameters

		public DHKeyGenerationParameters(
            SecureRandom	random,
            DHParameters	parameters)
			: base(random, GetStrength(parameters))
        {
            this.parameters = parameters;
        }
開發者ID:JohnMalmsteen,項目名稱:mobile-apps-tower-defense,代碼行數:7,代碼來源:DHKeyGenerationParameters.cs

示例5: DHKeyGenerationParameters

 public DHKeyGenerationParameters(
     SecureRandom	random,
     DHParameters	parameters)
     : base(random, parameters.P.BitLength)
 {
     this.parameters = parameters;
 }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:7,代碼來源:DHKeyGenerationParameters.cs

示例6: DHPrivateKeyParameters

		public DHPrivateKeyParameters(
            BigInteger		x,
            DHParameters	parameters)
			: base(true, parameters)
        {
            this.x = x;
        }
開發者ID:ktw,項目名稱:OutlookPrivacyPlugin,代碼行數:7,代碼來源:DHPrivateKeyParameters.cs

示例7: DHKeyParameters

 protected DHKeyParameters(
     bool			isPrivate,
     DHParameters	parameters)
     : base(isPrivate)
 {
     // TODO Should we allow parameters to be null?
     this.parameters = parameters;
 }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:8,代碼來源:DHKeyParameters.cs

示例8: DHPublicKeyParameters

		public DHPublicKeyParameters(
            BigInteger		y,
            DHParameters	parameters)
			: base(false, parameters)
        {
			if (y == null)
				throw new ArgumentNullException("y");

			this.y = y;
        }
開發者ID:nicecai,項目名稱:iTextSharp-4.1.6,代碼行數:10,代碼來源:DHPublicKeyParameters.cs

示例9: DHKeyParameters

		protected DHKeyParameters(
            bool				isPrivate,
            DHParameters		parameters,
			DerObjectIdentifier	algorithmOid)
			: base(isPrivate)
        {
			// TODO Should we allow parameters to be null?
            this.parameters = parameters;
			this.algorithmOid = algorithmOid;
        }
開發者ID:htlp,項目名稱:itextsharp,代碼行數:10,代碼來源:DHKeyParameters.cs

示例10: DHProvider

        public DHProvider(DHParameters parameters)
        {
            _parameters = parameters;

            IAsymmetricCipherKeyPairGenerator keyGen = GeneratorUtilities.GetKeyPairGenerator("DH");
            KeyGenerationParameters kgp = new DHKeyGenerationParameters(new SecureRandom(), _parameters);

            keyGen.Init(kgp);
            _kp = keyGen.GenerateKeyPair();
        }
開發者ID:soshimozi,項目名稱:SocketServer,代碼行數:10,代碼來源:DHProvider.cs

示例11: DHPublicKeyParameters

		public DHPublicKeyParameters(
            BigInteger			y,
            DHParameters		parameters,
		    DerObjectIdentifier	algorithmOid)
			: base(false, parameters, algorithmOid)
        {
			if (y == null)
				throw new ArgumentNullException("y");

			this.y = y;
        }
開發者ID:MBrekhof,項目名稱:pleiobox-clients,代碼行數:11,代碼來源:DHPublicKeyParameters.cs

示例12: ServerAuthority

        public ServerAuthority(DHParameters parameters)
        {
            this.parameters = parameters;

            IAsymmetricCipherKeyPairGenerator keyGen = GeneratorUtilities.GetKeyPairGenerator("DH");
            KeyGenerationParameters kgp = new DHKeyGenerationParameters(new SecureRandom(), parameters);

            keyGen.Init(kgp);
            kp = keyGen.GenerateKeyPair();
            agreement = AgreementUtilities.GetBasicAgreement("DH");
            agreement.Init(kp.Private);
        }
開發者ID:soshimozi,項目名稱:SocketServer,代碼行數:12,代碼來源:ServerAuthority.cs

示例13: GenerateEphemeralClientKeyExchange

        public static DHPrivateKeyParameters GenerateEphemeralClientKeyExchange(SecureRandom random,
			DHParameters dhParams, Stream output)
        {
            AsymmetricCipherKeyPair dhAgreeClientKeyPair = GenerateDHKeyPair(random, dhParams);
            DHPrivateKeyParameters dhAgreeClientPrivateKey =
                (DHPrivateKeyParameters)dhAgreeClientKeyPair.Private;

            BigInteger Yc = ((DHPublicKeyParameters)dhAgreeClientKeyPair.Public).Y;
            byte[] keData = BigIntegers.AsUnsignedByteArray(Yc);
            TlsUtilities.WriteOpaque16(keData, output);

            return dhAgreeClientPrivateKey;
        }
開發者ID:medvedttn,項目名稱:itextsharp_mod-src,代碼行數:13,代碼來源:TlsDHUtilities.cs

示例14: GenerateKeyPair

        public AsymmetricCipherKeyPair GenerateKeyPair()
        {
			DHKeyGeneratorHelper helper = DHKeyGeneratorHelper.Instance;
			ElGamalParameters egp = param.Parameters;
			DHParameters dhp = new DHParameters(egp.P, egp.G, null, 0, egp.L);

			BigInteger x = helper.CalculatePrivate(dhp, param.Random);
			BigInteger y = helper.CalculatePublic(dhp, x);

			return new AsymmetricCipherKeyPair(
                new ElGamalPublicKeyParameters(y, egp),
                new ElGamalPrivateKeyParameters(x, egp));
        }
開發者ID:MBrekhof,項目名稱:pleiobox-clients,代碼行數:13,代碼來源:ElGamalKeyPairGenerator.cs

示例15: Mix

        /// <summary>
        /// Create a Diffie-Hellman key pair mixture.
        /// </summary>
        /// <returns>KeyPair mixture</returns>
        public KeyPair Mix()
        {
            var cipherKeyPairGenerator = GeneratorUtilities.GetKeyPairGenerator("DiffieHellman");
            var diffieHellmanParameters = new DHParameters(_common.P, _common.G, null);

            KeyGenerationParameters diffieHellmanKeyGenerationParameters = new DHKeyGenerationParameters(new Org.BouncyCastle.Security.SecureRandom(), diffieHellmanParameters);
            cipherKeyPairGenerator.Init(diffieHellmanKeyGenerationParameters);

            var asymmetricKeyPair = cipherKeyPairGenerator.GenerateKeyPair();
            var agreement = AgreementUtilities.GetBasicAgreement("DiffieHellman");
            agreement.Init(asymmetricKeyPair.Private);

            return new KeyPair() { Private = ((DHPrivateKeyParameters)asymmetricKeyPair.Private).X.ToString(), Public = ((DHPublicKeyParameters)asymmetricKeyPair.Public).Y.ToString() };
        }
開發者ID:TimothyMeadows,項目名稱:Blackfeather,代碼行數:18,代碼來源:KeyExchange.cs


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