Documentation ¶
Index ¶
- Variables
- func CheckSymKey(key []byte) error
- func DeriveSymKey(password, salt []byte) ([]byte, error)
- func Magic(raw DB) error
- func PutMagic(raw DB) error
- func SymDecrypt(ciphertext []byte, key []byte) ([]byte, error)
- func SymEncrypt(plaintext []byte, key []byte) ([]byte, error)
- type BoltDB
- func (b *BoltDB) Close() error
- func (b *BoltDB) Delete(bucket []byte, key []byte) error
- func (b *BoltDB) DeleteBucket(bucket []byte) error
- func (b *BoltDB) ForEachBucket(fn func(*Bucket) error) error
- func (b *BoltDB) Get(bucket []byte, key []byte) (value []byte, err error)
- func (b *BoltDB) GetBucket(bucket []byte) (buck *Bucket, err error)
- func (b *BoltDB) Name() string
- func (b *BoltDB) Put(bucket []byte, key []byte, value []byte) error
- type Bucket
- type DB
- type Encrypted
- type FakeEncrypted
- type KeyValue
- type MemoryDB
- func (b *MemoryDB) Close() error
- func (b *MemoryDB) Delete(bucket []byte, key []byte) (err error)
- func (b *MemoryDB) DeleteBucket(bucket []byte) error
- func (b *MemoryDB) Get(bucket []byte, key []byte) (value []byte, err error)
- func (b *MemoryDB) GetBucket(bucket []byte) (buck *Bucket, err error)
- func (b *MemoryDB) GetRaw(bucket []byte, key []byte) (value []byte, err error)
- func (b *MemoryDB) IsLocked() bool
- func (b *MemoryDB) Lock()
- func (b *MemoryDB) Name() string
- func (b *MemoryDB) Put(bucket []byte, key []byte, value []byte) error
- func (b *MemoryDB) PutRaw(bucket []byte, key []byte, value []byte) error
- func (b *MemoryDB) UnlockFor(time.Duration) (time.Time, error)
- type Symmetric
- func (e *Symmetric) Get(bucket []byte, key []byte) (value []byte, err error)
- func (e *Symmetric) GetBucket(bucket []byte) (*Bucket, error)
- func (s *Symmetric) IsLocked() bool
- func (s *Symmetric) Lock()
- func (e *Symmetric) Put(bucket []byte, key []byte, value []byte) error
- func (s *Symmetric) Raw() DB
- func (s *Symmetric) UnlockFor(passphrase []byte, duration time.Duration) (dl time.Time, err error)
- type Version
Constants ¶
This section is empty.
Variables ¶
View Source
var BucketConfig = []byte("Config")
View Source
var ErrAlreadyOpen = errors.Conflict.With("database is already open")
View Source
var ErrDatabaseAlreadyEncrypted = errors.BadRequest.With("database already encrypted")
View Source
var ErrInvalidPassword = errors.BadPassword.With("invalid password")
View Source
var ErrMalformedEncryptedDatabase = errors.InternalError.With("malformed encrypted database")
View Source
var ErrNoBucket = errors.NotFound.With("bucket not defined")
View Source
var ErrNotFound = errors.NotFound.With("key not found")
View Source
var ErrNotOpen = errors.BadRequest.With("database is not open")
Functions ¶
func CheckSymKey ¶ added in v0.6.0
func DeriveSymKey ¶ added in v0.6.0
Types ¶
type BoltDB ¶
type BoltDB struct {
// contains filtered or unexported fields
}
func (*BoltDB) DeleteBucket ¶
DeleteBucket will delete all key/value pairs from a bucket
type Bucket ¶
type Bucket struct { Name string KeyValueList []KeyValue //KeyValueList contains the key/value data for the entry // contains filtered or unexported fields }
Bucket is the structure to store the key/value data and a reference map to pull it.
func NewBucket ¶
func NewBucket() *Bucket
NewBucket creates a new instance of the bucket and initializes the map
type DB ¶
type DB interface { Close() error // Returns an error if the close fails Name() string // returns the database filename if applicable Get(bucket []byte, key []byte) (value []byte, err error) // Get key from database (may further decrypt data if applicable), returns ErrNotFound if the key is not found Put(bucket []byte, key []byte, value []byte) error // Put the value in the database (may further encrypt data if applicable), throws an error if fails GetBucket(bucket []byte) (*Bucket, error) // GetBucket retrieves all the data contained within a bucket Delete(bucket []byte, key []byte) error // Delete will remove a key/value pair from the bucket DeleteBucket(bucket []byte) error // DeleteBucket will delete all key/value pairs from a bucket }
DB defines the interface functions to access the database
type Encrypted ¶
type Encrypted interface { DB Raw() DB // Raw returns the underlying database IsLocked() bool // Lock() // Lock the database // UnlockFor unlocks the encrypter and returns the time at which it will be // locked again. If the caller specifies a non-zero deadline, the encrypter // must set a deadline no later than that, though the encrypter may choose // to use an earlier deadline than the one requested. If the caller does not // specify a deadline (passes the zero value), the encrypter may still set a // deadline. The encrypter must return the deadline if one is set, or the // zero value otherwise. UnlockFor([]byte, time.Duration) (time.Time, error) }
type FakeEncrypted ¶
type FakeEncrypted struct {
DB
}
FakeEncrypted implements Encrypted without actually encrypting anything.
func (*FakeEncrypted) IsLocked ¶
func (e *FakeEncrypted) IsLocked() bool
func (*FakeEncrypted) Lock ¶
func (e *FakeEncrypted) Lock()
func (*FakeEncrypted) Raw ¶
func (e *FakeEncrypted) Raw() DB
type MemoryDB ¶
type MemoryDB struct {
// contains filtered or unexported fields
}
MemoryDB holds the main map of buckets for the in-memory database
func (*MemoryDB) DeleteBucket ¶
DeleteBucket will delete all key/value pairs from a bucket
type Symmetric ¶
type Symmetric struct { DB // Retention sets the default key retention policy. A value of zero // indicates indefinite key retention. Retention time.Duration // New indicates that the database is new and the passphrase should be // confirmed the first time. New bool // contains filtered or unexported fields }
Symmetric implements Encrypted via symmetric encryption using a key derived from a passphrase and a salt.
func NewSymmetric ¶
func OpenSymmetric ¶
OpenSymmetric creates or opens a symmetrically encrypted database.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.