libdecaf
Loading...
Searching...
No Matches
shake.h File Reference

SHA2-512. More...

Go to the source code of this file.

Classes

struct  decaf_keccak_sponge_s
 Sponge container object for the various primitives. More...

Typedefs

typedef struct decaf_keccak_sponge_s decaf_keccak_sponge_s
 Sponge container object for the various primitives.
typedef struct decaf_keccak_sponge_s decaf_keccak_sponge_t[1]
 Convenience GMP-style one-element array version.

Functions

void DECAF_API_VIS decaf_sha3_init (decaf_keccak_sponge_t sponge, const struct decaf_kparams_s *params)
 Initialize a sponge context object.
decaf_error_t DECAF_API_VIS decaf_sha3_update (struct decaf_keccak_sponge_s *__restrict__ sponge, const uint8_t *in, size_t len)
 Absorb data into a DECAF_SHA3 or DECAF_SHAKE hash context.
decaf_error_t DECAF_API_VIS decaf_sha3_output (decaf_keccak_sponge_t sponge, uint8_t *__restrict__ out, size_t len)
 Squeeze output data from a DECAF_SHA3 or DECAF_SHAKE hash context.
decaf_error_t DECAF_API_VIS decaf_sha3_final (decaf_keccak_sponge_t sponge, uint8_t *__restrict__ out, size_t len)
 Squeeze output data from a DECAF_SHA3 or DECAF_SHAKE hash context.
void DECAF_API_VIS decaf_sha3_reset (decaf_keccak_sponge_t sponge)
 Reset the sponge to the empty string.
size_t DECAF_API_VIS decaf_sha3_default_output_bytes (const decaf_keccak_sponge_t sponge)
 Return the default output length of the sponge construction, for the purpose of C++ default operators.
size_t DECAF_API_VIS decaf_sha3_max_output_bytes (const decaf_keccak_sponge_t sponge)
 Return the default output length of the sponge construction, for the purpose of C++ default operators.
void DECAF_API_VIS decaf_sha3_destroy (decaf_keccak_sponge_t sponge)
 Destroy a DECAF_SHA3 or DECAF_SHAKE sponge context by overwriting it with 0.
decaf_error_t DECAF_API_VIS decaf_sha3_hash (uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen, const struct decaf_kparams_s *params)
 Hash (in) to (out).

Detailed Description

SHA2-512.

SHA-3-n and DECAF_SHAKE-n instances.

Author
Mike Hamburg
Author
Mike Hamburg

Function Documentation

◆ decaf_sha3_default_output_bytes()

size_t DECAF_API_VIS decaf_sha3_default_output_bytes ( const decaf_keccak_sponge_t sponge)

Return the default output length of the sponge construction, for the purpose of C++ default operators.

Returns n/8 for DECAF_SHA3-n and 2n/8 for DECAF_SHAKE-n.

Parameters
[in,out]spongeThe context.

◆ decaf_sha3_destroy()

void DECAF_API_VIS decaf_sha3_destroy ( decaf_keccak_sponge_t sponge)

Destroy a DECAF_SHA3 or DECAF_SHAKE sponge context by overwriting it with 0.

Parameters
[out]spongeThe context.

◆ decaf_sha3_final()

decaf_error_t DECAF_API_VIS decaf_sha3_final ( decaf_keccak_sponge_t sponge,
uint8_t *__restrict__ out,
size_t len )

Squeeze output data from a DECAF_SHA3 or DECAF_SHAKE hash context.

This re-initializes the context to its starting parameters.

Parameters
[in,out]spongeThe context.
[out]outThe output data.
[in]lenThe requested output data length in bytes.

◆ decaf_sha3_hash()

decaf_error_t DECAF_API_VIS decaf_sha3_hash ( uint8_t * out,
size_t outlen,
const uint8_t * in,
size_t inlen,
const struct decaf_kparams_s * params )

Hash (in) to (out).

Parameters
[in]inThe input data.
[in]inlenThe length of the input data.
[out]outA buffer for the output data.
[in]outlenThe length of the output data.
[in]paramsThe parameters of the sponge hash.

◆ decaf_sha3_init()

void DECAF_API_VIS decaf_sha3_init ( decaf_keccak_sponge_t sponge,
const struct decaf_kparams_s * params )

Initialize a sponge context object.

Parameters
[out]spongeThe object to initialize.
[in]paramsThe sponge's parameter description.

◆ decaf_sha3_max_output_bytes()

size_t DECAF_API_VIS decaf_sha3_max_output_bytes ( const decaf_keccak_sponge_t sponge)

Return the default output length of the sponge construction, for the purpose of C++ default operators.

Returns n/8 for DECAF_SHA3-n and SIZE_MAX for DECAF_SHAKE-n.

Parameters
[in,out]spongeThe context.

◆ decaf_sha3_output()

decaf_error_t DECAF_API_VIS decaf_sha3_output ( decaf_keccak_sponge_t sponge,
uint8_t *__restrict__ out,
size_t len )

Squeeze output data from a DECAF_SHA3 or DECAF_SHAKE hash context.

This does not destroy or re-initialize the hash context, and decaf_sha3 output can be called more times.

Parameters
[in,out]spongeThe context.
[out]outThe output data.
[in]lenThe requested output data length in bytes.
Returns
DECAF_FAILURE if the sponge has exhausted its output capacity.
DECAF_SUCCESS otherwise.

◆ decaf_sha3_reset()

void DECAF_API_VIS decaf_sha3_reset ( decaf_keccak_sponge_t sponge)

Reset the sponge to the empty string.

Parameters
[in,out]spongeThe context.

◆ decaf_sha3_update()

decaf_error_t DECAF_API_VIS decaf_sha3_update ( struct decaf_keccak_sponge_s *__restrict__ sponge,
const uint8_t * in,
size_t len )

Absorb data into a DECAF_SHA3 or DECAF_SHAKE hash context.

Parameters
[in,out]spongeThe context.
[in]inThe input data.
[in]lenThe input data's length in bytes.
Returns
DECAF_FAILURE if the sponge has already been used for output.
DECAF_SUCCESS otherwise.