sig

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: 0BSD Imports: 13 Imported by: 0

Documentation

Overview

Package sig verifies OpenPGP and SSHSIG signatures on git commits and tags, and maps them to the forge's trust states.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalSSHSig

func MarshalSSHSig(signer ssh.Signer, payload []byte) ([]byte, error)

MarshalSSHSig builds an armored SSHSIG over payload with the given signer. Used by fixture generation and (later) forge-side tooling.

Types

type Commit

type Commit struct {
	Raw            []byte
	Payload        []byte // Raw with the gpgsig header removed, byte-exact
	Signature      []byte // armored signature block, nil if unsigned
	AuthorName     string
	AuthorEmail    string
	CommitterEmail string
	Subject        string
	AuthorUnix     int64
}

Commit is a parsed raw commit object.

func ParseCommit

func ParseCommit(raw []byte) (*Commit, error)

ParseCommit splits a raw commit object (as printed by `git cat-file commit`) into its signed payload and signature. The payload must be byte-exact: it is the original object minus the gpgsig header line and its continuation lines, nothing else.

type DB

type DB interface {
	// PGPKeyByIssuer finds a registered key whose fingerprint ends with the
	// issuer key id (16 hex chars, lowercase).
	PGPKeyByIssuer(keyIDHex string) (PGPKeyInfo, string, bool, error) // info, fingerprint, found
	SSHSignerByFingerprint(fp string) (SSHKeyInfo, bool, error)
	VerifiedEmails(userID int64) ([]string, error)
}

DB is the store surface the verifier depends on. Implemented by store.SigDB.

type PGPKeyInfo

type PGPKeyInfo struct {
	UserID    int64
	Armored   string
	ExpiresAt *time.Time
	RevokedAt *time.Time
}

PGPKeyInfo is a registered OpenPGP key as the verifier needs it.

type PGPKeyMeta

type PGPKeyMeta struct {
	Fingerprint string // primary key, lowercase hex
	Emails      []string
	ExpiresAt   *time.Time
	RevokedAt   *time.Time
}

PGPKeyMeta is what `pgp add` needs to persist about an imported key.

func ParsePGPKey

func ParsePGPKey(armored []byte) (PGPKeyMeta, error)

ParsePGPKey extracts registration metadata from an armored public key.

type Result

type Result struct {
	State          State
	SignerUserID   int64 // 0 when unknown
	KeyFingerprint string
}

func VerifyCommit

func VerifyCommit(db DB, c *Commit) (Result, error)

VerifyCommit classifies one parsed commit. The commit's author email drives the identity check, per the plan.

type SSHKeyInfo

type SSHKeyInfo struct {
	UserID      int64
	Fingerprint string
}

SSHKeyInfo is a registered SSH key as the verifier needs it.

type SigKind

type SigKind int

SigKind reports which signature format a gpgsig block holds.

const (
	SigNone SigKind = iota
	SigOpenPGP
	SigSSH
	SigUnknown
)

func KindOf

func KindOf(sig []byte) SigKind

type State

type State string
const (
	Verified            State = "verified"
	SignedUnknownKey    State = "signed_unknown_key"
	SignedEmailMismatch State = "signed_email_mismatch"
	SignedKeyExpired    State = "signed_key_expired"
	SignedKeyRevoked    State = "signed_key_revoked"
	BadSignature        State = "bad_signature"
	Unsigned            State = "unsigned"
)

Source Files

  • commit.go
  • keys.go
  • sshsig.go
  • verify.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL