Skip to content

Commit

Permalink
Key id needs to be more specific than just the version in order to us…
Browse files Browse the repository at this point in the history
…e Seal HA with multiple transit seals
  • Loading branch information
sgmiller committed Sep 14, 2023
1 parent 1c42881 commit 94a95cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wrappers/transit/transit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import (
type Wrapper struct {
logger hclog.Logger
client transitClientEncryptor
keyName string
currentKeyId *atomic.Value
keyIdPrefix string
}

var _ wrapping.Wrapper = (*Wrapper)(nil)
Expand Down Expand Up @@ -47,6 +49,8 @@ func (s *Wrapper) SetConfig(_ context.Context, opt ...wrapping.Option) (*wrappin
}
s.client = client

s.keyIdPrefix = client.mountPath + "/" + client.keyName + "/"

// Send a value to test the wrapper and to set the current key id
if _, err := s.Encrypt(context.Background(), []byte("a")); err != nil {
client.Close()
Expand Down Expand Up @@ -88,7 +92,7 @@ func (s *Wrapper) Encrypt(_ context.Context, plaintext []byte, _ ...wrapping.Opt
if len(splitKey) != 3 {
return nil, errors.New("invalid ciphertext returned")
}
keyId := splitKey[1]
keyId := s.keyIdPrefix + splitKey[1]
s.currentKeyId.Store(keyId)

ret := &wrapping.BlobInfo{
Expand Down

0 comments on commit 94a95cc

Please sign in to comment.