buildr/internal/vault/api.go

35 lines
806 B
Go
Raw Permalink Normal View History

2023-03-22 19:41:10 +00:00
package vault
type InitOption interface {
applyToVault(v *Vault) error
}
type initOptionFunc func(*Vault) error
func (f initOptionFunc) applyToVault(v *Vault) error {
return f(v)
}
2023-03-22 19:41:10 +00:00
type Encryption interface {
Encrypter
Decrypter
}
type Encrypter interface {
2023-06-22 16:06:56 +00:00
Encrypt(plainText []byte, passphrase string) (cipherText, salt, nonce []byte, err error)
2023-03-22 19:41:10 +00:00
}
type Decrypter interface {
Decrypt(cipherText []byte, passphrase string, salt, nonce []byte) (plainText []byte, err error)
}
type KeyDeriver interface {
2023-06-22 16:06:56 +00:00
DeriveKey(passphrase string, existingSalt []byte) (key, salt []byte)
2023-03-22 19:41:10 +00:00
}
2023-06-22 16:06:56 +00:00
type KeyDeriverFunc func(passphrase string, existingSalt []byte) (key, salt []byte)
2023-03-22 19:41:10 +00:00
2023-06-22 16:06:56 +00:00
func (f KeyDeriverFunc) DeriveKey(passphrase string, existingSalt []byte) (key, salt []byte) {
2023-03-22 19:41:10 +00:00
return f(passphrase, existingSalt)
}