private void loadPassword()
        {
            var password = restfulContext.LocalAuthenticationPassword;

            Debug.Assert(password != null);
            Debug.Assert(password.Length > 0);

            comparer = new ConstantTimeComparer(password);
        }
        public void TestComparer()
        {
            var equals = new ConstantTimeComparer("a");

            foreach (var index in Enumerable.Range(0, 10))
            {
                Assert.True(equals.CheckEquality("a"));
                Assert.False(equals.CheckEquality("b"));
                Assert.False(equals.CheckEquality(""));
            }
        }
 public void Equals_ReturnsTrueForEqualStrings() {
     var c = new ConstantTimeComparer();
     Assert.IsTrue(c.Equals(default(string), (string)null));
     Assert.IsTrue(c.Equals("", string.Empty));
     Assert.IsTrue(c.Equals("longer string", new string("longer string".Select(s => s).ToArray())));
 }
 public void Equals_ExtendedStringsAreNotEqual() {
     var s1 = "s";
     var s2 = "s____";
     var c = new ConstantTimeComparer();
     Assert.IsFalse(c.Equals(s1, s2));
 }
 public void Equals_ReturnsFalseForNonequalStrings() {
     var c = new ConstantTimeComparer();
     Assert.IsFalse(c.Equals(default(string), string.Empty));
     Assert.IsFalse(c.Equals("different case", "diFferent case"));
     Assert.IsFalse(c.Equals("different length", "different length "));
 }