encryption

package
v0.0.0-...-93fbde9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package encryption defines the various encryption Algorithms supported by the gormcrypto package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAlgo

func RegisterAlgo(name string, creator func(map[string]interface{}) Algorithm)

RegisterAlgo adds an Algorithm to the internal algos map so it can be used in YAML configs

func SupportedAlgos

func SupportedAlgos() []string

SupportedAlgos returns a list of registered Algorithms that can be used in YAML configs

Types

type AES256CBC

type AES256CBC struct {
	Algorithm
	// contains filtered or unexported fields
}

AES256CBC supports AES256CBC encryption of arbitrary data

func NewAES256CBC

func NewAES256CBC(key string) (*AES256CBC, error)

NewAES256CBC creates a new AES256CBC value

func (AES256CBC) Config

func (e AES256CBC) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (*AES256CBC) Decrypt

func (e *AES256CBC) Decrypt(crypted []byte) ([]byte, error)

Decrypt decrypts data with key

func (*AES256CBC) Encrypt

func (e *AES256CBC) Encrypt(plain []byte) ([]byte, error)

Encrypt encrypts data with key

func (AES256CBC) Name

func (AES256CBC) Name() string

Name identifies the Algorithm as a string for exporting configurations

type AES256GCM

type AES256GCM struct {
	Algorithm
	// contains filtered or unexported fields
}

AES256GCM supports AES256GCM encryption of arbitrary data

func NewAES

func NewAES(key string) (*AES256GCM, error)

NewAES creates a new AES value

func NewAES256

func NewAES256(key string) (*AES256GCM, error)

NewAES256 creates a new AES256 value

func NewAES256GCM

func NewAES256GCM(key string) (*AES256GCM, error)

NewAES256GCM creates instance of AES256GCM with passed key

func (AES256GCM) Config

func (e AES256GCM) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (*AES256GCM) Decrypt

func (e *AES256GCM) Decrypt(crypted []byte) ([]byte, error)

Decrypt decrypts data with key

func (*AES256GCM) Encrypt

func (e *AES256GCM) Encrypt(plain []byte) ([]byte, error)

Encrypt encrypts data with key

func (AES256GCM) Name

func (AES256GCM) Name() string

Name identifies the Algorithm as a string for exporting configurations

type Algorithm

type Algorithm interface {
	// Name identifies the Algorithm as a string for exporting configurations
	Name() string
	// Config converts an Algorthim's internal configuration into a map for export
	Config() map[string]interface{}
	// Encrypt transforms plaintext values into a securely encrypted binary representation.
	Encrypt([]byte) ([]byte, error)
	// Decrypt transforms a securely encrypted binary value into its plaintext version.
	Decrypt([]byte) ([]byte, error)
}

Algorithm defines an interface that encryption types must implement to be usable with gormcrypto. A type implementing encryption.Algorithm will convert a value to and from its serialized and encrypted representations. The types implemented here wrap the Go standard (and extended) library's various (non-deprecated) crypto packages.

func FromYaml

func FromYaml(name string, config map[string]interface{}) Algorithm

FromYaml configures an Algorithm automatically based on a name and a configuration map

type ChaCha20Poly1305

type ChaCha20Poly1305 struct {
	Algorithm
	// contains filtered or unexported fields
}

ChaCha20Poly1305 supports ChaCha20Poly1305 encryption of arbitrary data

func NewChaCha20Poly1305

func NewChaCha20Poly1305(key string) (*ChaCha20Poly1305, error)

NewChaCha20Poly1305 creates instance of ChaCha20Poly1305 with passed key

func (ChaCha20Poly1305) Config

func (e ChaCha20Poly1305) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (*ChaCha20Poly1305) Decrypt

func (e *ChaCha20Poly1305) Decrypt(crypted []byte) ([]byte, error)

Decrypt decrypts data with key

func (*ChaCha20Poly1305) Encrypt

func (e *ChaCha20Poly1305) Encrypt(plain []byte) ([]byte, error)

Encrypt encrypts data with key

func (ChaCha20Poly1305) Name

func (ChaCha20Poly1305) Name() string

Name identifies the Algorithm as a string for exporting configurations

type NaClBox

type NaClBox struct {
	Algorithm
	// contains filtered or unexported fields
}

NaClBox supports NaClBox enrcryption of arbitrary data

func NewNaClBox

func NewNaClBox(privateKey, publicKey *[32]byte) *NaClBox

NewNaClBox creates a new NaClBox value

func (NaClBox) Config

func (e NaClBox) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (*NaClBox) Decrypt

func (e *NaClBox) Decrypt(crypted []byte) ([]byte, error)

Decrypt ::: NaClBox

func (*NaClBox) Encrypt

func (e *NaClBox) Encrypt(plain []byte) ([]byte, error)

Encrypt ::: NaClBox

func (NaClBox) Name

func (NaClBox) Name() string

Name identifies the Algorithm as a string for exporting configurations

type RSA

type RSA struct {
	Algorithm
	// contains filtered or unexported fields
}

RSA supports RSA

func NewRSA

func NewRSA(privateKey *rsa.PrivateKey) *RSA

NewRSA creates a new RSA value

func (RSA) Config

func (e RSA) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (*RSA) Decrypt

func (e *RSA) Decrypt(crypted []byte) ([]byte, error)

Decrypt decrypts data with private key

func (*RSA) Encrypt

func (e *RSA) Encrypt(plain []byte) ([]byte, error)

Encrypt encrypts data with public key

func (RSA) Name

func (RSA) Name() string

Name identifies the Algorithm as a string for exporting configurations

type XChaCha20Poly1305

type XChaCha20Poly1305 struct {
	Algorithm
	// contains filtered or unexported fields
}

XChaCha20Poly1305 supports XChaCha20Poly1305

func NewXChaCha20Poly1305

func NewXChaCha20Poly1305(key string) (*XChaCha20Poly1305, error)

NewXChaCha20Poly1305 creates instance of XChaCha20Poly1305 with passed key

func (XChaCha20Poly1305) Config

func (e XChaCha20Poly1305) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (*XChaCha20Poly1305) Decrypt

func (e *XChaCha20Poly1305) Decrypt(crypted []byte) ([]byte, error)

Decrypt decrypts data with key

func (*XChaCha20Poly1305) Encrypt

func (e *XChaCha20Poly1305) Encrypt(plain []byte) ([]byte, error)

Encrypt encrypts data with key

func (XChaCha20Poly1305) Name

func (XChaCha20Poly1305) Name() string

Name identifies the Algorithm as a string for exporting configurations

Jump to

Keyboard shortcuts

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