package aead

import "git.sr.ht/~pingoo/stdx/crypto/aead"

Index

Constants

const (
	// Aes256GcmKeySize is the size of the key used by the AES-256-GCM AEAD, in bytes.
	Aes256GcmKeySize = crypto.Size256

	// Aes256GcmNonceSize is the size of the nonce used with the AES-256-GCM
	// variant of this AEAD, in bytes.
	Aes256GcmNonceSize = crypto.Size96
)

Functions

func Decrypt

func Decrypt(cipher cipher.AEAD, key, ciphertext, additionalData []byte) (plaintext []byte, err error)

DecryptWithNonce is an helper function to symetrically decrypt a piece of data using the provided cipher The nonce should be at the begining of the ciphertext

func DecryptWithNonce

func DecryptWithNonce(key, nonce, ciphertext, additionalData []byte) (plaintext []byte, err error)

DecryptWithNonce is an helper function to symetrically decrypt a piece of data using AES-256-GCM taking the nonce as a separate piece of input

func Encrypt

func Encrypt(cipher cipher.AEAD, key, plaintext, additionalData []byte) (ciphertext []byte, err error)

Encrypt is an helper function to symetrically encrypt a piece of data using the given cipher the nonce is prepended to the ciphertext in the returned buffer

func EncryptWithNonce

func EncryptWithNonce(key, plaintext, additionalData []byte) (ciphertext, nonce []byte, err error)

Encrypt is an helper function to symetrically encrypt a piece of data using AES-256-GCM returning the nonce separatly

func NewAes256Gcm

func NewAes256Gcm(key []byte) (aeadCipher cipher.AEAD, err error)

NewAEAD returns a AES-256-GCM AEAD that uses the given 256-bit key.

func NewAes256GcmKey

func NewAes256GcmKey() ([]byte, error)

NewAes256GcmKey generates a new random secret key.

func NewAes256GcmNonce

func NewAes256GcmNonce() ([]byte, error)

NewAes256GcmKey generates a new random nonce.

Source Files

aes_256_gcm.go encrypt.go

Version
v0.0.0-20240218134121-094174641f6e (latest)
Published
Feb 18, 2024
Platform
linux/amd64
Imports
4 packages
Last checked
4 months ago

Tools for package owners.