pbkdf2: fix password comparison

the key len for the derived function must be equal to the len of the
expected key
This commit is contained in:
Nicola Murino
2020-03-28 16:09:06 +01:00
parent 0a9c4914aa
commit b52d078986
2 changed files with 10 additions and 13 deletions

View File

@@ -2514,12 +2514,12 @@ func TestPasswordsHashPbkdf2Sha256(t *testing.T) {
user.Password = pbkdf2ClearPwd
client, err := getSftpClient(user, usePubKey)
if err != nil {
t.Errorf("unable to login with pkkdf2 sha1 password: %v", err)
t.Errorf("unable to login with pkkdf2 sha256 password: %v", err)
} else {
defer client.Close()
_, err = client.Getwd()
if err != nil {
t.Errorf("unable to get working dir with pkkdf2 sha1 password: %v", err)
t.Errorf("unable to get working dir with pkkdf2 sha256 password: %v", err)
}
}
user.Password = pbkdf2Pwd
@@ -2547,12 +2547,12 @@ func TestPasswordsHashPbkdf2Sha512(t *testing.T) {
user.Password = pbkdf2ClearPwd
client, err := getSftpClient(user, usePubKey)
if err != nil {
t.Errorf("unable to login with pkkdf2 sha1 password: %v", err)
t.Errorf("unable to login with pkkdf2 sha512 password: %v", err)
} else {
defer client.Close()
_, err = client.Getwd()
if err != nil {
t.Errorf("unable to get working dir with pkkdf2 sha1 password: %v", err)
t.Errorf("unable to get working dir with pkkdf2 sha512 password: %v", err)
}
}
user.Password = pbkdf2Pwd