km

package
v0.0.0-...-b9a05f1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrorsKMNotSupported occurs when the km type is not supported
	ErrorsKMNotSupported = errors.New("key manager type is not supported")
)

Functions

func RegisterKeyManager

func RegisterKeyManager(name string, f KeyManager) error

RegisterKeyManager provides a way to dynamically register an implementation of a key manager type.

If RegisterKeyManager is called twice with the same name if 'key manager type' is nil, or if the name is blank, it panics.

Types

type KeyManager

type KeyManager interface {
	// `url` is the database address or local directory (for example: /tmp/cache)
	New(url string) (KeyManager, error)
	Supported(url string) bool
	// proto: 'app/v1' for example
	// namespace : namespace
	GetPublicKey(proto string, namespace string) ([]byte, error)
	// proto: 'app/v1' for example
	// namespace : namespace
	Sign(proto string, namespace string, data []byte) ([]byte, error)
	// proto: 'app/v1' for example
	// namespace : namespace
	Decrypt(proto string, namespace string, data []byte) ([]byte, error)
}

KeyManager should be seperate from dockyard Now only assume that keys are existed in the backend key manager. It is up to each implementation to decide whether provides a way

to generate key pair automatically.

func NewKeyManager

func NewKeyManager(url string) (KeyManager, error)

NewKeyManager create a key manager by a url

type KeyManagerLocal

type KeyManagerLocal struct {
	Path string
}

func (*KeyManagerLocal) Decrypt

func (kml *KeyManagerLocal) Decrypt(proto string, namespace string, data []byte) ([]byte, error)

Sign signs a data of a namespace

func (*KeyManagerLocal) GetPublicKey

func (kml *KeyManagerLocal) GetPublicKey(proto string, namespace string) ([]byte, error)

GetPublicKey gets the public key data of a namespace

func (*KeyManagerLocal) New

func (kml *KeyManagerLocal) New(uri string) (KeyManager, error)

New returns a keymanager by a uri

func (*KeyManagerLocal) Sign

func (kml *KeyManagerLocal) Sign(proto string, namespace string, data []byte) ([]byte, error)

Sign signs a data of a namespace

func (*KeyManagerLocal) Supported

func (kml *KeyManagerLocal) Supported(uri string) bool

Supported checks if a uri is local path

Jump to

Keyboard shortcuts

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