files

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: BlueOak-1.0.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ExtKeyArmor is public key ASCII armor file extension in Key Exchange folder
	ExtKeyArmor = ".asc"
	// ExtMaster is encrypted master key file extension in Key Exchange folder
	ExtMaster = ".key"
)
View Source
const (
	// KeyMagic magic string the key file starts with
	KeyMagic = "\000REDACT\000"
	// KeyCurrentType current key file version
	KeyCurrentType = 0
)
View Source
const (
	// DefaultKeyDir contains standard key directory name inside .git/ directory
	DefaultKeyDir = "redact"
	// DefaultKeyFile contains standard key file name inside key directory
	DefaultKeyFile = "key"
	// DefaultKeyExchangeDir is where key exchange files are stored
	DefaultKeyExchangeDir = ".redact"
)
View Source
const (
	// FileMagic magic string the encoded file starts with
	FileMagic = "\000REDACTED\000"
)

Variables

View Source
var GitDirFunc = gitutil.GitDir

Functions

func EachKey

func EachKey(keys map[uint32]KeyHandler, callback func(uint32, KeyHandler) error) error

EachKey loops over keys by ascending order by epoch number

func ExchangeDir

func ExchangeDir(toplevel string) string

ExchangeDir returns Key Exchange dir inside the git repo

func ExchangeMasterKeyFile

func ExchangeMasterKeyFile(stub string) string

ExchangeMasterKeyFile returns full filename for Master key exchange

func ExchangePubKeyFile

func ExchangePubKeyFile(stub string) string

ExchangePubKeyFile returns full filename for Public key ASCII armor

Types

type KeyHandler

type KeyHandler interface {
	// Type returns key format type
	Type() uint32
	// Version returns epoch version number
	// Each time a new key is created, it must be stored with a different
	// epoch number. New encryptions must use latest key version.
	Version() uint32
	// Generate creates a new key, which is completely out of control of
	// the user. It is using secure random for generating the keys.
	Generate() error
	// Secret returns the Secret key
	Secret() []byte
	// String provides a string representation of the key. It is safe to show
	// it publicly.
	String() string
}

KeyHandler interface

type MasterKey

type MasterKey struct {
	afero.Fs
	*logrus.Logger
	RepoInfo  gitutil.GitRepoInfo
	KeyDir    string
	Keys      map[uint32]KeyHandler
	LatestKey uint32
	Cache     map[string]string
}

MasterKey contains master key in a git repository

func NewMasterKey

func NewMasterKey(l *logrus.Logger) (*MasterKey, error)

NewMasterKey generates a new repo key in the OS' filesystem

func (*MasterKey) Decode

func (k *MasterKey) Decode(reader io.Reader, writer io.Writer) error

Decode encodes an IO stream into another IO stream

func (*MasterKey) Encode

func (k *MasterKey) Encode(encodingFormat uint32, epoch uint32, reader io.Reader, writer io.Writer) error

Encode encodes an IO stream into another IO stream

func (*MasterKey) ExchangeDir

func (k *MasterKey) ExchangeDir() (string, error)

ExchangeDir returns key exchange directory if exists

func (*MasterKey) FileStatus

func (k *MasterKey) FileStatus(reader io.Reader) (bool, uint32)

FileStatus returns file encryption status and key used

func (*MasterKey) Generate

func (k *MasterKey) Generate() error

Generate generates a new master key

func (*MasterKey) GetExchangeFilenameStubFor

func (k *MasterKey) GetExchangeFilenameStubFor(fingerprint [20]byte) (string, error)

GetExchangeFilenameStubFor returns file name stub of the Key Exchange for an OpenPGP key identified by its full public key ID.

Add extensions for files:

- .asc: Public key ASCII armor file - .key: Master key encryped with public key

func (*MasterKey) Key

func (k *MasterKey) Key(epoch uint32) (KeyHandler, error)

Key returns the a key handler with a certain epoch. If epoch is 0, it returns the latest key.

func (*MasterKey) KeyFile

func (k *MasterKey) KeyFile() string

KeyFile returns master key's file name

func (*MasterKey) Load

func (k *MasterKey) Load() error

Load loads existing key

func (*MasterKey) Read

func (k *MasterKey) Read(f io.Reader) error

Read loads key from reader stream

func (*MasterKey) Save

func (k *MasterKey) Save() error

Save saves key

func (*MasterKey) SaveTo

func (k *MasterKey) SaveTo(writer io.Writer) error

SaveTo saves master key into IO stream

func (*MasterKey) String

func (k *MasterKey) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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