Documentation ¶
Index ¶
- func TestPooledWrapper(t *testing.T) wrapping.Wrapper
- func TestWrapper(t *testing.T) wrapping.Wrapper
- func WithAeadType(aeadType wrapping.AeadType) wrapping.Option
- func WithHashType(hash wrapping.HashType) wrapping.Option
- func WithInfo(info []byte) wrapping.Option
- func WithKey(key []byte) wrapping.Option
- func WithRandomReader(reader io.Reader) wrapping.Option
- func WithSalt(salt []byte) wrapping.Option
- type OptionFunc
- type ShamirWrapper
- func NewShamirWrapper() *ShamirWrapperdeprecated
- type Wrapper
- func (s *Wrapper) Decrypt(_ context.Context, in *wrapping.BlobInfo, opt ...wrapping.Option) ([]byte, error)
- func (s *Wrapper) Encrypt(_ context.Context, plaintext []byte, opt ...wrapping.Option) (*wrapping.BlobInfo, error)
- func (s *Wrapper) KeyBytes(context.Context) ([]byte, error)
- func (s *Wrapper) KeyId(_ context.Context) (string, error)
- func (s *Wrapper) NewDerivedWrapper(opt ...wrapping.Option) (*Wrapper, error)
- func (s *Wrapper) SetAead(aead cipher.AEAD)
- func (s *Wrapper) SetAesGcmKeyBytes(key []byte) error
- func (s *Wrapper) SetConfig(_ context.Context, opt ...wrapping.Option) (*wrapping.WrapperConfig, error)
- func (s *Wrapper) Type(_ context.Context) (wrapping.WrapperType, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestPooledWrapper ¶ added in v2.0.2
TestPooledWrapper returns a pooled aead wrapper for testing
func TestWrapper ¶ added in v2.0.2
TestWrapper returns a test aead wrapper for testing
func WithAeadType ¶
WithAeadType provides a way to chose the type of AEAD to use
func WithHashType ¶
WithHashType provides a wat to choose the type of hash to use for derivation
func WithRandomReader ¶ added in v2.0.5
WithRandomReader provides an optional random reader
Types ¶
type OptionFunc ¶
type OptionFunc func(*options) error
OptionFunc holds a function with local options
type ShamirWrapper ¶
type ShamirWrapper struct {
*Wrapper
}
ShamirWrapper is here for backwards compatibility for Vault; it reports a type of "shamir" instead of "aead"
func NewShamirWrapper
deprecated
func NewShamirWrapper() *ShamirWrapper
Deprecated: NewShamirWrapper returns a type of "shamir" instead of "aead" and is for backwards compatibility with old versions of Vault. Do not use in new code.
func (*ShamirWrapper) Type ¶
func (s *ShamirWrapper) Type(_ context.Context) (wrapping.WrapperType, error)
type Wrapper ¶
type Wrapper struct {
// contains filtered or unexported fields
}
Wrapper implements the wrapping.Wrapper interface for AEAD
func NewWrapper ¶
func NewWrapper() *Wrapper
NewWrapper creates a new Wrapper. No options are supported.
func (*Wrapper) Decrypt ¶
func (s *Wrapper) Decrypt(_ context.Context, in *wrapping.BlobInfo, opt ...wrapping.Option) ([]byte, error)
Decrypt is used to decrypt the ciphertext using the AEAD held by the wrapper
Supported options:
* wrapping.WithAad: Additional authenticated data that should be sourced from a separate location, and must match what was provided during encryption
func (*Wrapper) Encrypt ¶
func (s *Wrapper) Encrypt(_ context.Context, plaintext []byte, opt ...wrapping.Option) (*wrapping.BlobInfo, error)
Encrypt is used to encrypt the plaintext using the AEAD held by the wrapper
Supported options:
* wrapping.WithAad: Additional authenticated data that should be sourced from a separate location, and must also be provided during decryption
func (*Wrapper) NewDerivedWrapper ¶
NewDerivedWrapper returns an aead.Wrapper whose key is set to an hkdf-based derivation from the original wrapper
Supported options:
* wrapping.WithKeyId: The key ID, if any, to set on the derived wrapper
* wrapping.WithConfigMap: A struct containing the following:
** "aead_type": The type of AEAD to use as a string, defaults to wrapping.AeadTypeAesGcm.String()
** "hash": The type of hash function to use for derivation as a string, defaults to wrapping.HashTypeSha256.String()
** "info": The info value, if any, to use in the derivation, as a base64-encoded byte slice
** "salt": The salt value, if any, to use in the derivation, as a base64-encoded byte slice
The values in WithConfigMap can also be set via the package's native With* functions.
func (*Wrapper) SetAesGcmKeyBytes ¶
SetAesGcmKeyBytes takes in a byte slice and constucts an AES-GCM AEAD from it
func (*Wrapper) SetConfig ¶
func (s *Wrapper) SetConfig(_ context.Context, opt ...wrapping.Option) (*wrapping.WrapperConfig, error)
SetConfig sets the fields on the Wrapper object
Supported options:
* wrapping.WithKeyId: The key ID, if any, to set on the wrapper
* wrapping.WithConfigMap: A struct containing the following:
** "aead_type": The type of AEAD to use, defaults to wrapping.AeadTypeAesGcm
** "key": A base-64 encoded string value containing the key to use
The values in WithConfigMap can also be set via the package's native With* functions.