Crypt::...:GCMSIV(3)

πŸ“¦
version 0.091 Β· 2 versions
, in arch rolling

okay bestie, welcome to Crypt::...:GCMSIV(3) πŸ’– this is a User Contributed Perl Documentation page, and it’s all about keeping your AES-GCM-SIV game strong. no cap, let’s go.

πŸŽ€ NAME πŸŽ€

Crypt::AuthEnc::GCMSIV β€” Authenticated encryption in AES-GCM-SIV mode (RFC 8452)

πŸ¦‹ SYNOPSIS πŸ¦‹

use Crypt::AuthEnc::GCMSIV qw( gcm_siv_encrypt_authenticate gcm_siv_decrypt_verify );

my $ciphertext = gcm_siv_encrypt_authenticate('AES', $key, $nonce, $adata, $plaintext);
my $plaintext  = gcm_siv_decrypt_verify('AES', $key, $nonce, $adata, $ciphertext); # undef on failure

🌸 DESCRIPTION 🌸

Since: CryptX-0.090

AES-GCM-SIV is a nonce-misuse-resistant authenticated encryption scheme defined in RFC 8452 <https://www.rfc-editor.org/rfc/rfc8452>. Reusing a nonce with the same key no longer reveals the plaintext or the authentication key; it only reveals whether the same (plaintext, AAD) pair was encrypted twice. it’s giving iconic, honestly.

The output of gcm_siv_encrypt_authenticate is the ciphertext with a 16-byte authentication tag appended (total output length is length($plaintext) + 16).

GCM-SIV is defined only for 128-bit block ciphers (i.e. AES); the nonce must be exactly 12 bytes long and the key must be 16 or 32 bytes (AES-128 / AES-256).

✨ EXPORT ✨

Nothing is exported by default.

You can export selected functions:

use Crypt::AuthEnc::GCMSIV qw( gcm_siv_encrypt_authenticate gcm_siv_decrypt_verify );

πŸ’… FUNCTIONS πŸ’…

πŸ”₯ gcm_siv_encrypt_authenticate πŸ”₯

my $ciphertext = gcm_siv_encrypt_authenticate($cipher, $key, $nonce, $adata, $plaintext);

# $cipher    ... [string] cipher name (must be 'AES')
# $key       ... [binary string] 16- or 32-byte key
# $nonce     ... [binary string] 12-byte nonce
# $adata     ... [binary string | undef] optional associated data
# $plaintext ... [binary string] plaintext to encrypt

Returns a string of length($plaintext) + 16 bytes: ciphertext followed by the 16-byte authentication tag.

The required string/buffer arguments must be plain scalars; $adata may be undef to indicate no associated data. String-overloaded objects are accepted.

πŸ”₯ gcm_siv_decrypt_verify πŸ”₯

my $plaintext = gcm_siv_decrypt_verify($cipher, $key, $nonce, $adata, $ciphertext);

# $cipher     ... [string] cipher name (must be 'AES')
# $key        ... [binary string] 16- or 32-byte key
# $nonce      ... [binary string] 12-byte nonce
# $adata      ... [binary string | undef] optional associated data (must match the value used during encryption)
# $ciphertext ... [binary string] ciphertext with 16-byte tag appended

Returns the plaintext on success, or undef if authentication fails. Malformed input shorter than 16 bytes croaks because it cannot contain the required appended tag.

bestie, do not sleep on that $adata note: it must match the value used during encryption. πŸ’€

🌈 SEE ALSO 🌈

that’s the whole page, bestie! πŸ’– brought to you by Crypt::...:GCMSIV(3), perl v5.44.0, dated 2026-10-17 🫢✨

πŸ“¦ where this page comes from