public void GeneratesSameSharedKey()
        {
            byte[] serverSharedSecret;
            byte[] clientSharedSecret;

            using (X25519EcdheRsaSha256 serverCipherSuite = new X25519EcdheRsaSha256(this.random))
            {
                int expectedSize = serverCipherSuite.CalculateServerMessageSize(this.privateKey);
                Assert.IsTrue(expectedSize > 0);

                byte[] serverKeyExchangeMessage = new byte[expectedSize];
                serverCipherSuite.EncodeServerKeyExchangeMessage(serverKeyExchangeMessage, this.privateKey);

                byte[] clientKeyExchange;

                using (X25519EcdheRsaSha256 clientCipherSuite = new X25519EcdheRsaSha256(this.random))
                {
                    clientSharedSecret = new byte[clientCipherSuite.SharedKeySize()];
                    Assert.IsTrue(clientCipherSuite.VerifyServerMessageAndGenerateSharedKey(clientSharedSecret, serverKeyExchangeMessage, this.publicKey));

                    clientKeyExchange = new byte[clientCipherSuite.CalculateClientMessageSize()];
                    clientCipherSuite.EncodeClientKeyExchangeMessage(clientKeyExchange);
                }

                serverSharedSecret = new byte[serverCipherSuite.SharedKeySize()];
                Assert.IsTrue(serverCipherSuite.VerifyClientMessageAndGenerateSharedKey(serverSharedSecret, clientKeyExchange));
            }

            CollectionAssert.AreEqual(serverSharedSecret, clientSharedSecret);
        }
        public void SmallClientDataFails()
        {
            byte[] data;

            using (X25519EcdheRsaSha256 cipherSuite = new X25519EcdheRsaSha256(this.random))
            {
                int expectedSize = cipherSuite.CalculateClientMessageSize();
                Assert.IsTrue(expectedSize / 2 > 1);

                data = new byte[expectedSize / 2];
                random.GetBytes(data);
            }

            using (X25519EcdheRsaSha256 cipherSuite = new X25519EcdheRsaSha256(this.random))
            {
                byte[] sharedKey = new byte[cipherSuite.SharedKeySize()];
                Assert.IsFalse(cipherSuite.VerifyClientMessageAndGenerateSharedKey(sharedKey, data));
            }
        }