aesgcm

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package aesgcm provides an AES-256-GCM implementation of the cipher.Cipher interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher struct{}

Cipher implements cipher.Cipher using AES-256-GCM. Ciphertext format: [12-byte nonce][ciphertext][16-byte GCM auth tag]. Safe for concurrent use.

func New

func New() *Cipher

New returns a new AES-256-GCM cipher.

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(key, ciphertext, aad []byte) ([]byte, error)

Decrypt decrypts ciphertext with the given key and verifies the Additional Authenticated Data (aad) using AES-256-GCM. The key must be exactly 32 bytes. Expects [nonce][ciphertext][tag] format.

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(key, plaintext, aad []byte) ([]byte, error)

Encrypt encrypts plaintext with the given key and Additional Authenticated Data (aad) using AES-256-GCM. The key must be exactly 32 bytes. A random 12-byte nonce is generated for each call. Returns [nonce][ciphertext][tag].

func (*Cipher) KeySize

func (c *Cipher) KeySize() int

KeySize returns 32 (AES-256).

Jump to

Keyboard shortcuts

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