crypto

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EncryptionKeyFile string

Functions

func BackupKey

func BackupKey(client api.Client) error

func CreateKeyFingerprintFile

func CreateKeyFingerprintFile() error

func Decrypt

func Decrypt(prov Provider, text []byte) ([]byte, error)

func DownloadBackup

func DownloadBackup(client api.Client, name string) error

func Encrypt

func Encrypt(prov Provider, text []byte) ([]byte, error)

func Flush

func Flush(prov Provider) error

func GetKeyID

func GetKeyID() (string, error)

func Identity

func Identity() (*age.X25519Identity, error)

func RandStr

func RandStr(length int) (string, error)

func RandString

func RandString(length int) string

func RandStringWithCharset

func RandStringWithCharset(length int, charset string) string

func Setup

func Setup(key string) error

func SetupAge

func SetupAge(client api.Client, emails []string) error

func SetupIdentity

func SetupIdentity(client api.Client, name string) error

Types

type AESKey

type AESKey struct {
	Key string
}

func DeserializeKey

func DeserializeKey(contents []byte) (k *AESKey, err error)

func Import

func Import(buf []byte) (*AESKey, error)

func Materialize

func Materialize() (*AESKey, error)

func Read

func Read(path string) (*AESKey, error)

func (*AESKey) Flush

func (k *AESKey) Flush() error

func (*AESKey) ID

func (k *AESKey) ID() string

func (*AESKey) Marshal

func (k *AESKey) Marshal() ([]byte, error)

type Age

type Age struct {
	RepoKey    string
	Identities []*AgeIdentity
}

func (*Age) Flush

func (age *Age) Flush() error

func (*Age) Recipients

func (a *Age) Recipients() []age.Recipient

func (*Age) WriteKeyFile

func (age *Age) WriteKeyFile(path string, keydata []byte) error

type AgeIdentity

type AgeIdentity struct {
	Key   string
	Email string
}

type AgeProvider

type AgeProvider struct {
	Identity *age.X25519Identity
	Key      *AESKey
}

func BuildAgeProvider

func BuildAgeProvider() (prov *AgeProvider, err error)

func (*AgeProvider) ID

func (prov *AgeProvider) ID() string

func (*AgeProvider) Marshall

func (prov *AgeProvider) Marshall() ([]byte, error)

func (*AgeProvider) SymmetricKey

func (prov *AgeProvider) SymmetricKey() ([]byte, error)

type Config

type Config struct {
	Version string
	Type    IdentityType
	Id      string
	Context *Context
}

func ReadConfig

func ReadConfig() (conf *Config, err error)

type Context

type Context struct {
	Key *KeyConfig `yaml:"key" json:"key"`
}

type IdentityType

type IdentityType string
const (
	KEY IdentityType = "key"
	AGE IdentityType = "age"
)

type KeyConfig

type KeyConfig struct {
	File string
}

type KeyProvider

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

func (*KeyProvider) ID

func (prov *KeyProvider) ID() string

func (*KeyProvider) Marshall

func (prov *KeyProvider) Marshall() ([]byte, error)

func (*KeyProvider) SymmetricKey

func (prov *KeyProvider) SymmetricKey() ([]byte, error)

type KeyValidator

type KeyValidator struct {
	KeyID string
}

func (*KeyValidator) Flush

func (k *KeyValidator) Flush() error

func (*KeyValidator) Marshal

func (k *KeyValidator) Marshal() ([]byte, error)

type Provider

type Provider interface {
	ID() string
	SymmetricKey() ([]byte, error)
	Marshall() ([]byte, error)
}

func Build

func Build() (prov Provider, err error)

Jump to

Keyboard shortcuts

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