lynx

package
v0.0.0-...-795d1f5 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoKeyHandler = errors.New("No lynx.KeyHandler function has been set")

ErrNoKeyHandler is returned when attempting to find a key with no handler set.

View Source
var KeyHandler func(*ctx.Context) ([]byte, error)

KeyHandler is the function that returns an unlock key for a context.

View Source
var MaxNonceAttempts = 5

MaxNonceAttempts represents how many times we will retry generating a nonce.

Functions

func ContextKey

func ContextKey(context *ctx.Context) ([]byte, error)

ContextKey returns the key for the supplied context by calling a registered handler.

func Decrypt

func Decrypt(cypherBase64 []byte, nonceBase64 string, key []byte) ([]byte, error)

Decrypt decrypts a payload and returns the decrypted plaintext.

func Encrypt

func Encrypt(plainText []byte, nonceBase64 string, key []byte) []byte

Encrypt takes a plain text value and returns the encrypted cyphertext.

func Lock

func Lock(key []byte, lockable Lockable) error

Lock takes a lockable and encrypts its fields with the supplied key. If no nonce is set, one will be set for it.

func LockMany

func LockMany(key []byte, plainTexts []*string) error

LockMany decrypts an array of cyphers.

func LockString

func LockString(key []byte, plainText *string) error

LockString decrypts an array of cyphers.

func NewNonce

func NewNonce() (string, error)

NewNonce promises to return a new nonce for use in encrypting strings.

func Unlock

func Unlock(key []byte, lockable Lockable) error

Unlock takes a lockable and encrypts its fields with the supplied key.

func UnlockMany

func UnlockMany(key []byte, cypherTexts []*string) error

UnlockMany decrypts an array of cyphers.

Types

type EncryptedFloat

type EncryptedFloat struct {
	StringValue *string
}

EncryptedFloat represents a float that is encryptable as a string.

func NewEncryptedFloat

func NewEncryptedFloat(f float64) EncryptedFloat

NewEncryptedFloat returns a newly initialized EncryptedFloat.

func (EncryptedFloat) EncryptableString

func (ef EncryptedFloat) EncryptableString() *string

EncryptableString returns the underlying string pointer.

func (*EncryptedFloat) Float64

func (ef *EncryptedFloat) Float64() (float64, error)

Float64 returns a float64 representation of the EncryptedFloat.

func (EncryptedFloat) MarshalJSON

func (ef EncryptedFloat) MarshalJSON() ([]byte, error)

MarshalJSON marshals the current value into a json number.

func (*EncryptedFloat) Scan

func (ef *EncryptedFloat) Scan(value interface{}) error

Scan implements sql.Scanner for scanning database values.

func (*EncryptedFloat) SetFloat

func (ef *EncryptedFloat) SetFloat(f float64)

SetFloat updates the underlying float value.

func (EncryptedFloat) String

func (ef EncryptedFloat) String() string

String implements the stringer interface.

func (*EncryptedFloat) UnmarshalJSON

func (ef *EncryptedFloat) UnmarshalJSON(raw []byte) error

UnmarshalJSON will unmarshall a raw json representation of a number into an EncryptedFloat.

func (EncryptedFloat) Value

func (ef EncryptedFloat) Value() (driver.Value, error)

Value implements value.Valuer to provide database values.

type EncryptedJSON

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

EncryptedJSON represents json that is encryptable as a string.

func NewEncryptedJSON

func NewEncryptedJSON(j string) EncryptedJSON

NewEncryptedJSON returns a newly initialized EncryptedJSON.

func (EncryptedJSON) EncryptableString

func (j EncryptedJSON) EncryptableString() *string

EncryptableString returns the underlying string pointer.

func (EncryptedJSON) MarshalJSON

func (j EncryptedJSON) MarshalJSON() ([]byte, error)

MarshalJSON returns a []byte representation of the string.

func (*EncryptedJSON) Scan

func (j *EncryptedJSON) Scan(src interface{}) error

Scan implements sql.Scanner for scanning database values.

func (EncryptedJSON) String

func (j EncryptedJSON) String() string

String implements the stringer interface.

func (*EncryptedJSON) UnmarshalJSON

func (j *EncryptedJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON stores the supplied []byte data as a string.

func (EncryptedJSON) Value

func (j EncryptedJSON) Value() (driver.Value, error)

Value implements value.Valuer to provide database values.

type Key

type Key struct {
	KeyBase64    string             `json:"key_base64"`
	Key          []byte             `json:"-"`
	DecryptedKey []byte             `json:"-"`
	Context      map[string]*string `json:"context"`
	MasterID     string             `json:"master_id"`
	Region       string             `json:"region"`
}

Key is the type used for keys. This is the main structure used for encrypting/decrypting files and credntials.

type Lockable

type Lockable interface {
	LockableValues() []*string
}

Lockable defines an interface for objects that can be locked and unlocked.

type Payload

type Payload struct {
	CypherText []byte
	Nonce      []byte
}

Payload is the basic payload container for enc/dec operations.

type Store

type Store struct {
	Items   []Lockable
	Context *ctx.Context
}

Store instances can be used to register Lockable instances against for later unlocking or locking.

func ContextStore

func ContextStore(context *ctx.Context) *Store

ContextStore gets or creates a store for the supplied context.

func NewStore

func NewStore(context *ctx.Context) *Store

NewStore returns an initialized Store instance.

func (*Store) Save

func (store *Store) Save(items ...Lockable)

Save adds additional Lockable instances to the store.

func (*Store) Unlock

func (store *Store) Unlock() error

Unlock calls the Unlock method on all Lockable items.

Jump to

Keyboard shortcuts

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