public void ManagedExportAgreeswithNativeImportGroup2()
        {
            DiffieHellmanKey managedExport;

            using (var alice = new ManagedDiffieHellmanOakley2())
                using (var bob = new ManagedDiffieHellmanOakley2())
                {
                    managedExport = alice.PrivateKey as DiffieHellmanKey;

                    alice.ImportPartnerKey(bob.PublicKey);
                    bob.ImportPartnerKey(alice.PublicKey);

                    AssertKeysAgree(alice, bob);
                }

            managedExport.Generator = Pad(managedExport.Generator, managedExport.KeyLength);

            using (var alice = BCryptDiffieHellman.Import(managedExport))
                using (var bob = new BCryptDiffieHellmanOakleyGroup2())
                {
                    alice.ImportPartnerKey(bob.PublicKey);
                    bob.ImportPartnerKey(alice.PublicKey);

                    AssertKeysAgree(alice, bob);
                }
        }
        public void ManagedAgreesWithNativeGroup2()
        {
            using (var alice = new BCryptDiffieHellmanOakleyGroup2())
                using (var bob = new ManagedDiffieHellmanOakley2())
                {
                    alice.ImportPartnerKey(bob.PublicKey);
                    bob.ImportPartnerKey(alice.PublicKey);

                    AssertKeysAgree(alice, bob);
                }
        }
        public ReadOnlyMemory <byte> Modp2()
        {
            using (var alice = new BCryptDiffieHellmanOakleyGroup2())
                using (var bob = new BCryptDiffieHellmanOakleyGroup2())
                {
                    alice.ImportPartnerKey(bob.PublicKey);
                    bob.ImportPartnerKey(alice.PublicKey);

                    return(alice.GenerateAgreement());
                }
        }
        public void Oakley2_KeyAgreement()
        {
            using (var alice = new BCryptDiffieHellmanOakleyGroup2())
                using (var bob = new BCryptDiffieHellmanOakleyGroup2())
                {
                    Assert.IsFalse(bob.PublicKey.PublicComponent.Span.SequenceEqual(alice.PublicKey.PublicComponent.Span));

                    alice.ImportPartnerKey(GetRightPublicKey(alice.PublicKey, bob.PublicKey));
                    bob.ImportPartnerKey(GetRightPublicKey(bob.PublicKey, alice.PublicKey));

                    AssertKeysAgree(alice, bob);
                }
        }