Fix symmetric session key test
This commit is contained in:
parent
ac8a49c114
commit
4e5b29eb4a
2 changed files with 7 additions and 4 deletions
|
|
@ -70,7 +70,7 @@ func DecryptSessionKeyWithPassword(keyPacket, password []byte) (*SessionKey, err
|
|||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("gopenpgp: password incorrect")
|
||||
return nil, errors.New("gopenpgp: unable to decrypt any packet")
|
||||
}
|
||||
|
||||
// EncryptSessionKeyWithPassword encrypts the session key with the password and
|
||||
|
|
|
|||
|
|
@ -52,14 +52,17 @@ func TestSymmetricKeyPacket(t *testing.T) {
|
|||
t.Fatal("Expected no error while generating key packet, got:", err)
|
||||
}
|
||||
|
||||
_, err = DecryptSessionKeyWithPassword(keyPacket, []byte("Wrong password"))
|
||||
assert.EqualError(t, err, "gopenpgp: password incorrect")
|
||||
wrongSymmetricKey, err := DecryptSessionKeyWithPassword(keyPacket, []byte("Wrong password"))
|
||||
if err != nil {
|
||||
assert.EqualError(t, err, "gopenpgp: unable to decrypt any packet")
|
||||
} else {
|
||||
assert.NotEqual(t, testSessionKey, wrongSymmetricKey)
|
||||
}
|
||||
|
||||
outputSymmetricKey, err := DecryptSessionKeyWithPassword(keyPacket, password)
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error while decrypting key packet, got:", err)
|
||||
}
|
||||
|
||||
assert.Exactly(t, testSessionKey, outputSymmetricKey)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue