.\" $NetBSD: SHAKE.3,v 1.1 2017/11/30 16:00:48 wiz Exp $ .\" .\" Copyright (c) 2015 Taylor R. Campbell .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd October 14, 2015 .Dt SHAKE 3 .Os .Sh NAME .Nm SHAKE .Nd NIST FIPS PUB 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions .Sh SYNOPSIS .In sha3.h .Ft void .Fn SHAKE128_Init "SHAKE128_CTX *ctx" .Ft void .Fn SHAKE128_Update "SHAKE128_CTX *ctx" "const uint8_t *buf" "size_t len" .Ft void .Fn SHAKE128_Final "uint8_t *output[]" "size_t outlen" "SHAKE128_CTX *ctx" .Ft void .Fn SHAKE256_Init "SHAKE256_CTX *ctx" .Ft void .Fn SHAKE256_Update "SHAKE256_CTX *ctx" "const uint8_t *buf" "size_t len" .Ft void .Fn SHAKE256_Final "uint8_t *output[]" "size_t outlen" "SHAKE256_CTX *ctx" .Sh DESCRIPTION The .Nm functions implement the extendable-output functions of the NIST SHA-3 standard, FIPS PUB 202. The .Nm functions absorb an arbitrary-length message m and yield an arbitrary-length output SHAKE128(m) or SHAKE256(m), truncated to a specified number of octets. .Pp Before using the .Nm functions, applications should first call .Xr SHA3_Selftest 3 and confirm that it succeeded. .Pp Only the .Nm SHAKE128 functions are specified in detail; the .Nm SHAKE256 functions are analogous. .Pp The caller must allocate memory for a .Vt SHAKE128_CTX object to hold the state of a SHAKE128 computation over a message. .Vt SHAKE128_CTX objects may be copied or relocated in memory. .Bl -tag -width abcd .It Fn SHAKE128_Init "ctx" Initialize a SHAKE128 context. Must be done before any other operations on .Fa ctx . .It Fn SHAKE128_Update "ctx" "data" "len" Append .Fa len octets at .Fa data to the message. .It Fn SHAKE128_Final "output" "outlen" "ctx" Store at .Fa output the first .Fa outlen octets of the SHAKE128 output for the message obtained by concatenating all prior inputs to .Fn SHAKE128_Update on .Fa ctx . .Pp Subsequent use of .Fa ctx is not allowed, unless it is reinitialized with .Fn SHAKE128_Init . .El .Sh SEE ALSO .Xr keccak 3 , .Xr sha3 3 , .Xr SHA3_Selftest 3 .Sh STANDARDS .Rs .%A National Institute of Standards and Technology .%T SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions .%O FIPS PUB 202 .%D August 2015 .Re .Sh AUTHORS .An Taylor R Campbell Aq campbell+sha3@mumble.net