public void Given_PasswordHashWithIterationsChanged_Then_PasswordHashesDoNotMatch()
        {
            var password         = "******";
            var securedPassword  = new SecuredPassword(password, HashStrategyKind.Argon248KWorkCost);
            var securedPassword2 = new SecuredPassword(password, HashStrategyKind.Pbkdf28000Iterations);

            Assert.IsFalse(securedPassword2.Equals(securedPassword));
        }
        public void Given_SecuredPasswordIsDifferentToGiven_Then_VerifiesFalse()
        {
            var securedPassword  = new SecuredPassword("password", HashStrategyKind.Argon248KWorkCost);
            var securedPassword2 = new SecuredPassword("Password2", HashStrategyKind.Argon248KWorkCost);
            var result           = securedPassword.Equals(securedPassword2);

            Assert.IsFalse(result);
        }
예제 #3
0
        public void Given_SecuredPasswordIsDifferentToGiven_Then_VerifiesFalse()
        {
            var securedPassword  = new SecuredPassword("password", HashStrategyKind.Pbkdf210001Iterations);
            var securedPassword2 = new SecuredPassword("Password2", HashStrategyKind.Pbkdf210001Iterations);
            var result           = securedPassword.Equals(securedPassword2);

            Assert.IsFalse(result);
        }
예제 #4
0
        public void Given_PasswordHashWithIterationsChanged_Then_PasswordHashesDoNotMatch()
        {
            string password         = "******";
            var    securedPassword  = new SecuredPassword(password, HashStrategyKind.Pbkdf210001Iterations);
            var    securedPassword2 = new SecuredPassword(password, HashStrategyKind.Pbkdf210001Iterations);

            Assert.IsFalse(securedPassword2.Equals(securedPassword));
        }
예제 #5
0
        public void Given_WhenRehydratedAndMatching_Then_ReturnsTrue()
        {
            var password        = "******";
            var securedPassword = new SecuredPassword(password, HashStrategyKind.Argon248KWorkCost);
            var rehydrated      = new SecuredPassword(password, securedPassword.Hash, securedPassword.Salt, HashStrategyKind.Argon248KWorkCost);

            Assert.IsTrue(securedPassword.Equals(rehydrated));
            Assert.IsTrue(rehydrated.IsValid);
        }
        public void Given_PasswordHashAndSalt_Then_NewPasswordIsHashedAsExpected()
        {
            var password        = "******";
            var securedPassword = new SecuredPassword(password, HashStrategyKind.Argon248KWorkCost);
            var storedSalt      = Convert.ToBase64String(securedPassword.Salt);
            var storedHash      = Convert.ToBase64String(securedPassword.Hash);

            var securedPassword2 = new SecuredPassword(password, Convert.FromBase64String(storedHash),
                                                       Convert.FromBase64String(storedSalt), HashStrategyKind.Argon248KWorkCost);

            Assert.IsTrue(securedPassword2.Equals(securedPassword));
        }
예제 #7
0
        public void Given_WhenRehydratedAndMatching_Then_ReturnsTrue()
        {
            // Arrange
            var password        = "******";
            var securedPassword = new SecuredPassword(password, HashStrategyKind.Argon2WorkCost);

            // Act
            var rehydrated = new SecuredPassword(password, securedPassword.Hash, securedPassword.Salt, HashStrategyKind.Argon2WorkCost);

            // Assert
            Assert.IsTrue(securedPassword.Equals(rehydrated));
            Assert.IsTrue(rehydrated.IsValid, "Rehydrated password is not valid");
        }