Ejemplo n.º 1
0
        public void Create_CalculatesSameMacForSameUserWithSameSessionComponent()
        {
            _helper = new AuthenticatedSessionIDHelper(_rng, new byte[32], new HmacSha256Helper());

            var session1 = _helper.Create("klings").AddBase64Padding();
            var session2 = _helper.Create("klings").AddBase64Padding();

            Assert.AreEqual(session1, session2);
        }
Ejemplo n.º 2
0
        public void Create_CreatesRandomIdWithMac()
        {
            var expectedSessionId = GetMockValidSessionID();

            var sessionID = _helper.Create("klings");

            Assert.AreEqual(expectedSessionId, sessionID);
        }
Ejemplo n.º 3
0
 //[Test]
 public void Create_Performance()
 {
     _helper = new AuthenticatedSessionIDHelper(new RNGCryptoServiceProvider(), new byte[32], new HmacSha256Helper());
     foreach (var number in Enumerable.Range(0, 10000000))
     {
         _helper.Create("klings");
     }
 }
Ejemplo n.º 4
0
        public void Create_CalculatesDifferentMacForDifferentUsersWithSameSessionComponent()
        {
            _helper = new AuthenticatedSessionIDHelper(_rng, new byte[32], new HmacSha256Helper());

            var session1 = Convert.FromBase64String(_helper.Create("klings").AddBase64Padding());
            var session2 = Convert.FromBase64String(_helper.Create("klings2").AddBase64Padding());

            for (var i = 0; i < SessionIdComponentLength; i++)
            {
                Assert.AreEqual(session1[i], session2[i]);
            }

            var differs = false;

            for (var i = SessionIdComponentLength; i < session1.Length; i++)
            {
                differs = differs || session1[i] != session2[i];
            }
            Assert.IsTrue(differs, "MACs were equal.");
        }