cipher

package
v0.0.0-...-2514748 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package cipher implements Families 5 and 6. Family 5: encrypt(), decrypt() — AES-256-GCM, ChaCha20-Poly1305. Family 6: encrypt_det(), decrypt_det() — AES-256-SIV.

Nonce is generated internally by DRBG on every encrypt call. Caller cannot supply nonce. Output is always a CryptoEnvelope struct.

Index

Constants

View Source
const (
	AlgorithmAES256GCM        = "AES-256-GCM"
	AlgorithmChaCha20Poly1305 = "ChaCha20-Poly1305"
	AlgorithmAES256SIV        = "AES-256-SIV"
)

Algorithm identifiers.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(key []byte, env *envelope.Envelope, context string, algorithm string) ([]byte, error)

Decrypt decrypts an Envelope using key and algorithm. Family 5: decrypt(key []byte, envelope Envelope, context string, algorithm string) ([]byte, error)

func DecryptDet

func DecryptDet(key []byte, ciphertext []byte, context string) ([]byte, error)

DecryptDet decrypts AES-256-SIV ciphertext. Family 6: decrypt_det(key []byte, ciphertext []byte, context string) ([]byte, error)

func Encrypt

func Encrypt(key []byte, plaintext []byte, context string, algorithm string) (*envelope.Envelope, error)

Encrypt encrypts plaintext using key and algorithm, returning an Envelope. Family 5: encrypt(key []byte, plaintext []byte, context string, algorithm string) (Envelope, error)

Supported algorithms: AES-256-GCM, ChaCha20-Poly1305. context is bound as AAD and must match at decrypt. Nonce is generated internally.

func EncryptDet

func EncryptDet(key []byte, plaintext []byte, context string) ([]byte, error)

EncryptDet encrypts plaintext using AES-256-SIV (deterministic encryption). Family 6: encrypt_det(key []byte, plaintext []byte, context string) ([]byte, error)

Key must be 64 bytes (two AES-256 keys). Same key + same plaintext + same context always produces same ciphertext.

Types

This section is empty.

Jump to

Keyboard shortcuts

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