Ejemplo n.º 1
0
        public void DeepSymmetryTest(int depth)
        {
            RandomNumberGenerator rng  = new RandomNumberGenerator();
            SymmetricRacthet      send = new SymmetricRacthet();
            SymmetricRacthet      recv = new SymmetricRacthet();

            byte[] chainKey = rng.Generate(32);
            send.Initialize(chainKey);
            recv.Initialize(chainKey);

            byte[] key;
            for (; ;)
            {
                var r = send.RatchetForSending(kdf);
                if (r.generation == depth)
                {
                    key = r.key;
                    break;
                }
            }

            var(rk, rg) = recv.RatchetForReceiving(kdf, depth);

            Assert.Equal(depth, rg);
            Assert.Equal(key, rk);
        }
Ejemplo n.º 2
0
        public void RatchetForReceivingManyTest(int howmany)
        {
            RandomNumberGenerator rng  = new RandomNumberGenerator();
            SymmetricRacthet      recv = new SymmetricRacthet();

            recv.Initialize(rng.Generate(32));

            recv.RatchetForReceiving(kdf, howmany);
        }
Ejemplo n.º 3
0
        public void MultiSymmetryTest()
        {
            RandomNumberGenerator rng  = new RandomNumberGenerator();
            SymmetricRacthet      send = new SymmetricRacthet();
            SymmetricRacthet      recv = new SymmetricRacthet();

            byte[] chainKey = rng.Generate(32);
            send.Initialize(chainKey);
            recv.Initialize(chainKey);

            var(skey1, sgeneration1) = send.RatchetForSending(kdf);
            var(skey2, sgeneration2) = send.RatchetForSending(kdf);
            var(rkey1, rgeneration1) = recv.RatchetForReceiving(kdf, sgeneration1);
            var(rkey2, rgeneration2) = recv.RatchetForReceiving(kdf, sgeneration2);

            Assert.NotNull(skey1);
            Assert.NotNull(skey2);
            Assert.NotNull(rkey1);
            Assert.NotNull(rkey2);
            Assert.Equal(sgeneration1, rgeneration1);
            Assert.Equal(sgeneration2, rgeneration2);
            Assert.Equal(skey1, rkey1);
            Assert.Equal(skey2, rkey2);
        }