Skip to content

Commit

Permalink
docs(keys): Fix no valid encrption key comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Dec 11, 2023
1 parent 0a030a3 commit c519177
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openpgp/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ func shouldPreferIdentity(existingId, potentialNewId *Identity) bool {
// EncryptionKey returns the best candidate Key for encrypting a message to the
// given Entity.
func (e *Entity) EncryptionKey(now time.Time) (Key, bool) {
// Fail to find any encryption key if the...
primarySelfSignature, primaryIdentity := e.PrimarySelfSignature()
if primarySelfSignature == nil || // no self-signature found
e.PrimaryKey.KeyExpired(primarySelfSignature, now) || // primary key has expired
e.Revoked(now) || // primary key has been revoked
primarySelfSignature.SigExpired(now) || // user ID or or direct self-signature has expired
(primaryIdentity != nil && primaryIdentity.Revoked(now)) { // user ID has been revoked (for v4 keys)
// No valid encryption key can be found
return Key{}, false
}

// Iterate the keys to find the newest, unexpired one
// Iterate the keys to find the newest, unexpired one.
candidateSubkey := -1
var maxTime time.Time
for i, subkey := range e.Subkeys {
Expand Down

0 comments on commit c519177

Please sign in to comment.