Skip to content

Commit

Permalink
make key.IsUsable depend on KeyCaps gopasspw#1917
Browse files Browse the repository at this point in the history
RELEASE_NOTES=[FEATURE] Add GPG key capabilities and check in key.isUsable

Signed-off-by: Thomas Mantl <thomas.mantl@redgears.net>
  • Loading branch information
TM2500 committed Nov 25, 2021
1 parent 9500557 commit 10e2f9b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/backend/crypto/gpg/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ type Capabilities struct {

// IsUseable returns true if GPG would assume this key is useable for encryption
func (k Key) IsUseable(alwaysTrust bool) bool {
if k.Caps.Deactivated {
return false
}
if !k.Caps.Encrypt {
return false
}
if !k.ExpirationDate.IsZero() && k.ExpirationDate.Before(time.Now()) {
return false
}
Expand Down

0 comments on commit 10e2f9b

Please sign in to comment.