pinentry

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Info = server.ProtoInfo{
	Greeting: "PinGO (w32)",
	Handlers: map[string]server.CommandHandler{
		"SETDESC":          setDesc,
		"SETPROMPT":        setPrompt,
		"SETREPEAT":        setRepeat,
		"SETREPEATERROR":   setRepeatError,
		"SETERROR":         setError,
		"SETOK":            setOk,
		"SETNOTOK":         setNotOk,
		"SETCANCEL":        setCancel,
		"SETQUALITYBAR":    setQualityBar,
		"SETQUALITYBAR_TT": setQualityBarToolTip,
		"SETGENPIN":        setGenPINLabel,
		"SETGENPIN_TT":     setGenPINToolTip,
		"SETTITLE":         setTitle,
		"SETTIMEOUT":       setTimeout,
		"CLEARPASSPHRASE":  clearPassphrase,
		"GETINFO":          getInfo,
		"SETKEYINFO":       setKeyInfo,
		"RESET":            resetState,
	},
	Help: map[string][]string{},
	GetDefaultState: func() interface{} {
		var s = DefaultSettings
		return &s
	},
	SetOption: setOpt,
}

Info is our pinentry protocol definition.

Functions

func CredentialName

func CredentialName(key string) string

CredentialName generates name of credential to be used as a key to store it in external cache.

func Serve

func Serve(callbacks Callbacks, ver string) error

Serve handles pinentry protocol.

Types

type Callbacks

type Callbacks struct {
	GetPIN  func(*common.Pipe, *Settings) (string, *common.Error)
	Confirm func(*common.Pipe, *Settings) (bool, *common.Error)
	Msg     func(*common.Pipe, *Settings) *common.Error
}

Callbacks list functions to be implemented by caller.

type Client

type Client struct {
	Session *assuan.Session
	// contains filtered or unexported fields
}

Client for Assuan Session.

func Launch

func Launch() (*Client, error)

Launch starts pinentry binary found in directories from PATH envvar and creates pinentry.Client for interaction with it.

func LaunchCustom

func LaunchCustom(path string) (Client, error)

LaunchCustom starts pinentry binary specified by passed path and creates pinentry.Client for interaction with it.

func New

func New(stream io.ReadWriter) (Client, error)

New initializes Client but does not start pinentry binary.

func (*Client) Apply

func (c *Client) Apply(s Settings) error

Apply initializes current settings.

func (*Client) Close

func (c *Client) Close() error

Close ends Session.

func (*Client) Confirm

func (c *Client) Confirm() error

Confirm shows window with Cancel and Ok buttons but without password textbox, error is returned if Cancel is pressed (as usual).

func (*Client) Current

func (c *Client) Current() Settings

Current returns a copy of current settings.

func (*Client) GetPIN

func (c *Client) GetPIN() (string, error)

GetPIN shows window with password textbox, Cancel and Ok buttons. Error is returned if Cancel is pressed.

func (*Client) Message

func (c *Client) Message() error

Message just shows window with only OK button.

func (*Client) Reset

func (c *Client) Reset() error

Reset resets Session.

func (*Client) SetCancelBtn

func (c *Client) SetCancelBtn(text string) error

SetCancelBtn sends SETCANCEL Assuan command and stores results.

func (*Client) SetDesc

func (c *Client) SetDesc(text string) error

SetDesc sends SETDESC Assuan command and stores results.

func (*Client) SetError

func (c *Client) SetError(text string) error

SetError sends SETERROR Assuan command and stores results.

func (*Client) SetNotOkBtn

func (c *Client) SetNotOkBtn(text string) error

SetNotOkBtn sends SETNOTOK Assuan command and stores results.

func (*Client) SetOkBtn

func (c *Client) SetOkBtn(text string) error

SetOkBtn sends SETOK Assuan command and stores results.

func (*Client) SetPasswdQualityCallback

func (c *Client) SetPasswdQualityCallback(callback func(string) int)

SetPasswdQualityCallback stores quality check callback.

func (*Client) SetPrompt

func (c *Client) SetPrompt(text string) error

SetPrompt sends SETPROMPT Assuan command and stores results.

func (*Client) SetQualityBar

func (c *Client) SetQualityBar(text string) error

SetQualityBar sends SETQUALITYBAR Assuan command and stores results.

func (*Client) SetRepeatError

func (c *Client) SetRepeatError(text string) error

SetRepeatError sends SETREPEATERROR Assuan command and stores results.

func (*Client) SetRepeatPrompt

func (c *Client) SetRepeatPrompt(text string) error

SetRepeatPrompt sends SETREPEAT Assuan command and stores results.

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration) error

SetTimeout sends SETTIMEOUT Assuan command and stores results.

func (*Client) SetTitle

func (c *Client) SetTitle(text string) error

SetTitle sends SETTITLE Assuan command and stores results.

type Options

type Options struct {
	Grab                bool
	AllowExtPasswdCache bool
	Display             string
	TTYType             string
	TTYName             string
	TTYAlert            string
	LCCtype             string
	LCMessages          string
	Owner               string
	TouchFile           string
	ParentWID           string
	InvisibleChar       string
}

Options part of Setting structure.

func (*Options) String

func (o *Options) String() string

type Settings

type Settings struct {
	// Some commands now allow argument passing
	CmdArgs string
	// Detailed description of request.
	Desc string
	// Text right before textbox.
	Prompt string
	// Error to show. Reset after GetPin.
	Error string
	// Text on OK button.
	OkBtn string
	// Text on NOT OK button.
	// Broken in GnuPG's pinentry (2.2.5).
	NotOkBtn string
	// Text on CANCEL button.
	CancelBtn string
	// Window title.
	Title string
	// Prompt timeout. Any user interaction disables timeout.
	Timeout time.Duration
	// Text right before repeat textbox.
	// Repeat textbox is hidden after GetPin.
	RepeatPrompt string
	// Error text to be shown if passwords do not match.
	RepeatError string
	// Text before password quality bar.
	QualityBar, QualityBarToolTip string
	// label and tooltip to be used for a generate action.
	GenPINLabel, GenPINToolTip string
	// To identify a key for caching - empty string mean that the key does not have a stable identifier.
	KeyInfo string
	// Password quality callback.
	PasswordQuality func(string) int

	Opts Options

	// For getInfo
	Ver string
}

Settings struct contains options for pinentry prompt.

var DefaultSettings Settings

DefaultSettings keep global initial state to avoid initialization loop.

func (*Settings) String

func (s *Settings) String() string

Jump to

Keyboard shortcuts

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