.\" -*- 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::Digest::KangarooTwelve 3" .TH Crypt::Digest::KangarooTwelve 3 2026-05-12 "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::Digest::KangarooTwelve \- XOF (extendable output) hash function KangarooTwelve .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Crypt::Digest::KangarooTwelve; \& \& my $d = Crypt::Digest::KangarooTwelve\->new(128); # 128\-bit security \& $d\->add(\*(Aqany data\*(Aq); \& $d\->customization(\*(Aqoptional context string\*(Aq); \& my $result = $d\->done(32); # 32 bytes of output \& \& # or absorb input from a file instead \& my $file_d = Crypt::Digest::KangarooTwelve\->new(128); \& $file_d\->addfile(\*(Aqfilename.dat\*(Aq); \& $file_d\->customization(\*(Aqoptional context string\*(Aq); \& my $file_result = $file_d\->done(32); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\fISince: CryptX\-0.089\fR .PP Provides an interface to KangarooTwelve (K12) as defined in RFC 9861 . .PP KangarooTwelve is a fast cryptographic hash and XOF based on a reduced\-round (12\-round) Keccak\-p permutation. It supports an optional \fBcustomization string\fR that binds the output to a specific context. \f(CWdone()\fR can be called multiple times to stream arbitrary amounts of output. .PP \&\fBOrder of operations\fR: \f(CWadd()\fR must be called before \f(CWcustomization()\fR; \&\f(CWcustomization()\fR must be called before \f(CWdone()\fR. After the first \f(CWdone()\fR, treat the object as being in output mode: do not call \f(CWadd()\fR or \f(CWcustomization()\fR again on that state. Use \f(CWreset()\fR or a new object to start hashing a new message. .SH METHODS .IX Header "METHODS" Unless noted otherwise, assume \f(CW$d\fR is an existing KangarooTwelve object created via \f(CW\*(C`new\*(C'\fR, for example: .PP .Vb 1 \& my $d = Crypt::Digest::KangarooTwelve\->new(128); .Ve .SS new .IX Subsection "new" .Vb 2 \& my $d = Crypt::Digest::KangarooTwelve\->new($num); \& # $num ... [integer] 128 or 256 (security level in bits) .Ve .SS clone .IX Subsection "clone" .Vb 1 \& my $d2 = $d\->clone; .Ve .SS reset .IX Subsection "reset" .Vb 1 \& $d\->reset; .Ve .SS add .IX Subsection "add" Appends data to the message. Returns the object itself (for chaining). .PP Each argument is converted to bytes using Perl\*(Aqs usual scalar stringification. Defined scalars, including numbers and string\-overloaded objects, are accepted. \f(CW\*(C`undef\*(C'\fR is treated as an empty string and may emit Perl\*(Aqs usual "uninitialized value" warning. .PP .Vb 3 \& $d\->add(\*(Aqany data\*(Aq); \& #or \& $d\->add(\*(Aqchunk1\*(Aq, \*(Aqchunk2\*(Aq, ...); .Ve .SS addfile .IX Subsection "addfile" Reads the file content and appends it to the message. Returns the object itself (for chaining). .PP .Vb 4 \& $d\->addfile(\*(Aqfilename.dat\*(Aq); \& #or \& my $filehandle = ...; # existing binary\-mode filehandle \& $d\->addfile($filehandle); .Ve .SS customization .IX Subsection "customization" .Vb 1 \& $d\->customization(\*(Aqcontext string\*(Aq); # optional; call after add(), before done() .Ve .PP Each argument is converted to bytes using Perl\*(Aqs usual scalar stringification. Defined scalars, including numbers and string\-overloaded objects, are accepted. \f(CW\*(C`undef\*(C'\fR is treated as an empty string and may emit Perl\*(Aqs usual "uninitialized value" warning. .SS done .IX Subsection "done" Returns \f(CW$len\fR bytes of output as a binary string. Can be called repeatedly to stream an unlimited amount of output from the same absorbed input. The \&\f(CW$len\fR argument is required and must be a positive integer. Single \&\f(CWdone()\fR calls are limited to 1,000,000,000 bytes, but the recommended way to read large output is to call \f(CWdone()\fR repeatedly in 10 MB chunks. .PP After the first \f(CWdone()\fR call the object is in output mode. Calling \&\f(CWadd()\fR or \f(CWcustomization()\fR in this state croaks; use \&\f(CWreset()\fR or create a new object to hash a different message. .PP .Vb 3 \& my $result_raw = $d\->done($len); \& # can be called multiple times; $len is the number of output bytes to read \& # after the first done(), add() / customization() croak until you call reset() .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" .IP \(bu 4 CryptX, Crypt::Digest::SHAKE, Crypt::Digest::TurboSHAKE .IP \(bu 4 RFC 9861