Loading...
Searching...
No Matches

Implementation of the SHA-3 hashing function. More...

Detailed Description

Implementation of the SHA-3 hashing function.

Files

file  sha3.h
 Header definitions for the SHA-3 hash function.
 

Data Structures

struct  keccak_state_t
 Context for operations on a sponge with keccak permutation. More...
 

Macros

#define SHA3_256_DIGEST_LENGTH   32
 Length of SHA3-256 digests in bytes.
 
#define SHA3_384_DIGEST_LENGTH   48
 Length of SHA3-384 digests in bytes.
 
#define SHA3_512_DIGEST_LENGTH   64
 Length of SHA3-512 digests in bytes.
 

Functions

void Keccak_init (keccak_state_t *ctx, unsigned int rate, unsigned int capacity, unsigned char delimitedSuffix)
 Initialise a sponge based on a keccak-1600 permutation.
 
void Keccak_update (keccak_state_t *ctx, const unsigned char *input, unsigned long long int inputByteLen)
 Absorbs data into a sponge.
 
void Keccak_final (keccak_state_t *ctx, unsigned char *output, unsigned long long int outputByteLen)
 Squeeze data from a sponge.
 
void sha3_256_init (keccak_state_t *ctx)
 SHA3-256 initialization.
 
void sha3_update (keccak_state_t *ctx, const void *data, size_t len)
 Add bytes into the hash.
 
void sha3_256_final (keccak_state_t *ctx, void *digest)
 SHA3-256 finalization.
 
void sha3_384_init (keccak_state_t *ctx)
 SHA3-384 initialization.
 
void sha3_384_final (keccak_state_t *ctx, void *digest)
 SHA3-384 finalization.
 
void sha3_512_init (keccak_state_t *ctx)
 SHA3-512 initialization.
 
void sha3_512_final (keccak_state_t *ctx, void *digest)
 SHA3-512 finalization.
 
void sha3_256 (void *digest, const void *data, size_t len)
 A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-256 from one buffer.
 
void sha3_384 (void *digest, const void *data, size_t len)
 A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-384 from one buffer.
 
void sha3_512 (void *digest, const void *data, size_t len)
 A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-512 from one buffer.
 

Macro Definition Documentation

◆ SHA3_256_DIGEST_LENGTH

#define SHA3_256_DIGEST_LENGTH   32

Length of SHA3-256 digests in bytes.

Definition at line 39 of file sha3.h.

◆ SHA3_384_DIGEST_LENGTH

#define SHA3_384_DIGEST_LENGTH   48

Length of SHA3-384 digests in bytes.

Definition at line 44 of file sha3.h.

◆ SHA3_512_DIGEST_LENGTH

#define SHA3_512_DIGEST_LENGTH   64

Length of SHA3-512 digests in bytes.

Definition at line 49 of file sha3.h.

Function Documentation

◆ Keccak_final()

void Keccak_final ( keccak_state_t ctx,
unsigned char *  output,
unsigned long long int  outputByteLen 
)

Squeeze data from a sponge.

Parameters
[in,out]ctxcontext handle of the sponge
[out]outputthe squeezed data
[in]outputByteLensize of the data to be squeezed.

◆ Keccak_init()

void Keccak_init ( keccak_state_t ctx,
unsigned int  rate,
unsigned int  capacity,
unsigned char  delimitedSuffix 
)

Initialise a sponge based on a keccak-1600 permutation.

Parameters
[out]ctxcontext handle to initialise
[in]ratethe desired rate of the sponge
[in]capacitythe desired capacity of the sponge
[in]delimitedSuffixsuffix to be appended to the message after the absorbation phase

◆ Keccak_update()

void Keccak_update ( keccak_state_t ctx,
const unsigned char *  input,
unsigned long long int  inputByteLen 
)

Absorbs data into a sponge.

Can be called multiple times

Parameters
[in,out]ctxcontext handle of the sponge
[in]inputpointer to the data to be absorbed
[in]inputByteLenlength of the input data in bytes

◆ sha3_256()

void sha3_256 ( void *  digest,
const void *  data,
size_t  len 
)

A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-256 from one buffer.

Parameters
[in]datapointer to the buffer to generate hash from
[in]lenlength of the buffer
[out]digestpointer to an array for the result, length must be SHA3_256_DIGEST_LENGTH

◆ sha3_256_final()

void sha3_256_final ( keccak_state_t ctx,
void *  digest 
)

SHA3-256 finalization.

Pads the input data and exports the hash value

Parameters
[in,out]ctxcontext handle to use
[out]digestresulting digest, this is the hash of all the bytes

◆ sha3_256_init()

void sha3_256_init ( keccak_state_t ctx)

SHA3-256 initialization.

Begins a SHA3-256 operation.

Parameters
[in]ctxkeccak_state_t handle to initialise

◆ sha3_384()

void sha3_384 ( void *  digest,
const void *  data,
size_t  len 
)

A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-384 from one buffer.

Parameters
[in]datapointer to the buffer to generate hash from
[in]lenlength of the buffer
[out]digestpointer to an array for the result, length must be SHA3_384_DIGEST_LENGTH

◆ sha3_384_final()

void sha3_384_final ( keccak_state_t ctx,
void *  digest 
)

SHA3-384 finalization.

Pads the input data and exports the hash value

Parameters
[in,out]ctxcontext handle to use
[out]digestresulting digest, this is the hash of all the bytes

◆ sha3_384_init()

void sha3_384_init ( keccak_state_t ctx)

SHA3-384 initialization.

Begins a SHA3-384 operation.

Parameters
[in]ctxkeccak_state_t handle to initialise

◆ sha3_512()

void sha3_512 ( void *  digest,
const void *  data,
size_t  len 
)

A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-512 from one buffer.

Parameters
[in]datapointer to the buffer to generate hash from
[in]lenlength of the buffer
[out]digestpointer to an array for the result, length must be SHA3_512_DIGEST_LENGTH

◆ sha3_512_final()

void sha3_512_final ( keccak_state_t ctx,
void *  digest 
)

SHA3-512 finalization.

Pads the input data and exports the hash value

Parameters
[in,out]ctxcontext handle to use
[out]digestresulting digest, this is the hash of all the bytes

◆ sha3_512_init()

void sha3_512_init ( keccak_state_t ctx)

SHA3-512 initialization.

Begins a SHA3-512 operation.

Parameters
[in]ctxkeccak_state_t handle to initialise

◆ sha3_update()

void sha3_update ( keccak_state_t ctx,
const void *  data,
size_t  len 
)

Add bytes into the hash.

Parameters
[in,out]ctxcontext handle to use
[in]dataInput data
[in]lenLength of data