pasta

package
v0.0.73 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_pasta_proto protoreflect.FileDescriptor

Functions

func GenerateSecret

func GenerateSecret(length int) []byte

GenerateSecret generates random bytes with CharsetAlphaNum

func HashByteSecret

func HashByteSecret(secret []byte) []byte

HashByteSecret hashes the secret for consumption by the AEAD encryption algorithm which expects exactly 32 bytes.

The system secret is being hashed to always match exactly the 32 bytes required by AEAD, even if the secret is long or shorter.

func HashStringSecret

func HashStringSecret(secret string) []byte

HashStringSecret hashes the secret for consumption by the AEAD encryption algorithm which expects exactly 32 bytes.

The system secret is being hashed to always match exactly the 32 bytes required by AEAD, even if the secret is long or shorter.

Types

type CompletedConfig

type CompletedConfig struct {
	// contains filtered or unexported fields
}

func (CompletedConfig) New

func (c CompletedConfig) New() *Pasta

New creates a new server which logically combines the handling chain with the passed server. name is used to differentiate for logging. The handler chain in particular can be difficult as it starts delgating. New usually called after Complete

func (CompletedConfig) Validate added in v0.0.44

func (c CompletedConfig) Validate() error

Validate checks Config.

type Config

type Config struct {
	Proto     Secret
	Validator *validator.Validate
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Config

NewConfig returns a Config struct with the default values

func NewViperConfig added in v0.0.17

func NewViperConfig(v *viper.Viper, keys ...string) *Config

NewViperConfig returns a Config struct with the global viper instance key representing a sub tree of this instance. NewViperConfig is case-insensitive for a key.

func (*Config) Complete

func (c *Config) Complete() CompletedConfig

Complete fills in any fields not set that are required to have valid data and can be derived from other fields. If you're going to ApplyOptions, do that first. It's mutating the receiver. ApplyOptions is called inside.

type KeyProvider

type KeyProvider interface {
	GetSystemSecret() []byte           // primary key
	GetRotatedSystemSecrets() [][]byte // multi keys for multi encrypt|decrypt
}

type Pasta

type Pasta struct {
	// contains filtered or unexported fields
}

Pasta copy & paste-friendly golang crypto

func New

func New(c KeyProvider) *Pasta

func NewFromKey

func NewFromKey(systemSecret []byte, rotatedSystemSecrets [][]byte) *Pasta

func (*Pasta) Decrypt

func (c *Pasta) Decrypt(ciphertext string) (p []byte, err error)

func (*Pasta) Encrypt

func (c *Pasta) Encrypt(plaintext []byte) (string, error)

type Secret added in v0.0.17

type Secret struct {
	SystemSecret         string   `protobuf:"bytes,1,opt,name=system_secret,json=systemSecret,proto3" json:"system_secret,omitempty"`                           // new
	RotatedSystemSecrets []string `protobuf:"bytes,2,rep,name=rotated_system_secrets,json=rotatedSystemSecrets,proto3" json:"rotated_system_secrets,omitempty"` // old, older,..., oldest
	// contains filtered or unexported fields
}

func (*Secret) Descriptor deprecated added in v0.0.17

func (*Secret) Descriptor() ([]byte, []int)

Deprecated: Use Secret.ProtoReflect.Descriptor instead.

func (*Secret) GetRotatedSystemSecrets added in v0.0.17

func (x *Secret) GetRotatedSystemSecrets() []string

func (*Secret) GetSystemSecret added in v0.0.23

func (x *Secret) GetSystemSecret() string

func (*Secret) ProtoMessage added in v0.0.17

func (*Secret) ProtoMessage()

func (*Secret) ProtoReflect added in v0.0.17

func (x *Secret) ProtoReflect() protoreflect.Message

func (*Secret) Reset added in v0.0.17

func (x *Secret) Reset()

func (*Secret) String added in v0.0.17

func (x *Secret) String() string

Jump to

Keyboard shortcuts

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