Documentation ¶
Index ¶
- Constants
- type Key
- func (k *Key) AsJSON() ([]byte, error)
- func (k *Key) Decrypt(block cipher.Block, blocksize int) ([]byte, error)
- func (k *Key) Disable()
- func (k *Key) FromJSON(byt []byte) error
- func (k *Key) GetNote() string
- func (k *Key) GetStatus() uint
- func (k *Key) GobDecode(byt []byte) error
- func (k *Key) GobEncode() ([]byte, error)
- func (k *Key) ID() string
- func (k *Key) SetNote(note string)
- type Smokering
- func (sr *Smokering) AsJSON() ([]byte, error)
- func (sr *Smokering) GetKey(id string) *Key
- func (sr *Smokering) GobEncode() ([]byte, error)
- func (sr *Smokering) Key(id, note string, block cipher.Block, blocksize int, f func() ([]byte, error)) (*Key, error)
- func (sr *Smokering) KeyFromGob(byt []byte) (*Key, error)
- func (sr *Smokering) KeyFromJSON(byt []byte) (*Key, error)
Constants ¶
const ( // StatusUnknown should only ever be set on an improperly intialized key. StatusUnknown uint = iota // StatusNew is for a new key that has never been decrypted or used. StatusNew // StatusUsed is set on a key that's been decryted at least once. StatusUsed // StatusDisabled is set on a key that's been disabled. StatusDisabled )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
Key represents an encryption key.
func (*Key) Decrypt ¶
Decrypt and decode the key so that it may be used. block is the block cipher generated from the smokering master key.
func (*Key) Disable ¶
func (k *Key) Disable()
Disable sets the status on a key to disabled, the keyring will not return it again after this.
func (*Key) GobDecode ¶
GobDecode implements the GobDecoder interface to allow restoring a key state.
type Smokering ¶
Smokering stores encryption keys protected by a master key.
func NewFromGob ¶
NewFromGob restores a Smokering from a Gob []byte.
func NewFromJSON ¶
NewFromJSON restores a Smokering from a JSON []byte.
func (*Smokering) AsJSON ¶
AsJSON returns a Smokering's data serialized as JSON to allow saving a Smokering.
func (*Smokering) GobEncode ¶
GobEncode implements the GobEncoder interface to allow saving a Smokering.
func (*Smokering) Key ¶
func (sr *Smokering) Key(id, note string, block cipher.Block, blocksize int, f func() ([]byte, error)) (*Key, error)
Key adds a new key to the Smokering and returns it. block is the block cipher used to encrypt the keys (generally an AES cipher encrypted with a master key). blocksize is the size of the block used to encrypt the keys (e.g. aes.BlockSize) f is provided to generate the key.
func (*Smokering) KeyFromGob ¶
KeyFromGob adds a key to the Smokering from Gob encoded key data, returning the key.