.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "Crypt::AuthEnc::GCMSIV 3" .TH Crypt::AuthEnc::GCMSIV 3 2026-06-18 "perl v5.42.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Crypt::AuthEnc::GCMSIV \- Authenticated encryption in AES\-GCM\-SIV mode (RFC 8452) .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Crypt::AuthEnc::GCMSIV qw( gcm_siv_encrypt_authenticate gcm_siv_decrypt_verify ); \& \& my $ciphertext = gcm_siv_encrypt_authenticate(\*(AqAES\*(Aq, $key, $nonce, $adata, $plaintext); \& my $plaintext = gcm_siv_decrypt_verify(\*(AqAES\*(Aq, $key, $nonce, $adata, $ciphertext); # undef on failure .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\fISince: CryptX\-0.090\fR .PP AES\-GCM\-SIV is a nonce\-misuse\-resistant authenticated encryption scheme defined in RFC 8452 . 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. .PP The output of \f(CW\*(C`gcm_siv_encrypt_authenticate\*(C'\fR is the ciphertext with a 16\-byte authentication tag appended (total output length is \f(CW\*(C`length($plaintext) + 16\*(C'\fR). .PP 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). .SH EXPORT .IX Header "EXPORT" Nothing is exported by default. .PP You can export selected functions: .PP .Vb 1 \& use Crypt::AuthEnc::GCMSIV qw( gcm_siv_encrypt_authenticate gcm_siv_decrypt_verify ); .Ve .SH FUNCTIONS .IX Header "FUNCTIONS" .SS gcm_siv_encrypt_authenticate .IX Subsection "gcm_siv_encrypt_authenticate" .Vb 1 \& my $ciphertext = gcm_siv_encrypt_authenticate($cipher, $key, $nonce, $adata, $plaintext); \& \& # $cipher ... [string] cipher name (must be \*(AqAES\*(Aq) \& # $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 .Ve .PP Returns a string of \f(CW\*(C`length($plaintext) + 16\*(C'\fR bytes: ciphertext followed by the 16\-byte authentication tag. .PP The required string/buffer arguments must be plain scalars; \f(CW$adata\fR may be \&\f(CW\*(C`undef\*(C'\fR to indicate no associated data. String\-overloaded objects are accepted. .SS gcm_siv_decrypt_verify .IX Subsection "gcm_siv_decrypt_verify" .Vb 1 \& my $plaintext = gcm_siv_decrypt_verify($cipher, $key, $nonce, $adata, $ciphertext); \& \& # $cipher ... [string] cipher name (must be \*(AqAES\*(Aq) \& # $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 .Ve .PP Returns the plaintext on success, or \f(CW\*(C`undef\*(C'\fR if authentication fails. Malformed input shorter than 16 bytes croaks because it cannot contain the required appended tag. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP \(bu 4 CryptX, Crypt::AuthEnc::GCM, Crypt::AuthEnc::SIV .IP \(bu 4 RFC 8452