Пример #1
0
        public void FirstWriteSendsNonce()
        {
            var psk = new PreSharedKey().Generate();

            var insecure = new MemoryStream();
            var secure   = new Psk1Stream(insecure, psk);

            secure.WriteByte(0x10);
            Assert.AreEqual(24 + 1, insecure.Length);

            insecure = new MemoryStream();
            secure   = new Psk1Stream(insecure, psk);
            secure.Write(new byte[10], 0, 10);
            Assert.AreEqual(24 + 10, insecure.Length);

            insecure = new MemoryStream();
            secure   = new Psk1Stream(insecure, psk);
            secure.WriteAsync(new byte[12], 0, 12).Wait();
            Assert.AreEqual(24 + 12, insecure.Length);
        }