1package vault
2
3import "context"
4
5// BarrierEncryptorAccess is a wrapper around BarrierEncryptor that allows Core
6// to expose its barrier encrypt/decrypt operations through BarrierEncryptorAccess()
7// while restricting the ability to modify Core.barrier itself.
8type BarrierEncryptorAccess struct {
9	barrierEncryptor BarrierEncryptor
10}
11
12var _ BarrierEncryptor = (*BarrierEncryptorAccess)(nil)
13
14func NewBarrierEncryptorAccess(barrierEncryptor BarrierEncryptor) *BarrierEncryptorAccess {
15	return &BarrierEncryptorAccess{barrierEncryptor: barrierEncryptor}
16}
17
18func (b *BarrierEncryptorAccess) Encrypt(ctx context.Context, key string, plaintext []byte) ([]byte, error) {
19	return b.barrierEncryptor.Encrypt(ctx, key, plaintext)
20}
21
22func (b *BarrierEncryptorAccess) Decrypt(ctx context.Context, key string, ciphertext []byte) ([]byte, error) {
23	return b.barrierEncryptor.Decrypt(ctx, key, ciphertext)
24}
25