Documentation ¶
Index ¶
- Constants
- Variables
- func EachKey(keys map[uint32]KeyHandler, callback func(uint32, KeyHandler) error) error
- func ExchangeDir(toplevel string) string
- func ExchangeMasterKeyFile(stub string) string
- func ExchangePubKeyFile(stub string) string
- type KeyHandler
- type MasterKey
- func (k *MasterKey) Decode(reader io.Reader, writer io.Writer) error
- func (k *MasterKey) Encode(encodingFormat uint32, epoch uint32, reader io.Reader, writer io.Writer) error
- func (k *MasterKey) ExchangeDir() (string, error)
- func (k *MasterKey) FileStatus(reader io.Reader) (bool, uint32)
- func (k *MasterKey) Generate() error
- func (k *MasterKey) GetExchangeFilenameStubFor(fingerprint [20]byte) (string, error)
- func (k *MasterKey) Key(epoch uint32) (KeyHandler, error)
- func (k *MasterKey) KeyFile() string
- func (k *MasterKey) Load() error
- func (k *MasterKey) Read(f io.Reader) error
- func (k *MasterKey) Save() error
- func (k *MasterKey) SaveTo(writer io.Writer) error
- func (k *MasterKey) String() string
Constants ¶
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" )
const ( // KeyMagic magic string the key file starts with KeyMagic = "\000REDACT\000" // KeyCurrentType current key file version KeyCurrentType = 0 )
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" )
const (
// FileMagic magic string the encoded file starts with
FileMagic = "\000REDACTED\000"
)
Variables ¶
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 ¶
ExchangeDir returns Key Exchange dir inside the git repo
func ExchangeMasterKeyFile ¶
ExchangeMasterKeyFile returns full filename for Master key exchange
func ExchangePubKeyFile ¶
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 ¶
NewMasterKey generates a new repo key in the OS' filesystem
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 ¶
ExchangeDir returns key exchange directory if exists
func (*MasterKey) FileStatus ¶
FileStatus returns file encryption status and key used
func (*MasterKey) GetExchangeFilenameStubFor ¶
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.