Documentation
¶
Index ¶
- Variables
- func ContextKey(context *ctx.Context) ([]byte, error)
- func Decrypt(cypherBase64 []byte, nonceBase64 string, key []byte) ([]byte, error)
- func Encrypt(plainText []byte, nonceBase64 string, key []byte) []byte
- func Lock(key []byte, lockable Lockable) error
- func LockMany(key []byte, plainTexts []*string) error
- func LockString(key []byte, plainText *string) error
- func NewNonce() (string, error)
- func Unlock(key []byte, lockable Lockable) error
- func UnlockMany(key []byte, cypherTexts []*string) error
- type EncryptedFloat
- func (ef EncryptedFloat) EncryptableString() *string
- func (ef *EncryptedFloat) Float64() (float64, error)
- func (ef EncryptedFloat) MarshalJSON() ([]byte, error)
- func (ef *EncryptedFloat) Scan(value interface{}) error
- func (ef *EncryptedFloat) SetFloat(f float64)
- func (ef EncryptedFloat) String() string
- func (ef *EncryptedFloat) UnmarshalJSON(raw []byte) error
- func (ef EncryptedFloat) Value() (driver.Value, error)
- type EncryptedJSON
- func (j EncryptedJSON) EncryptableString() *string
- func (j EncryptedJSON) MarshalJSON() ([]byte, error)
- func (j *EncryptedJSON) Scan(src interface{}) error
- func (j EncryptedJSON) String() string
- func (j *EncryptedJSON) UnmarshalJSON(data []byte) error
- func (j EncryptedJSON) Value() (driver.Value, error)
- type Key
- type Lockable
- type Payload
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrNoKeyHandler = errors.New("No lynx.KeyHandler function has been set")
ErrNoKeyHandler is returned when attempting to find a key with no handler set.
var KeyHandler func(*ctx.Context) ([]byte, error)
KeyHandler is the function that returns an unlock key for a context.
var MaxNonceAttempts = 5
MaxNonceAttempts represents how many times we will retry generating a nonce.
Functions ¶
func ContextKey ¶
ContextKey returns the key for the supplied context by calling a registered handler.
func Lock ¶
Lock takes a lockable and encrypts its fields with the supplied key. If no nonce is set, one will be set for it.
func LockString ¶
LockString decrypts an array of cyphers.
func UnlockMany ¶
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.
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.
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 Store ¶
Store instances can be used to register Lockable instances against for later unlocking or locking.
func ContextStore ¶
ContextStore gets or creates a store for the supplied context.