Beispiel #1
0
            protected override IKeyAgreement StartKeyAgreement()
            {
                IKeyAgreement agreement = null;

                switch (random.Next(4))
                {
                case 0:
                    agreement = new BCryptDiffieHellmanOakleyGroup14();
                    break;

                case 1:
                    agreement = new BCryptDiffieHellmanOakleyGroup2();
                    break;

                case 2:
                    agreement = new ManagedDiffieHellmanOakley14();
                    break;

                case 3:
                    agreement = new ManagedDiffieHellmanOakley2();
                    break;
                }

                W($"DH Type: {agreement.GetType()}");

                if (agreement == null)
                {
                    throw new ArgumentException("How did it get here?");
                }

                return(agreement);
            }
        public void ManagedAgreesWithNativeGroup14()
        {
            using (var alice = new BCryptDiffieHellmanOakleyGroup14())
                using (var bob = new ManagedDiffieHellmanOakley14())
                {
                    alice.ImportPartnerKey(bob.PublicKey);
                    bob.ImportPartnerKey(alice.PublicKey);

                    AssertKeysAgree(alice, bob);
                }
        }