signing

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultStorePath

func DefaultStorePath() string

DefaultStorePath returns the default store path (~/.jerboa).

func Verify

func Verify(publicKey ed25519.PublicKey, sig *Signature) error

Verify checks that sig is a valid Ed25519 signature over digest by publicKey.

Types

type KeyPair

type KeyPair struct {
	PrivateKey ed25519.PrivateKey
	PublicKey  ed25519.PublicKey
	KeyID      string
}

KeyPair holds an Ed25519 key pair and its key ID.

func GenerateKeyPair

func GenerateKeyPair() (*KeyPair, error)

GenerateKeyPair creates a new Ed25519 key pair.

type Signature

type Signature struct {
	Type      string `json:"type"`
	KeyID     string `json:"keyId"`
	Digest    string `json:"digest"`
	Signature string `json:"signature"`
}

Signature represents an Ed25519 signature over a manifest digest.

func Sign

func Sign(kp *KeyPair, digest string) (*Signature, error)

Sign signs the given digest with the private key and returns a Signature.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store persists Ed25519 key pairs and signatures on disk.

func NewStore

func NewStore(root string) (*Store, error)

NewStore creates a Store rooted at root (typically ~/.jerboa).

func (*Store) GenerateAndSave

func (s *Store) GenerateAndSave() (*KeyPair, error)

GenerateAndSave creates a new key pair and saves it to disk.

func (*Store) HasKeyPair

func (s *Store) HasKeyPair() bool

HasKeyPair reports whether a key pair exists on disk.

func (*Store) ImportPublicKey

func (s *Store) ImportPublicKey(pemData []byte) error

ImportPublicKey imports a PEM-encoded public key for verification. The key is stored as a separate verification key file.

func (*Store) LoadKeyPair

func (s *Store) LoadKeyPair() (*KeyPair, error)

LoadKeyPair loads the key pair from disk. Returns error if no key pair exists.

func (*Store) LoadSignature

func (s *Store) LoadSignature(imageDir string) (*Signature, error)

LoadSignature reads a signature file from the image store directory.

func (*Store) PublicKeyPEM

func (s *Store) PublicKeyPEM() ([]byte, error)

PublicKeyPEM exports the public key as PEM-encoded bytes.

func (*Store) SaveKeyPair

func (s *Store) SaveKeyPair(kp *KeyPair) error

SaveKeyPair persists a key pair to disk.

func (*Store) SaveSignature

func (s *Store) SaveSignature(imageDir string, sig *Signature) error

SaveSignature writes a signature file next to the image manifest in the image store. The signature file is stored at <imageDir>/manifest.json.sig.

func (*Store) SignDigest

func (s *Store) SignDigest(digest string) (*Signature, error)

SignDigest signs a content digest (e.g. an image's disk digest) with the stored key pair and saves the signature keyed by that digest.

func (*Store) SignManifest

func (s *Store) SignManifest(digest, imageDir string) (*Signature, error)

SignManifest signs the manifest digest using the stored key pair and saves the signature. imageDir is the directory containing the manifest (typically <store>/images/<hex-digest>). If no key pair exists, it generates one first.

func (*Store) VerifyDigest

func (s *Store) VerifyDigest(digest string) (*Signature, error)

VerifyDigest verifies the signature stored for a content digest. It returns (nil, nil) when no signature exists, the signature on success, and an error when a signature exists but is invalid.

func (*Store) VerifyManifest

func (s *Store) VerifyManifest(imageDir string) (*Signature, error)

VerifyManifest verifies the signature for a manifest in the image store. Returns nil if signature is valid, an error if invalid, and (nil, nil) if no signature exists.

type VerifyPolicy

type VerifyPolicy int

VerifyPolicy controls signature verification behavior.

const (
	// VerifyOff skips signature verification.
	VerifyOff VerifyPolicy = iota
	// VerifyWarn logs a warning if signature is missing or invalid but does not fail.
	VerifyWarn
	// VerifyEnforce requires a valid signature; fails if missing or invalid.
	VerifyEnforce
)

func ParseVerifyPolicy

func ParseVerifyPolicy(s string) (VerifyPolicy, error)

ParseVerifyPolicy parses a verification policy string.

Jump to

Keyboard shortcuts

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