aead

package
v2.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2023 License: MPL-2.0 Imports: 15 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestPooledWrapper added in v2.0.2

func TestPooledWrapper(t *testing.T) wrapping.Wrapper

TestPooledWrapper returns a pooled aead wrapper for testing

func TestWrapper added in v2.0.2

func TestWrapper(t *testing.T) wrapping.Wrapper

TestWrapper returns a test aead wrapper for testing

func WithAeadType

func WithAeadType(aeadType wrapping.AeadType) wrapping.Option

WithAeadType provides a way to chose the type of AEAD to use

func WithHashType

func WithHashType(hash wrapping.HashType) wrapping.Option

WithHashType provides a wat to choose the type of hash to use for derivation

func WithInfo

func WithInfo(info []byte) wrapping.Option

WithInfo provides optional info for deriving wrappers

func WithKey

func WithKey(key []byte) wrapping.Option

WithKey provides a common way to pass in a key.

func WithRandomReader added in v2.0.5

func WithRandomReader(reader io.Reader) wrapping.Option

WithRandomReader provides an optional random reader

func WithSalt

func WithSalt(salt []byte) wrapping.Option

WithSalt provides optional salt for deriving wrappers

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

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) KeyBytes added in v2.0.4

func (s *Wrapper) KeyBytes(context.Context) ([]byte, error)

KeyBytes returns the current key bytes

func (*Wrapper) KeyId

func (s *Wrapper) KeyId(_ context.Context) (string, error)

KeyId returns the last known key id

func (*Wrapper) NewDerivedWrapper

func (s *Wrapper) NewDerivedWrapper(opt ...wrapping.Option) (*Wrapper, error)

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) SetAead

func (s *Wrapper) SetAead(aead cipher.AEAD)

SetAead allows directly setting an AEAD to use

func (*Wrapper) SetAesGcmKeyBytes

func (s *Wrapper) SetAesGcmKeyBytes(key []byte) error

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.

func (*Wrapper) Type

Type returns the seal type for this particular Wrapper implementation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL