Documentation ¶
Overview ¶
Package pinentry provides a client to GnuPG's pinentry.
See info pinentry. See https://www.gnupg.org/related_software/pinentry/index.html. See https://www.gnupg.org/documentation/manuals/assuan.pdf.
Index ¶
- Constants
- func IsCancelled(err error) bool
- type AssuanError
- type Client
- type ClientOption
- func WithArgs(args []string) ClientOption
- func WithBinaryName(binaryName string) ClientOption
- func WithBinaryNameFromGnuPGAgentConf() (clientOption ClientOption)
- func WithCancel(cancel string) ClientOption
- func WithCommand(command string) ClientOption
- func WithCommandf(format string, args ...interface{}) ClientOption
- func WithDebug() ClientOption
- func WithDesc(desc string) ClientOption
- func WithError(err string) ClientOption
- func WithGPGTTY() ClientOption
- func WithGenPIN(genPIN string) ClientOption
- func WithGenPINToolTip(genPINTT string) ClientOption
- func WithKeyInfo(keyInfo string) ClientOption
- func WithLogger(logger *slog.Logger) ClientOption
- func WithNoGlobalGrab() ClientOption
- func WithNotOK(notOK string) ClientOption
- func WithOK(ok string) ClientOption
- func WithOption(option string) ClientOption
- func WithOptions(options []string) ClientOption
- func WithProcess(process Process) ClientOption
- func WithPrompt(prompt string) ClientOption
- func WithQualityBar(qualityFunc QualityFunc) ClientOption
- func WithQualityBarToolTip(qualityBarTT string) ClientOption
- func WithRepeat(repeat string) ClientOption
- func WithRepeatError(repeatError string) ClientOption
- func WithRepeatOK(repeatOK string) ClientOption
- func WithTimeout(timeout time.Duration) ClientOption
- func WithTitle(title string) ClientOption
- type GetPINResult
- type Process
- type QualityFunc
- type UnexpectedResponseError
Constants ¶
const ( OptionAllowExternalPasswordCache = "allow-external-password-cache" OptionDefaultOK = "default-ok" OptionDefaultCancel = "default-cancel" OptionDefaultPrompt = "default-prompt" OptionTTYName = "ttyname" OptionTTYType = "ttytype" OptionLCCType = "lc-ctype" )
Options.
const (
AssuanErrorCodeCancelled = 83886179
)
Error codes.
Variables ¶
This section is empty.
Functions ¶
func IsCancelled ¶
IsCancelled returns if the error is operation cancelled.
Types ¶
type AssuanError ¶
An AssuanError is returned when an error is sent over the Assuan protocol.
func (*AssuanError) Error ¶
func (e *AssuanError) Error() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a pinentry client.
func NewClient ¶
func NewClient(options ...ClientOption) (c *Client, err error)
NewClient returns a new Client with the given options.
func (*Client) ClearPassphrase ¶
ClearPassphrase clears the cached passphrase associated with the key identified by cacheID.
func (*Client) GetPIN ¶
func (c *Client) GetPIN() (GetPINResult, error)
GetPIN gets a PIN from the user. If the user cancels, an error is returned which can be tested with IsCancelled.
type ClientOption ¶
type ClientOption func(*Client)
A ClientOption sets an option on a Client.
func WithArgs ¶
func WithArgs(args []string) ClientOption
WithArgs appends extra arguments to the pinentry command.
func WithBinaryName ¶
func WithBinaryName(binaryName string) ClientOption
WithBinaryName sets the name of the pinentry binary name. The default is pinentry.
func WithBinaryNameFromGnuPGAgentConf ¶
func WithBinaryNameFromGnuPGAgentConf() (clientOption ClientOption)
WithBinaryNameFromGnuPGAgentConf sets the name of the pinentry binary by reading ~/.gnupg/gpg-agent.conf, if it exists.
func WithCancel ¶
func WithCancel(cancel string) ClientOption
WithCancel sets the cancel button text.
func WithCommand ¶
func WithCommand(command string) ClientOption
WithCommand appends an Assuan command that is sent when the connection is established.
func WithCommandf ¶
func WithCommandf(format string, args ...interface{}) ClientOption
WithCommandf appends an Assuan command that is sent when the connection is established, using fmt.Sprintf to format the command.
func WithDebug ¶
func WithDebug() ClientOption
WithDebug tells the pinentry command to print debug messages.
func WithGenPIN ¶
func WithGenPIN(genPIN string) ClientOption
WithGenPIN sets the label to be used for a generate action.
func WithGenPINToolTip ¶
func WithGenPINToolTip(genPINTT string) ClientOption
WithGenPINToolTip sets the tooltip to be used for a generate action.
func WithKeyInfo ¶
func WithKeyInfo(keyInfo string) ClientOption
WithKeyInfo sets a stable key identifier for use with password caching.
func WithNoGlobalGrab ¶
func WithNoGlobalGrab() ClientOption
WithNoGlobalGrab instructs pinentry to only grab the password when the window is focused.
func WithNotOK ¶
func WithNotOK(notOK string) ClientOption
WithNotOK sets the text of the non-affirmative response button.
func WithOptions ¶
func WithOptions(options []string) ClientOption
WithOptions sets multiple options.
func WithQualityBar ¶
func WithQualityBar(qualityFunc QualityFunc) ClientOption
WithQualityBar enables the quality bar.
func WithQualityBarToolTip ¶
func WithQualityBarToolTip(qualityBarTT string) ClientOption
WithQualityBarToolTip sets the quality bar tool tip.
func WithRepeat ¶
func WithRepeat(repeat string) ClientOption
WithRepeat sets the repeat passphrase.
func WithRepeatError ¶
func WithRepeatError(repeatError string) ClientOption
WithRepeatError sets the repeat error message.
func WithRepeatOK ¶
func WithRepeatOK(repeatOK string) ClientOption
WithRepeatOK sets the repeat OK message.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets the timeout.
type GetPINResult ¶
A GetPINResult is the result of a call to Client.GetPIN.
type Process ¶
type Process interface { io.WriteCloser ReadLine() ([]byte, bool, error) Start(string, []string) error }
A Process abstracts the interface to a pinentry Process.
type QualityFunc ¶
A QualityFunc evaluates the quality of a password. It should return a value between -100 and 100. The absolute value of the return value is used as the quality. Negative values turn the quality bar red. The boolean return value indicates whether the quality is valid.
type UnexpectedResponseError ¶
type UnexpectedResponseError struct {
Line string
}
An UnexpectedResponseError is returned when an unexpected response is received.
func (UnexpectedResponseError) Error ¶
func (e UnexpectedResponseError) Error() string