Beispiel #1
0
        public void MfKey32_SameNtTwoNonce(uint uid, uint nt, uint nr0, uint nr1, ulong expectedKey)
        {
            var p64     = Crypto1.PrngSuccessor(nt, 64);
            var crypto1 = new Crypto1(expectedKey);

            crypto1.Crypto1Word(uid ^ nt);
            nr0 ^= crypto1.Crypto1Word(nr0);
            var ar0 = p64 ^ crypto1.Crypto1Word();

            crypto1 = new Crypto1(expectedKey);
            crypto1.Crypto1Word(uid ^ nt);
            nr1 ^= crypto1.Crypto1Word(nr1);
            var ar1 = p64 ^ crypto1.Crypto1Word();

            var key = MfKey.MfKey32(uid, nt, nr0, ar0, nr1, ar1);

            Assert.AreEqual(expectedKey, key);
        }
Beispiel #2
0
        public void MfKey32_SameNtManyNonce(uint uid, uint nt, int randomSeed, int nonceCount, ulong expectedKey)
        {
            var    p64  = Crypto1.PrngSuccessor(nt, 64);
            var    list = new List <Nonce>();
            Random rnd  = new Random(randomSeed);

            for (int i = 0; i < nonceCount; i++)
            {
                var crypto1 = new Crypto1(expectedKey);
                crypto1.Crypto1Word(uid ^ nt);
                var nr = (uint)rnd.Next();
                list.Add(new Nonce()
                {
                    Nr = crypto1.Crypto1Word(nr) ^ nr,
                    Ar = p64 ^ crypto1.Crypto1Word()
                });
            }

            var key = MfKey.MfKey32(uid, nt, list);

            Assert.AreEqual(expectedKey, key);
        }