piv

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package piv implements a provider that derives a 32-byte secret from a PIV-compatible hardware token (e.g., YubiKey) using the go-piv library.

During enrollment, an ECC P-256 key is generated on the token in the chosen slot. A deterministic challenge is signed, and the signature is run through HKDF-SHA256 to produce the 32-byte secret. Because the private key never leaves the device, the secret is hardware-bound.

Requires: PC/SC (pcscd on Linux, CryptoTokenKit on macOS).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CardSerial

func CardSerial(cardName string) string

CardSerial opens a card by name and returns its serial number as a string. Returns "unknown" if the serial cannot be read.

func ListCards

func ListCards() ([]string, error)

ListCards wraps gopiv.Cards with actionable error messages for PC/SC conflicts.

func SlotHasKey

func SlotHasKey(cardName string, slot gopiv.Slot) (*ecdsa.PublicKey, error)

SlotHasKey checks if a PIV slot already has key material on the given card. Returns the public key if found, nil if empty. Uses the Yubico GET METADATA extension (KeyInfo), which is the same source `ykman piv info` reads, so cryptkey and ykman agree on slot occupancy.

Types

type PIV

type PIV struct{}

PIV is the PIV smart card provider.

func (*PIV) Derive

func (p *PIV) Derive(ctx context.Context, params map[string]string) ([]byte, error)

func (*PIV) DeriveTimeout

func (p *PIV) DeriveTimeout() time.Duration

func (*PIV) Description

func (p *PIV) Description() string

func (*PIV) Enroll

func (p *PIV) Enroll(ctx context.Context, id string) (*provider.EnrollResult, error)

func (*PIV) EnrollOptions

func (p *PIV) EnrollOptions() []provider.EnrollOption

func (*PIV) InteractiveDerive

func (p *PIV) InteractiveDerive() bool

func (*PIV) PreDerive

func (p *PIV) PreDerive(ctx context.Context, _ map[string]string) (context.Context, error)

PreDerive collects the PIV PIN before the timeout-wrapped ECDH operation.

func (*PIV) Type

func (p *PIV) Type() string

Jump to

Keyboard shortcuts

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