Skip to content

Commit

Permalink
docs(v2): Improve documentation in signatures for keys
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Nov 24, 2023
1 parent e3b2b43 commit 3551630
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
15 changes: 4 additions & 11 deletions openpgp/packet/public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,16 +935,9 @@ func userIdSignatureHash(id string, pk *PublicKey, h hash.Hash) (err error) {
return nil
}

// directSignatureHash returns a Hash of the message that needs to be signed
// directSignatureHash returns a Hash of the message that needs to be signed.
func directKeySignatureHash(pk *PublicKey, h hash.Hash) (err error) {
// RFC 4880, section 5.2.4
if err := pk.SerializeSignaturePrefix(h); err != nil {
return err
}
if err := pk.serializeWithoutHeaders(h); err != nil {
return err
}
return nil
return pk.SerializeForHash(h)
}

// VerifyUserIdSignature returns nil iff sig is a valid signature, made by this
Expand All @@ -960,8 +953,8 @@ func (pk *PublicKey) VerifyUserIdSignature(id string, pub *PublicKey, sig *Signa
return pk.VerifySignature(h, sig)
}

// VerifyUserIdSignature returns nil iff sig is a valid signature, made by this
// public key
// VerifyDirectKeySignature returns nil iff sig is a valid signature, made by this
// public key.
func (pk *PublicKey) VerifyDirectKeySignature(sig *Signature) (err error) {
h, err := sig.PrepareVerify()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions openpgp/v2/subkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (s *Subkey) Serialize(w io.Writer, includeSecrets bool) error {
return nil
}

// ReSign resigns the latest valid subkey binding signature with the given config.
func (s *Subkey) ReSign(config *packet.Config) error {
selectedSig, err := s.LatestValidBindingSignature(time.Time{})
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions openpgp/v2/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func readUser(e *Entity, packets *packet.Reader, pkt *packet.UserId) error {
return nil
}

// Serialize serializes the user id to the writer.
func (i *Identity) Serialize(w io.Writer) error {
if err := i.UserId.Serialize(w); err != nil {
return err
Expand Down Expand Up @@ -135,6 +136,7 @@ func (i *Identity) Revoked(selfCertification *packet.Signature, date time.Time)
return false
}

// ReSign resigns the latest valid self-certification with the given config.
func (i *Identity) ReSign(config *packet.Config) error {
selectedSig, err := i.LatestValidSelfCertification(config.Now())
if err != nil {
Expand Down

0 comments on commit 3551630

Please sign in to comment.