Skip to content

Commit

Permalink
Update openpgp/v2/keys.go
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Huigens <[email protected]>
  • Loading branch information
izouxv and twiss authored Sep 19, 2024
1 parent c3b1f43 commit 29b7348
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions openpgp/v2/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 29b7348

Please sign in to comment.