aead

package
v1.17.27 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package aead provides authenticated encryption with associated data

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AEAD

type AEAD interface {
	// Seal encrypts and authenticates plaintext
	Seal(dst, nonce, plaintext, aad []byte) []byte

	// Open decrypts and authenticates ciphertext
	Open(dst, nonce, ciphertext, aad []byte) ([]byte, error)

	// NonceSize returns the nonce size in bytes
	NonceSize() int

	// Overhead returns the authentication tag size
	Overhead() int

	// KeySize returns the key size in bytes
	KeySize() int
}

AEAD interface for authenticated encryption

func GetAEAD

func GetAEAD(id AeadID, key []byte) (AEAD, error)

GetAEAD returns an AEAD implementation for the given ID

func NewAES256GCM

func NewAES256GCM(key []byte) (AEAD, error)

NewAES256GCM creates a new AES-256-GCM instance

func NewChaCha20Poly1305

func NewChaCha20Poly1305(key []byte) (AEAD, error)

NewChaCha20Poly1305 creates a new ChaCha20-Poly1305 instance

type AES256GCMImpl

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

AES256GCMImpl implements AES-256-GCM

func (*AES256GCMImpl) KeySize

func (a *AES256GCMImpl) KeySize() int

KeySize returns 256-bit key size

func (*AES256GCMImpl) NonceSize

func (a *AES256GCMImpl) NonceSize() int

NonceSize returns 96-bit nonce size for GCM

func (*AES256GCMImpl) Open

func (a *AES256GCMImpl) Open(dst, nonce, ciphertext, aad []byte) ([]byte, error)

Open decrypts and authenticates ciphertext

func (*AES256GCMImpl) Overhead

func (a *AES256GCMImpl) Overhead() int

Overhead returns 128-bit tag size

func (*AES256GCMImpl) Seal

func (a *AES256GCMImpl) Seal(dst, nonce, plaintext, aad []byte) []byte

Seal encrypts and authenticates plaintext

type AeadID

type AeadID string

AeadID identifies an AEAD algorithm

const (
	AES256GCM        AeadID = "aes256gcm"
	ChaCha20Poly1305 AeadID = "chacha20poly1305"
	AES256GCMSIV     AeadID = "aes256gcmsiv"
)

type ChaCha20Poly1305Impl

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

ChaCha20Poly1305Impl implements ChaCha20-Poly1305

func (*ChaCha20Poly1305Impl) KeySize

func (c *ChaCha20Poly1305Impl) KeySize() int

KeySize returns 256-bit key size

func (*ChaCha20Poly1305Impl) NonceSize

func (c *ChaCha20Poly1305Impl) NonceSize() int

NonceSize returns 96-bit nonce size

func (*ChaCha20Poly1305Impl) Open

func (c *ChaCha20Poly1305Impl) Open(dst, nonce, ciphertext, aad []byte) ([]byte, error)

Open decrypts and authenticates ciphertext

func (*ChaCha20Poly1305Impl) Overhead

func (c *ChaCha20Poly1305Impl) Overhead() int

Overhead returns 128-bit tag size

func (*ChaCha20Poly1305Impl) Seal

func (c *ChaCha20Poly1305Impl) Seal(dst, nonce, plaintext, aad []byte) []byte

Seal encrypts and authenticates plaintext

type NonceGenerator

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

NonceGenerator generates deterministic nonces for stream-based protocols

func NewNonceGenerator

func NewNonceGenerator(streamID uint32) *NonceGenerator

NewNonceGenerator creates a new nonce generator

func (*NonceGenerator) GetSeqNo

func (ng *NonceGenerator) GetSeqNo() uint64

GetSeqNo returns the current sequence number

func (*NonceGenerator) Next

func (ng *NonceGenerator) Next() []byte

Next returns the next nonce and increments sequence number

func (*NonceGenerator) SetSeqNo

func (ng *NonceGenerator) SetSeqNo(seqNo uint64)

SetSeqNo sets the sequence number (for resumption)

Jump to

Keyboard shortcuts

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