agent

package
v0.0.0-...-b2a87f5 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CardSexUnspecified CardSex = 0
	CardSexMale                = 1
	CardSexFemale              = 2
)

These constants define the possible CardSex values.

View Source
const (
	SignatureKey = iota
	EncryptionKey
	AuthenticationKey
)

The IDs of the different subkeys

Variables

View Source
var (
	ErrUnknownFormat = errors.New("s-expression is in unknown format")
	ErrNotPublicKey  = errors.New("s-expression is not a public key")
	ErrNotSignature  = errors.New("s-expression is not a signature")
)

These errors may be returned from the functions related to s-expression encoding and decoding.

Functions

This section is empty.

Types

type Card

type Card struct {
	Reader  string
	Serial  string
	AppType string
	ExtCap  string

	LoginData       string
	DisplayName     string
	DisplayLanguage string
	DisplaySex      CardSex
	PubkeyURL       string

	SignatureCounter   int
	SignaturePINCached bool
	MaxPINLength       [cardMaxKeyNumber]int
	PINRetryCounter    [cardMaxKeyNumber]int

	Subkeys [cardMaxKeyNumber]*CardKey
	// contains filtered or unexported fields
}

Card describes the information gpg-agent exposes about a card

func (*Card) AddKey

func (card *Card) AddKey(subKey int) error

AddKey will generate a new key on the card

func (*Card) AuthenticationKey

func (card *Card) AuthenticationKey() *CardKey

AuthenticationKey returns the card authentication key (or nil if it's missing)

func (*Card) CheckPIN

func (card *Card) CheckPIN(admin bool) error

CheckPIN will check the requested password (potentially cached, might need unplugging for subsequent calls)

func (*Card) EncryptionKey

func (card *Card) EncryptionKey() *CardKey

EncryptionKey returns the card encryption key (or nil if it's missing)

func (*Card) FactoryReset

func (card *Card) FactoryReset() error

FactoryReset will ensure the key is completely wiped out, see https://support.yubico.com/support/solutions/articles/15000006421-resetting-the-openpgp-applet-on-your-yubikey for more information

func (*Card) ResetPassword

func (card *Card) ResetPassword(admin bool) error

ResetPassword will unblock the requested password

func (*Card) SetDisplayLanguage

func (card *Card) SetDisplayLanguage(lang string) error

SetDisplayLanguage sets the display language on the given smart card

func (*Card) SetDisplayName

func (card *Card) SetDisplayName(name string) error

SetDisplayName sets the display name on the given smart card

func (*Card) SetDisplaySex

func (card *Card) SetDisplaySex(sex CardSex) error

SetDisplaySex sets the display sex on the given smart card

func (*Card) SetLoginData

func (card *Card) SetLoginData(loginData string) error

SetLoginData sets the login data on the given smart card

func (*Card) SetPIN

func (card *Card) SetPIN(admin bool) error

SetPIN will provide a prompt to set the requested password

func (*Card) SignatureKey

func (card *Card) SignatureKey() *CardKey

SignatureKey returns the card signature key (or nil if it's missing)

type CardKey

type CardKey struct {
	Key

	Created time.Time
}

CardKey describes the information gpg-agent exposes about a card key

type CardSex

type CardSex int

CardSex describes the sex specified on the card.

type Conn

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

Conn represents a single connection to a GPG agent.

func Dial

func Dial(filename string, options []string) (*Conn, error)

Dial connects to the specified unix domain socket and checks if there is a live GPG agent on the other end. If filename is "", try to find the path the socket automatically by calling gpgconf --list-dirs (see findAgentSocket).

func (*Conn) Close

func (conn *Conn) Close() error

Close this connection.

func (*Conn) CurrentCard

func (conn *Conn) CurrentCard() (*Card, error)

CurrentCard returns the currently connected smartcard, including its subkeys

func (*Conn) Key

func (conn *Conn) Key(keygrip string) (Key, error)

Key returns the key information for the key with the specified keygrip.

func (*Conn) KeyGrips

func (conn *Conn) KeyGrips() (map[string]string, error)

KeyGrips returns a list of available keysgrips, indexed by CardID, by querying the card

func (*Conn) Keys

func (conn *Conn) Keys() ([]Key, error)

Keys returns a list of available keys.

func (*Conn) Raw

func (conn *Conn) Raw(f ResponseFunc, format string, a ...interface{}) error

Raw executes a command and pipes its results to the specified ResponseFunc parameter.

func (*Conn) ReadKey

func (conn *Conn) ReadKey(keygrip string) (crypto.PublicKey, error)

ReadKey returns the public key for the key with the specified keygrip.

func (*Conn) Version

func (conn *Conn) Version() (string, error)

Version returns the version number of gpg-agent.

type Error

type Error struct {
	Code        int
	Description string
}

Error describes a gpg-agent error.

func NewError

func NewError(line string) Error

NewError parses a gpg-agent error.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

type Key

type Key struct {
	Keygrip     string
	Type        KeyType
	SerialNo    string
	CardID      string
	Cached      bool
	Protection  KeyProtection
	Fingerprint string
	TimeToLive  string
	// contains filtered or unexported fields
}

Key describes the information gpg-agent exposes about a key.

func (*Key) Decrypt

func (key *Key) Decrypt(rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)

Decrypt decrypts ciphertext with this key. If opts is nil or of type *PKCS1v15DecryptOptions then PKCS#1 v1.5 decryption is performed. Otherwise opts must have type *OAEPOptions and OAEP decryption is done.

This function is basically a copy of rsa.Decrypt().

func (*Key) Public

func (key *Key) Public() crypto.PublicKey

Public returns this key's public key.

func (*Key) Sign

func (key *Key) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error)

Sign signs msg with this key, possibly using entropy from rand. If opts is a *PSSOptions then the PSS algorithm will be used, otherwise PKCS#1 v1.5 will be used.

This function is basically a copy of rsa.Sign().

type KeyProtection

type KeyProtection int

KeyProtection describes the key project type.

const (
	ProtByPassphrase KeyProtection = iota
	ProtByNothing
	ProtUnknown
)

These constants define the possible KeyProtection values.

type KeyType

type KeyType int

KeyType describes the type of the key.

const (
	StoredOnDisk KeyType = iota
	StoredOnCard
	StoredUnknown
	StoredMissing
)

These constants define the possible KeyType values.

type ResponseFunc

type ResponseFunc func(respType, data string) error

ResponseFunc defines the function handler for the Raw function.

Directories

Path Synopsis
internal
rsa

Jump to

Keyboard shortcuts

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