yubikey

package
v0.0.0-...-2db412b Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCardReaderUnavailable = errors.New("the specified reader is not currently available for use") // error 0x80100017

	ErrYubikeyNotOpen = errors.New("yubikey not opened")
)
View Source
var (
	SlotKeyRSAID   = uint32(0x95)
	SlotKeyECDSAID = uint32(0x94)

	SlotKeyRSA   = MustSlotFromKeyID(SlotKeyRSAID)
	SlotKeyECDSA = MustSlotFromKeyID(SlotKeyECDSAID)

	AllSSHSlots = []Slot{
		SlotKeyRSA,
		SlotKeyECDSA,
	}

	AllSlots = func() []Slot {
		out := []Slot{
			MustSlotFromKeyID(piv.SlotAuthentication.Key),
			MustSlotFromKeyID(piv.SlotSignature.Key),
			MustSlotFromKeyID(piv.SlotKeyManagement.Key),
			MustSlotFromKeyID(piv.SlotCardAuthentication.Key),
		}

		for id := uint32(0x82); id <= 0x95; id++ {
			out = append(out, MustSlotFromKeyID(id))
		}

		return out
	}()
)

Functions

func GenerateManagementKey

func GenerateManagementKey() ([24]byte, error)

func GeneratePinCode

func GeneratePinCode() (string, error)

func GeneratePukCode

func GeneratePukCode() (string, error)

func MapPINPolicy

func MapPINPolicy(name string) (piv.PINPolicy, bool)

func MapToStrPINPolicy

func MapToStrPINPolicy(policy piv.PINPolicy) (string, bool)

func MapToStrTouchPolicy

func MapToStrTouchPolicy(policy piv.TouchPolicy) (string, bool)

func MapTouchPolicy

func MapTouchPolicy(name string) (piv.TouchPolicy, bool)

func ValidatePin

func ValidatePin(pin string) bool

func ValidatePuk

func ValidatePuk(puk string) bool

Types

type Card

type Card struct {
	Name    string
	Serial  uint32
	Version string
}

func Cards

func Cards() ([]Card, error)

func (*Card) String

func (c *Card) String() string

type Cert

type Cert struct {
	*x509.Certificate
	Slot Slot
}

type CertRequest

type CertRequest struct {
	piv.Key
	CommonName string
	Days       int
}

type Slot

type Slot struct {
	PIVSlot piv.Slot
}

func MustSlotFromKeyID

func MustSlotFromKeyID(keyID uint32) Slot

func SlotFromKeyID

func SlotFromKeyID(keyID uint32) (Slot, error)

func (Slot) String

func (s Slot) String() string

type Yubikey

type Yubikey struct {
	Serial uint32
	// contains filtered or unexported fields
}

func Open

func Open(card Card) (*Yubikey, error)

func OpenBySerial

func OpenBySerial(serial uint32) (*Yubikey, error)

func (*Yubikey) Close

func (y *Yubikey) Close() error

func (*Yubikey) GenCertificate

func (y *Yubikey) GenCertificate(slot Slot, pin string, req CertRequest) (*x509.Certificate, error)

func (*Yubikey) GetActiveSlots

func (y *Yubikey) GetActiveSlots(slots ...Slot) ([]Slot, error)

func (*Yubikey) GetCertPublicKey

func (y *Yubikey) GetCertPublicKey(slot piv.Slot) (crypto.PublicKey, error)

func (*Yubikey) ListKeys

func (y *Yubikey) ListKeys(slots ...Slot) ([]Cert, error)

func (*Yubikey) PrivateKey

func (y *Yubikey) PrivateKey(slot piv.Slot, public crypto.PublicKey, auth piv.KeyAuth) (crypto.PrivateKey, error)

func (*Yubikey) Reset

func (y *Yubikey) Reset(newPIN, newPUK string) error

func (*Yubikey) ResetMngmtKey

func (y *Yubikey) ResetMngmtKey(newKey [24]byte) error

func (*Yubikey) ResetToDefault

func (y *Yubikey) ResetToDefault() error

func (*Yubikey) Retries

func (y *Yubikey) Retries() (int, error)

func (*Yubikey) SetPIN

func (y *Yubikey) SetPIN(currentPIN, newPIN string) error

func (*Yubikey) SetPUK

func (y *Yubikey) SetPUK(currentPUK, newPUK string) error

func (*Yubikey) Unblock

func (y *Yubikey) Unblock(pukCode, newPIN string) error

func (*Yubikey) VerifyPIN

func (y *Yubikey) VerifyPIN(pin string) error

Jump to

Keyboard shortcuts

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