identity

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// default privage secret key. It can be an age key of a PIV encoded age
	// key.
	DefaultFileName = "privage-key.txt"
	TypePiv         = "PIV"
	TypeAge         = "AGE"
)

Variables

This section is empty.

Functions

func BackupFilePath

func BackupFilePath(dir string) string

BackupFilePath returns a path for a backup identity file.

func DecryptPiv added in v0.23.0

func DecryptPiv(r io.Reader, device Device, slot uint32) ([]byte, error)

DecryptPiv returns the decrypted contents read from r, using the PIV device to decrypt with the key in the specified slot.

func FmtType

func FmtType(slot string) string

func GenerateAge added in v0.23.0

func GenerateAge(w io.Writer) error

GenerateAge generates an age Identity and writes it to the writer.

func GeneratePiv added in v0.23.0

func GeneratePiv(w io.Writer, device Device, slot uint32) (err error)

GeneratePiv generates a new age identity, encrypts it using the PIV device at the specified slot, and writes the ascii85-encoded result to w.

Types

type Device added in v0.23.0

type Device interface {
	// Decrypt decrypts ciphertext using the key in the specified slot.
	Decrypt(ciphertext []byte, slot uint32) ([]byte, error)
	// Encrypt encrypts plaintext using the key in the specified slot and writes
	// the result to w.
	Encrypt(w io.Writer, plaintext []byte, slot uint32) error
	// Close releases any resources associated with the device.
	Close() error
}

Device represents a PIV-compatible hardware device that can perform cryptographic operations like decryption.

type Identity

type Identity struct {

	// The age identity
	Id *age.X25519Identity

	// Path of the found key.
	// Path can contain a normal age key or a PIV encrypted one.
	//
	// Path can be not empty and still a null Id because of a decoding error.
	//
	// A empty Path means all possible paths were searched and no files were
	// found
	Path string

	// Err is the error raised finding or validating the a age identity.
	Err error
}

An Identity is a wrapper for the age Identity.

func LoadAge added in v0.23.0

func LoadAge(r io.Reader, path string) Identity

LoadAge returns an Age identity from an io.Reader. The path parameter is used for error messages and tracking.

func LoadPiv

func LoadPiv(r io.Reader, path string, device Device, slot uint32) Identity

LoadPiv returns the age identity read from r that is encrypted with PIV. The path parameter is used for error messages and tracking (no filesystem operations). TODO: Revisit signature - consider whether path should be part of Identity struct.

Directories

Path Synopsis
piv
yubikey
Package yubikey provides YubiKey PIV device integration for privage.
Package yubikey provides YubiKey PIV device integration for privage.

Jump to

Keyboard shortcuts

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