$NetBSD: sha3.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 SHA3 3 .Os .Sh NAME .Nm SHA3 .Nd NIST FIPS PUB 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions .Sh SYNOPSIS n sha3.h .Ft void .Fn SHA3_224_Init "SHA3_224_CTX *ctx" .Ft void .Fn SHA3_224_Update "SHA3_224_CTX *ctx" "const uint8_t *buf" "size_t len" .Ft void .Fn SHA3_224_Final "uint8_t digest[SHA3_224_DIGEST_LENGTH]" "SHA3_224_CTX *ctx" .Ft void .Fn SHA3_256_Init "SHA3_256_CTX *ctx" .Ft void .Fn SHA3_256_Update "SHA3_256_CTX *ctx" "const uint8_t *buf" "size_t len" .Ft void .Fn SHA3_256_Final "uint8_t digest[SHA3_256_DIGEST_LENGTH]" "SHA3_256_CTX *ctx" .Ft void .Fn SHA3_384_Init "SHA3_384_CTX *ctx" .Ft void .Fn SHA3_384_Update "SHA3_384_CTX *ctx" "const uint8_t *buf" "size_t len" .Ft void .Fn SHA3_384_Final "uint8_t digest[SHA3_384_DIGEST_LENGTH]" "SHA3_384_CTX *ctx" .Ft void .Fn SHA3_512_Init "SHA3_512_CTX *ctx" .Ft void .Fn SHA3_512_Update "SHA3_512_CTX *ctx" "const uint8_t *buf" "size_t len" .Ft void .Fn SHA3_512_Final "uint8_t digest[SHA3_512_DIGEST_LENGTH]" "SHA3_512_CTX *ctx" .Sh DESCRIPTION The .Nm functions implement the cryptographic hash functions of the NIST SHA-3 standard, FIPS PUB 202. The .Nm functions compress an arbitrary-length message m into short fixed-length octet strings SHA3-224(m), SHA3-256(m), etc., called a cryptographic digest or hash.

p Before using the .Nm functions, applications should first call .Xr SHA3_Selftest 3 and confirm that it succeeded.

p Only the .Nm SHA3_256 functions are specified in detail; the .Nm SHA3_224 , .Nm SHA3_384 , and .Nm SHA3_512 functions are exactly analogous.

p The caller must allocate memory for a .Vt SHA3_256_CTX object to hold the state of a SHA3-256 hash computation over a message. .Vt SHA3_256_CTX objects are slightly over 200 bytes, and may be copied or relocated in memory. l -tag -width abcd t Fn SHA3_256_Init "ctx" Initialize a SHA3-256 context. Must be done before any other operations on .Fa ctx . t Fn SHA3_256_Update "ctx" "data" "len" Append .Fa len octets at .Fa data to the message. t Fn SHA3_256_Final "digest" "ctx" Store at .Fa digest the 32-octet SHA3-256 hash of the message obtained by concatenating all prior inputs to .Fn SHA3_256_Update on .Fa ctx .

p Subsequent use of .Fa ctx is not allowed, unless it is reinitialized with .Fn SHA3_256_Init . .El .Sh SEE ALSO .Xr keccak 3 , .Xr SHA3_Selftest 3 , .Xr SHAKE 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