当前位置: 首页>>代码示例>>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;未经允许,请勿转载。