encryption

package
v0.0.0-...-7579eda Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: MIT Imports: 20 Imported by: 1

Documentation

Overview

Package encryption bundles various symmetric and asymmetric encryption schemes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AES

type AES struct{}

AES is the AES-CBC object handler.

func NewAES

func NewAES() *AES

NewAES returns a fresh AES-CBC instance.

func (AES) Decrypt

func (a AES) Decrypt(key, ct []byte) ([]byte, error)

Decrypt invokes the AES-CBC decryption routine.

func (AES) Encrypt

func (a AES) Encrypt(key, msg []byte) ([]byte, error)

Encrypt invokes the AES-CBC encryption routine.

func (AES) Generate

func (a AES) Generate(seed []byte) ([]byte, error)

Generate creates a fresh 16-byte AES-CBC symmetric key. If seed is nil crypto.rand is used as the random stream.

type Asymmetric

type Asymmetric interface {
	// Generate creates a public/private key pair.
	Generate(seed []byte) (pk, sk []byte, err error)
	// Encrypt enciphers a message with a given public key.
	Encrypt(pk, msg, ad []byte) ([]byte, error)
	// Decrypt deciphers a message with a given private key.
	Decrypt(sk, ct, ad []byte) ([]byte, error)
}

Asymmetric defines a common interface for asymmetric encryption schemes.

type Authenticated

type Authenticated interface {
	// Encrypt enciphers and authenticates a message and authenticates the associated data.
	Encrypt(key, msg, ad []byte) ([]byte, error)
	// Decrypt deciphers and authenticates a ciphertext with associated data.
	Decrypt(key, ct, ad []byte) ([]byte, error)
}

Authenticated defines a common interface for authenticated encryption schemes.

type ECIES

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

ECIES implements the Elliptic Curve Integrated Encryption Scheme on a given curve using HS256 and AES-GCM as the authentication and encryption primitives and HDKF for key derivation.

func NewECIES

func NewECIES(curve elliptic.Curve) *ECIES

NewECIES creates a fresh ECIES object instance.

func (ECIES) Decrypt

func (e ECIES) Decrypt(sk, ct, ad []byte) ([]byte, error)

Decrypt deciphers a ciphertex with a given private key.

func (ECIES) Encrypt

func (e ECIES) Encrypt(pk, msg, ad []byte) ([]byte, error)

Encrypt enciphers a message with a given public key.

func (ECIES) Generate

func (e ECIES) Generate(seed []byte) (pk, sk []byte, err error)

Generate creates a ECIES public/private key pair.

type Encapsulation

type Encapsulation interface {
	// Generate creates a public/private key pair.
	Generate(seed []byte) (pk, sk []byte, err error)
	// Encapsulate generates and encapsulates a fresh symmetric key.
	Encapsulate(pk []byte) (k, c []byte, err error)
	// Decapsulate decapsulates a symmetric key from a ciphertext.
	Decapsulate(sk, ct []byte) ([]byte, error)
}

Encapsulation defines a common interface for key-encapsulation mechanisms.

type GCM

type GCM struct{}

GCM implements the AES-GCM AEAD scheme.

func NewGCM

func NewGCM() *GCM

NewGCM returns a fresh AES-GCM instance.

func (GCM) Decrypt

func (g GCM) Decrypt(key, ct, ad []byte) ([]byte, error)

Decrypt applies the AES-GCM decryption routine to a given message and associated data.

func (GCM) Encrypt

func (g GCM) Encrypt(key, msg, ad []byte) ([]byte, error)

Encrypt applies the AES-GCM encryption/authentication routine to a given message and associated data.

type OAEP

type OAEP struct{}

OAEP implements to RSA-OAEP encryption scheme based on SHA256.

func NewOAEP

func NewOAEP() *OAEP

NewOAEP creates a fresh RSA-OAEP instance.

func (OAEP) Decrypt

func (o OAEP) Decrypt(sk, ct, ad []byte) ([]byte, error)

Decrypt deciphers a ciphertext and associated data with the given private key.

func (OAEP) Encrypt

func (o OAEP) Encrypt(pk, msg, ad []byte) ([]byte, error)

Encrypt enciphers a message and associated data with the given public key.

func (OAEP) Generate

func (o OAEP) Generate(seed []byte) (pk, sk []byte, err error)

Generate creates a fresh RSA-OAEP public/private key pair.

type Symmetric

type Symmetric interface {
	// Generate returns a fresh symmetric key.
	Generate(seed []byte) ([]byte, error)
	// Encrypt enciphers a message with a given symmetric key.
	Encrypt(key, msg []byte) ([]byte, error)
	// Decrypt deciphers a ciphertext with a given symmetric key.
	Decrypt(key, ct []byte) ([]byte, error)
}

Symmetric defines a common interface for symmetric encryption schemes.

Jump to

Keyboard shortcuts

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