Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCryptorVersion = fmt.Errorf("Cryptor version does not match")
var ErrDBVersion = fmt.Errorf("DB version does not match")
Functions ¶
This section is empty.
Types ¶
type Cryptor ¶
type Cryptor interface { Decrypt(*DBKey) (*knox.Key, error) Encrypt(*knox.Key) (*DBKey, error) EncryptVersion(*knox.Key, *knox.KeyVersion) (*EncKeyVersion, error) }
Cryptor is an interface for converting a knox Key to a DB Key
func NewAESGCMCryptor ¶
NewAESGCMCryptor creates a Cryptor that performs AES GCM AEAD encryption on key data.
type DB ¶
type DB interface { // Get returns the key specified by the ID. Get(id string) (*DBKey, error) // GetAll returns all of the keys in the database. GetAll() ([]DBKey, error) // Update makes an update to DBKey indexed by its ID. // It will fail if the key has been changed since the specified version. Update(key *DBKey) error // Add adds the key(s) to the DB (it will fail if the key id exists). Add(keys ...*DBKey) error // Remove permanently removes the key specified by the ID. Remove(id string) error }
DB is the underlying database connection that KeyDB uses for all of its operations.
This interface should not contain any business logic and should only deal with formatting and database specific logic.
func NewPostgreSQLDB ¶
NewPostgreSQLDB will create a SQLDB with the necessary statements for using postgres.
type DBKey ¶
type DBKey struct { ID string `json:"id"` ACL knox.ACL `json:"acl"` VersionList []EncKeyVersion `json:"versions"` VersionHash string `json:"hash"` // The version should be set by the db provider and is not part of the data. DBVersion int64 `json:"-"` }
DBKey is a struct for the json serialization of keys in the database.
type EncKeyVersion ¶
type EncKeyVersion struct { ID uint64 `json:"id"` EncData []byte `json:"data"` Status knox.VersionStatus `json:"status"` CreationTime int64 `json:"ts"` CryptoMetadata []byte `json:"crypt"` }
EncKeyVersion is a struct for encrypting key data
type SQLDB ¶
type SQLDB struct { UpdateStmt *sql.Stmt AddStmt *sql.Stmt RemoveStmt *sql.Stmt // contains filtered or unexported fields }
SQLDB provides a generic way to use SQL providers as Knox DBs.
type TempDB ¶
TempDB is an in memory DB that does no replication across servers and starts out fresh everytime. It is written for testing and simple dev work.