gpg

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package gpg provides encrypted files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectGPGPubKeys

func CollectGPGPubKeys(fp string) (*openpgp.EntityList, error)

CollectGPGPubKeys returns an EntityList from a place of pub keys

func Encrypt

func Encrypt(d []byte, encryptionKeys *openpgp.EntityList, useArmor bool) ([]byte, error)

Encrypt the provided bytes for the provided encryption keys recipients. Returns the encrypted content bytes.

func EncryptToWithCmd

func EncryptToWithCmd(cmd *cobra.Command) (*openpgp.EntityList, error)

EncryptToWithCmd uses a cobra.Command to create an EntityList

func KeyTypeCompletion added in v0.11.0

func KeyTypeCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)

KeyTypeCompletion returns shell completion

func NewKeyFilesWithPair

func NewKeyFilesWithPair(kp *KeyPair, dest string) ([]string, error)

NewKeyFilesWithPair Given a keypair object, write the contents to a public and private key file, returning those paths

func ReadEntity

func ReadEntity(name string) (*openpgp.Entity, error)

ReadEntity returns an Entity from a string

Types

type FileInfo

type FileInfo struct {
	FileName         string
	Data             []byte
	OriginalFileInfo os.FileInfo
	IsDirectory      bool
}

FileInfo is information about a GPGFile

func NewFileInfo

func NewFileInfo(data []byte, ogi os.FileInfo) (*FileInfo, error)

NewFileInfo returns a new FileInfo

func (FileInfo) IsDir

func (gfi FileInfo) IsDir() bool

IsDir returns a boolean representing if the file is also a Dir

func (FileInfo) ModTime

func (gfi FileInfo) ModTime() time.Time

ModTime returns the files modification time

func (FileInfo) Mode

func (gfi FileInfo) Mode() os.FileMode

Mode returns the file mode

func (FileInfo) Name

func (gfi FileInfo) Name() string

Name is the name of a file

func (FileInfo) Size

func (gfi FileInfo) Size() int64

Size is the size of a file in bytes

func (FileInfo) Sys

func (gfi FileInfo) Sys() interface{}

Sys is just a placeholder right now

type KeyOpts

type KeyOpts struct {
	Name       string
	Email      string
	KeyType    string
	Bits       int
	Passphrase []byte
}

KeyOpts is options for a gpg key

type KeyPair

type KeyPair struct {
	Private string
	Public  string
}

KeyPair represents both the public and private keys

func NewKeyPair

func NewKeyPair(opts *KeyOpts) (*KeyPair, error)

NewKeyPair generates a new gpg private and public key

type KeyType added in v0.11.0

type KeyType int

KeyType represents the different types of GPG keys supported

const (
	// NullKeyType is the unset value for this type
	NullKeyType KeyType = iota
	// RSAKeyType represents and RSA key. This is the most commonly used option
	RSAKeyType
	// X25519Type is an elliptic curve Diffie-Hellman key exchange using
	// Curve25519. It allows two parties to jointly agree on a shared secret
	// using an insecure channel.
	X25519Type
)

func (*KeyType) MarshalJSON added in v0.11.0

func (k *KeyType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that json conversions use the string value here, not the int value

func (*KeyType) Set added in v0.11.0

func (k *KeyType) Set(v string) error

Set helps fulfill the pflag.Value interface

func (KeyType) String added in v0.11.0

func (k KeyType) String() string

func (KeyType) Type added in v0.11.0

func (k KeyType) Type() string

Type satisfies part of the pflags.Value interface

Jump to

Keyboard shortcuts

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