From 29b7348d439bfe25f90d7c66053a67ba777931ed Mon Sep 17 00:00:00 2001 From: izouxv Date: Fri, 20 Sep 2024 07:09:42 +0800 Subject: [PATCH] Update openpgp/v2/keys.go Co-authored-by: Daniel Huigens --- openpgp/v2/keys.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/openpgp/v2/keys.go b/openpgp/v2/keys.go index c089bd45..eb29ccf8 100644 --- a/openpgp/v2/keys.go +++ b/openpgp/v2/keys.go @@ -599,26 +599,18 @@ func (e *Entity) serializePrivate(w io.Writer, config *packet.Config, reSign boo } for _, attr := range e.Attributes { if reSign { - userAttribute := attr.UserAttribute - - err = userAttribute.Serialize(w) - if err != nil { - return - } - if attr.SelfSignature == nil { return goerrors.New("openpgp: can't re-sign user attribute without valid self-signature") } - err = attr.SelfSignature.SignUserAttribute(userAttribute, e.PrimaryKey, e.PrivateKey, config) - if err != nil { - return - } - } else { - err = attr.UserAttribute.Serialize(w) + err = attr.SelfSignature.SignUserAttribute(attr.UserAttribute, e.PrimaryKey, e.PrivateKey, config) if err != nil { return } } + err = attr.UserAttribute.Serialize(w) + if err != nil { + return + } for _, sig := range attr.Signatures { err = sig.Serialize(w) if err != nil {