PBKDF2PasswordVerifier GetSut(IPBKDF2Credentials credentials = null) { if (credentials != null) { Mock.Get(credentials) .Setup(x => x.GetSaltLength()) .Returns(16); Mock.Get(credentials) .Setup(x => x.GetKeyLength()) .Returns(16); } return(new PBKDF2PasswordVerifier(credentials)); }
public void Verify_returns_false_for_correct_password_and_salt_but_wrong_iteration_count(IPBKDF2Credentials credentials, IPassword entered) { // Arrange Mock.Get(credentials) .Setup(x => x.GetKeyAsByteArray()).Returns(PASSWORD_ONE_SALT_ONE_ITER_100_KEY); Mock.Get(credentials) .Setup(x => x.GetSaltAsByteArray()).Returns(SALT_ONE); Mock.Get(credentials) .Setup(x => x.GetIterationCount()).Returns(105); Mock.Get(entered) .Setup(x => x.GetPasswordAsByteArray()).Returns(PASSWORD_TWO); var sut = GetSut(credentials); // Act var result = sut.Verify(entered, credentials); // Assert Assert.IsFalse(result); }