algorithms

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package algorithms contains implementations of various crypto algorithms for the crypto engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownAlgorithm is returned when an incorrect algorithm name is used.
	ErrUnknownAlgorithm = errors.New("unexpected encryption algorithm")
	// ErrExceedsMaxSize is returned when the plaintext is too large.
	ErrExceedsMaxSize = errors.New("plaintext is too large, limited to 32MiB")
)

Functions

This section is empty.

Types

type AES256CFBAlgorithm

type AES256CFBAlgorithm struct{}

AES256CFBAlgorithm implements the AES-256-CFB algorithm

func (*AES256CFBAlgorithm) Decrypt

func (a *AES256CFBAlgorithm) Decrypt(ciphertext []byte, key []byte) ([]byte, error)

Decrypt decrypts a row of data.

func (*AES256CFBAlgorithm) Encrypt

func (a *AES256CFBAlgorithm) Encrypt(plaintext []byte, key []byte) ([]byte, error)

Encrypt encrypts a row of data.

type AES256GCMAlgorithm

type AES256GCMAlgorithm struct{}

AES256GCMAlgorithm provides symmetric authenticated encryption using 256-bit AES-GCM with a random nonce.

func (*AES256GCMAlgorithm) Decrypt

func (_ *AES256GCMAlgorithm) Decrypt(ciphertext []byte, key []byte) ([]byte, error)

Decrypt decrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.

func (*AES256GCMAlgorithm) Encrypt

func (_ *AES256GCMAlgorithm) Encrypt(plaintext []byte, key []byte) ([]byte, error)

Encrypt encrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.

type EncryptionAlgorithm

type EncryptionAlgorithm interface {
	Encrypt(plaintext []byte, key []byte) ([]byte, error)
	Decrypt(ciphertext []byte, key []byte) ([]byte, error)
}

EncryptionAlgorithm represents a crypto algorithm used by the Engine

func NewFromType

func NewFromType(algoType Type) (EncryptionAlgorithm, error)

NewFromType instantiates an encryption algorithm by name

type Type

type Type string

Type is an enum of supported encryption algorithms

const (
	// Aes256Cfb is the AES-256-CFB algorithm
	Aes256Cfb Type = "aes-256-cfb"
	// Aes256Gcm is the AES-256-GCM algorithm
	Aes256Gcm Type = "aes-256-gcm"
)

func TypeFromString

func TypeFromString(name string) (Type, error)

TypeFromString attempts to map a string to a `Type` value.

Jump to

Keyboard shortcuts

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