Documentation ¶
Index ¶
- Variables
- func IsArmored(key string) bool
- type Client
- func (c *Client) Cleanup() error
- func (c *Client) GetDirs() error
- func (c *Client) GetVersion() (*Version, error)
- func (c *Client) ImportKey() error
- func (c *Client) ReadPrivateKey() error
- func (c *Client) SetHomedir(path string) error
- func (c *Client) SetTrustLevel(level string) error
- func (c *Client) SignFile(armor, detach, clear bool, path string) error
- type Dirs
- type Key
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( ErrDirLookupFailed = errors.New("failed to lookup gpg directories") ErrInvalidTrustLevel = errors.New("invlaid key owner trust level") ErrGetKeygripsFailed = errors.New("failed to get keygrips") )
var ( ErrPrimaryIdentityNotFound = errors.New("no primary identity found") ErrReadKeyFailed = errors.New("failed to read private key") )
Functions ¶
Types ¶
type Client ¶
func (*Client) Cleanup ¶
Cleanup removes the home directory for the given key, if one was specified. It returns any error encountered while removing the directory.
func (*Client) GetDirs ¶
GetDirs queries gpgconf to get the GnuPG directory paths and populates the Dirs struct with the results. It parses the gpgconf output to extract the lib, libexec, data and home dirs.
func (*Client) GetVersion ¶
GetVersion queries gpg to get the version information and populates the Version struct with the results.
func (*Client) ImportKey ¶
ImportKey imports a GPG key provided via the Key.Content field. It runs the gpg --import command to import the key into the keyring. Returns an error if the import command fails.
func (*Client) ReadPrivateKey ¶
ReadPrivateKey reads a private key from the given Key struct. It parses the armored key content into a gopenpgp private key. It returns the key ID, creation time, identity, and fingerprint. It returns an error if the key could not be parsed or the primary identity was not found.
func (*Client) SetHomedir ¶
SetHomedir sets the home directory path for the GPG client. It creates the directory if it doesn't exist and sets the GNUPGHOME environment variable to point to it.
func (*Client) SetTrustLevel ¶
SetTrustLevel sets the trust level for the public key in the client. It runs the gpg --edit-key command to set the trust level to the provided level string. Valid levels are "unknown", "never", "marginal", "full", "ultimate". Returns an error if the command fails.