aeadutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package aeadutil provides pure AES-GCM helpers shared across runtime/crypto and adapters/vault. All functions are stateless, have zero external dependencies (stdlib only), and follow the same nonce-handling and error- sanitisation conventions as google/tink-go aead/subtle and kubernetes/kubernetes kmsv2/envelope.go.

ref: google/tink-go aead/subtle/aes_gcm.go — AEAD function signature convention ref: kubernetes/kubernetes kmsv2/envelope.go — envelope encryption pattern ref: aws/aws-sdk-go s3crypto — split nonce storage convention

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptGCM

func DecryptGCM(key, ciphertext, nonce, aad []byte) (plaintext []byte, err error)

DecryptGCM decrypts rawCiphertext (not nonce-prefixed) using key, nonce, and aad. The aad must match exactly what was used in EncryptGCM; any mismatch causes AES-GCM authentication failure. Errors are sanitized — the message never contains key material or plaintext.

ref: google/tink-go aead/subtle/aes_gcm.go ref: kubernetes/kubernetes kmsv2/envelope.go — Transformer.TransformFromStorage

func DecryptGCMSelfContained

func DecryptGCMSelfContained(key, blob, aad []byte) (plaintext []byte, err error)

DecryptGCMSelfContained decrypts a nonce-prefixed self-contained blob produced by EncryptGCMSelfContained.

Returns an error containing "blob too short" if the blob is smaller than the AES-GCM nonce size.

ref: google/tink-go aead/subtle/aes_gcm.go

func EncryptGCM

func EncryptGCM(key, plaintext, aad []byte) (ciphertext, nonce []byte, err error)

EncryptGCM encrypts plaintext with key and aad using AES-GCM. Returns (ciphertext, nonce, error). The nonce is NOT prepended to the ciphertext — it is returned separately so callers can store it in a dedicated column (value_nonce). This matches the split-storage convention used by AWS S3 crypto and kubernetes/kubernetes kmsv2/envelope.go.

The nonce is generated internally via crypto/rand; its length is derived from gcm.NonceSize() (standard AES-GCM = 12 bytes).

ref: google/tink-go aead/subtle/aes_gcm.go — AEAD function signature ref: aws/aws-sdk-go s3crypto — split nonce/ciphertext storage

func EncryptGCMSelfContained

func EncryptGCMSelfContained(key, plaintext, aad []byte) (blob []byte, err error)

EncryptGCMSelfContained encrypts plaintext and returns a nonce-prefixed self-contained blob: nonce || ciphertext. Suitable for storing a single opaque blob (e.g. wrapped DEK in value_edk) where a separate nonce column is inconvenient.

ref: google/tink-go aead/subtle/aes_gcm.go — NewAESGCM prepends nonce ref: kubernetes/kubernetes kmsv2/envelope.go — self-contained wrapped DEK

Types

This section is empty.

Jump to

Keyboard shortcuts

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