ece

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySize = aes.BlockSize
	// NonceSize is standard nonce size for GCM (unexported in cipher package)
	NonceSize = 12
	// TagSize is standard auth tag size for GCM (unexported in cipher package)
	TagSize = 16
)
View Source
const (
	DefaultRecordSize uint32 = 4096
	DefaultKeyLabel   string = "P-256"
)

Variables

View Source
var (
	ErrInvalidDH      = fmt.Errorf("dh sequence is invalid")
	ErrTruncated      = fmt.Errorf("content truncated")
	ErrInvalidPadding = fmt.Errorf("invalid padding")
)
View Source
var (
	ErrInvalidKeySize  = fmt.Errorf("invalid static key length")
	ErrInvalidSaltSize = fmt.Errorf("invaild salt size")
)

Functions

func WithAuthSecret

func WithAuthSecret(authSecret []byte) engineOption

WithAuthSecret specifies auth secret for shared key derivation

func WithKeyLabel

func WithKeyLabel(keyLabel string) engineOption

WithKeyLabel sets a key label to use

Types

type Engine

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

Engine represents encryption and decryption engine

func (*Engine) Decrypt

func (e *Engine) Decrypt(content, target []byte, params operationalParams) ([]byte, error)

Decrypt takes input cipher text, decrypts it using provided parameters and appends result to target

func (*Engine) Encrypt

func (e *Engine) Encrypt(content, target []byte, params operationalParams) ([]byte, error)

Encrypt takes input plain text, encrypts it using provided parameters and appends result to target

type KeyLookupFunc

type KeyLookupFunc func(keyID []byte) *ecdsa.PrivateKey

KeyLookupFunc is a function that fetches a private key by provided keyID It must always return non-nil value even if input is nil

func SingleKey

func SingleKey(key *ecdsa.PrivateKey) KeyLookupFunc

type Version

type Version string

Version determines encoding mode

const (
	// AES128GCM is a newest and recommended for usage, also used as default if not specified explicitly
	AES128GCM Version = "aes128gcm"

	// AESGCM is a widely used version (i.e. in Firebase Cloud Messaging)
	AESGCM Version = "aesgcm"

	// AESGCM128 is a legacy version but sometimes used
	AESGCM128 Version = "aesgcm128"
)

Available content-encoding versions

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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