aeadcrypter

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package aeadcrypter provides the interface for AEAD cipher implementations used by S2A's record protocol.

Index

Constants

View Source
const (
	AES128GCMKeySize = 16
	AES256GCMKeySize = 32
)

Supported key sizes in bytes.

View Source
const (
	// TagSize is the tag size in bytes for AES-128-GCM-SHA256,
	// AES-256-GCM-SHA384, and CHACHA20-POLY1305-SHA256.
	TagSize = 16
	// NonceSize is the size of the nonce in number of bytes for
	// AES-128-GCM-SHA256, AES-256-GCM-SHA384, and CHACHA20-POLY1305-SHA256.
	NonceSize = 12
	// SHA256DigestSize is the digest size of sha256 in bytes.
	SHA256DigestSize = 32
	// SHA384DigestSize is the digest size of sha384 in bytes.
	SHA384DigestSize = 48
)
View Source
const (
	Chacha20Poly1305KeySize = 32
)

Supported key size in bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type S2AAEADCrypter

type S2AAEADCrypter interface {
	// Encrypt encrypts the plaintext and computes the tag of dst and plaintext.
	// dst and plaintext may fully overlap or not at all.
	Encrypt(dst, plaintext, nonce, aad []byte) ([]byte, error)
	// Decrypt decrypts ciphertext and verifies the tag. dst and ciphertext may
	// fully overlap or not at all.
	Decrypt(dst, ciphertext, nonce, aad []byte) ([]byte, error)
	// TagSize returns the tag size in bytes.
	TagSize() int
}

S2AAEADCrypter is the interface for an AEAD cipher used by the S2A record protocol.

func NewAESGCM

func NewAESGCM(key []byte) (S2AAEADCrypter, error)

NewAESGCM creates an AES-GCM crypter instance. Note that the key must be either 128 bits or 256 bits.

func NewChachaPoly

func NewChachaPoly(key []byte) (S2AAEADCrypter, error)

NewChachaPoly creates a Chacha-Poly crypter instance. Note that the key must be Chacha20Poly1305KeySize bytes in length.

Directories

Path Synopsis
Package testutil is a collection of test utilities for the AEAD crypter.
Package testutil is a collection of test utilities for the AEAD crypter.

Jump to

Keyboard shortcuts

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