skykey

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: MIT Imports: 13 Imported by: 5

README

Skykey Manager

The skykey package defines Skykeys used for encrypting files in Skynet and provides a way to persist Skykeys using a SkykeyManager that manages these keys in a file on-disk.

The file consists of a header which is: SkykeyFileMagic | SkykeyVersion | Length

The SkykeyFileMagic never changes. The version only changes when backwards-incompatible changes are made to the design of Skykeys or to the way this file is structured. The length refers to the number of bytes in the file.

When adding a Skykey to the file, a Skykey is unmarshaled and appended to the end of the file and the file is then synced. Then the length field in the header is updated to indicate the newly written bytes and the file is synced once again.

Skykeys

A Skykey is a key associated with a name to be used in Skynet to share encrypted files. Each key has a name and a unique identifier.

Documentation

Index

Constants

View Source
const (
	// SkykeyIDLen is the length of a SkykeyID
	SkykeyIDLen = 16

	// MaxKeyNameLen is the maximum length of a skykey's name.
	MaxKeyNameLen = 128
)

Variables

View Source
var (

	// SkykeySpecifier is used as a prefix when hashing Skykeys to compute their
	// ID.
	SkykeySpecifier = types.NewSpecifier("Skykey")

	// SkykeyFileMagic is the first piece of data found in a Skykey file.
	SkykeyFileMagic = types.NewSpecifier("SkykeyFile")

	// SkykeyPersistFilename is the name of the skykey persistence file.
	SkykeyPersistFilename = "skykeys.dat"
)

Functions

This section is empty.

Types

type Skykey

type Skykey struct {
	Name       string
	CipherType crypto.CipherType
	Entropy    []byte
}

Skykey is a key used to encrypt/decrypt skyfiles.

func (Skykey) ID

func (sk Skykey) ID() (keyID SkykeyID)

ID returns the ID for the Skykey.

type SkykeyID

type SkykeyID [SkykeyIDLen]byte

SkykeyID is the identifier of a skykey.

type SkykeyManager

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

SkykeyManager manages the creation and handling of new skykeys which can be referenced by their unique name or identifier.

func NewSkykeyManager

func NewSkykeyManager(persistDir string) (*SkykeyManager, error)

NewSkykeyManager creates a SkykeyManager for managing skykeys.

func (*SkykeyManager) AddKey

func (sm *SkykeyManager) AddKey(name string, cipherType crypto.CipherType, entropy []byte) (Skykey, error)

AddKey creates a key with the given name, cipherType, and entropy and adds it to the key file.

func (*SkykeyManager) CreateKey

func (sm *SkykeyManager) CreateKey(name string, cipherType crypto.CipherType) (Skykey, error)

CreateKey creates a new Skykey under the given name and cipherType.

func (*SkykeyManager) IDByName

func (sm *SkykeyManager) IDByName(name string) (SkykeyID, error)

IDByName returns the ID associated with the given key name.

func (*SkykeyManager) KeyByID

func (sm *SkykeyManager) KeyByID(id SkykeyID) (Skykey, error)

KeyByID returns the Skykey associated with that ID.

func (*SkykeyManager) KeyByName

func (sm *SkykeyManager) KeyByName(name string) (Skykey, error)

KeyByName returns the Skykey associated with that key name.

func (*SkykeyManager) SupportsCipherType

func (sm *SkykeyManager) SupportsCipherType(ct crypto.CipherType) bool

SupportsCipherType returns true if and only if the SkykeyManager supports keys with the given cipher type.

Jump to

Keyboard shortcuts

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