crypto

package
v0.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package crypto opens backups encrypted with age or GPG.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoKey      = errors.New("no decryption key is set")
	ErrInvalidKey = errors.New("the decryption key can't be used")
	ErrWrongKey   = errors.New("the decryption key doesn't match this backup")
)

Reasons a backup can't be opened. Key parsing errors are replaced by these because library messages can quote the key they were given.

View Source
var ErrInvalidBundle = errors.New("the sealed keys can't be read, enter them again in the dashboard")

ErrInvalidBundle replaces every reason a bundle can't be read, because parser messages can quote the decrypted contents.

Functions

func GenerateRunnerKey

func GenerateRunnerKey() (config.Secret, string, error)

GenerateRunnerKey creates the key pair that keys are sealed for. The private key stays on the runner.

func KeyFingerprint

func KeyFingerprint(publicKey string) string

KeyFingerprint is what users compare with the dashboard to spot a swapped key. The dashboard calculates the same value: SHA-256 of the public key string in unpadded base64.

func OpenAge

func OpenAge(encrypted io.Reader, identity config.Secret) (io.Reader, error)

OpenAge returns the decrypted contents of an age file. Damage is reported while reading.

func OpenGPG

func OpenGPG(encrypted io.Reader, key, passphrase config.Secret) (io.Reader, error)

OpenGPG returns the decrypted contents of a GPG message. Damage is reported while reading.

func RunnerID

func RunnerID(privateKey config.Secret) (string, error)

RunnerID derives a stable, public ID from the runner's key. It labels the runner's containers.

func RunnerPublicKey

func RunnerPublicKey(privateKey config.Secret) (string, error)

RunnerPublicKey returns the public half of the runner's key, which keys are sealed for.

Types

type SealedBundle

type SealedBundle struct {
	S3AccessKey   config.Secret
	S3SecretKey   config.Secret
	NameSalt      config.Secret
	AgeIdentity   config.Secret
	GPGKey        config.Secret
	GPGPassphrase config.Secret
}

SealedBundle holds the keys from SealedBundleContents in api/v1/openapi.yaml. It lives in memory for one job.

func OpenSealedBundle

func OpenSealedBundle(armored string, identity config.Secret) (SealedBundle, error)

OpenSealedBundle decrypts a job's sealed bundle in memory with the runner's private key. A bundle sealed for other runners returns ErrWrongKey.

Jump to

Keyboard shortcuts

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