| 203 | } |
| 204 | |
| 205 | func validEntity(entity *openpgp.Entity) bool { |
| 206 | var selfSig *packet.Signature |
| 207 | for _, ident := range entity.Identities { |
| 208 | if selfSig == nil { |
| 209 | selfSig = ident.SelfSignature |
| 210 | } else if ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId { |
| 211 | selfSig = ident.SelfSignature |
| 212 | break |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | if selfSig == nil { |
| 217 | return false |
| 218 | } |
| 219 | |
| 220 | if len(entity.Revocations) > 0 { |
| 221 | return false |
| 222 | } |
| 223 | |
| 224 | if selfSig.RevocationReason != nil { |
| 225 | return false |
| 226 | } |
| 227 | |
| 228 | if !selfSig.FlagsValid { |
| 229 | return false |
| 230 | } |
| 231 | |
| 232 | if selfSig.KeyLifetimeSecs != nil && selfSig.CreationTime.Add(time.Duration(*selfSig.KeyLifetimeSecs)*time.Second).Before(time.Now()) { |
| 233 | return false |
| 234 | } |
| 235 | |
| 236 | return true |
| 237 | } |