Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
Data Structures | Macros | Functions
internal-subterranean.h File Reference

Internal implementation of the Subterranean block operation. More...

#include "internal-util.h"

Go to the source code of this file.

Data Structures

struct  subterranean_state_t
 Representation of the 257-bit state of Subterranean. More...
 

Macros

#define subterranean_duplex_0(state)
 Performs a single Subterranean round and absorbs 0 bytes. More...
 
#define subterranean_duplex_1(state, data)
 Performs a single Subterranean round and absorbs one byte. More...
 
#define subterranean_duplex_word(state, x)
 Absorbs a 32-bit word into the Subterranean state after performing the round function. More...
 
#define subterranean_duplex_4(state, data)
 Performs a single Subterranean round and absorbs four bytes. More...
 

Functions

void subterranean_round (subterranean_state_t *state)
 Performs a single Subterranean round. More...
 
void subterranean_blank (subterranean_state_t *state)
 Performs 8 Subterranean rounds with no absorption or squeezing of data; i.e. data input and output is "blanked". More...
 
void subterranean_absorb_1 (subterranean_state_t *state, unsigned char data)
 Absorbs a single byte into the Subterranean state. More...
 
void subterranean_absorb_word (subterranean_state_t *state, uint32_t x)
 Absorbs a 32-bit word into the Subterranean state. More...
 
void subterranean_duplex_n (subterranean_state_t *state, const unsigned char *data, unsigned len)
 Performs a single Subterranean round and absorbs between zero and four bytes. More...
 
uint32_t subterranean_extract (subterranean_state_t *state)
 Extracts 32 bits of output from the Subterranean state. More...
 
void subterranean_absorb (subterranean_state_t *state, const unsigned char *data, unsigned long long len)
 Absorbs an arbitrary amount of data, four bytes at a time. More...
 
void subterranean_squeeze (subterranean_state_t *state, unsigned char *data, unsigned len)
 Squeezes an arbitrary amount of data out of a Subterranean state. More...
 

Detailed Description

Internal implementation of the Subterranean block operation.

References: https://cs.ru.nl/~joan/subterranean.html

Macro Definition Documentation

#define subterranean_duplex_0 (   state)
Value:
do { \
(state)->x[0] ^= 2; /* padding for an empty block */ \
} while (0)
void subterranean_round(subterranean_state_t *state)
Performs a single Subterranean round.
Definition: internal-subterranean.c:28

Performs a single Subterranean round and absorbs 0 bytes.

Parameters
stateSubterranean state to be transformed.
#define subterranean_duplex_1 (   state,
  data 
)
Value:
do { \
subterranean_absorb_1((state), (data)); \
} while (0)
void subterranean_absorb_1(subterranean_state_t *state, unsigned char data)
Absorbs a single byte into the Subterranean state.
Definition: internal-subterranean.c:173
void subterranean_round(subterranean_state_t *state)
Performs a single Subterranean round.
Definition: internal-subterranean.c:28

Performs a single Subterranean round and absorbs one byte.

Parameters
stateSubterranean state to be transformed.
dataThe single byte to be absorbed.
#define subterranean_duplex_4 (   state,
  data 
)
Value:
do { \
subterranean_duplex_word((state), (data)); \
(state)->x[8] ^= 1; \
} while (0)
#define subterranean_duplex_word(state, x)
Absorbs a 32-bit word into the Subterranean state after performing the round function.
Definition: internal-subterranean.h:112

Performs a single Subterranean round and absorbs four bytes.

Parameters
stateSubterranean state to be transformed.
data32-bit word containing the four data bytes to be absorbed.
#define subterranean_duplex_word (   state,
 
)
Value:
do { \
subterranean_absorb_word((state), (x)); \
} while (0)
void subterranean_absorb_word(subterranean_state_t *state, uint32_t x)
Absorbs a 32-bit word into the Subterranean state.
Definition: internal-subterranean.c:187
void subterranean_round(subterranean_state_t *state)
Performs a single Subterranean round.
Definition: internal-subterranean.c:28

Absorbs a 32-bit word into the Subterranean state after performing the round function.

Parameters
stateSubterranean state to be transformed.
xThe word to absorb into the state.

Function Documentation

void subterranean_absorb ( subterranean_state_t state,
const unsigned char *  data,
unsigned long long  len 
)

Absorbs an arbitrary amount of data, four bytes at a time.

Parameters
stateSubterranean state to be transformed.
dataPoints to the bytes to be absorbed.
lenNumber of bytes to absorb.
void subterranean_absorb_1 ( subterranean_state_t state,
unsigned char  data 
)

Absorbs a single byte into the Subterranean state.

Parameters
stateSubterranean state to be transformed.
dataThe single byte to be absorbed.
void subterranean_absorb_word ( subterranean_state_t state,
uint32_t  x 
)

Absorbs a 32-bit word into the Subterranean state.

Parameters
stateSubterranean state to be transformed.
xThe word to absorb into the state.
void subterranean_blank ( subterranean_state_t state)

Performs 8 Subterranean rounds with no absorption or squeezing of data; i.e. data input and output is "blanked".

Parameters
stateSubterranean state to be transformed.
void subterranean_duplex_n ( subterranean_state_t state,
const unsigned char *  data,
unsigned  len 
)

Performs a single Subterranean round and absorbs between zero and four bytes.

Parameters
stateSubterranean state to be transformed.
dataPoints to the data bytes to be absorbed.
lenLength of the data to be absorbed.
uint32_t subterranean_extract ( subterranean_state_t state)

Extracts 32 bits of output from the Subterranean state.

Parameters
stateSubterranean state to extract the output from.
Returns
Returns the 32-bit word that was extracted.
void subterranean_round ( subterranean_state_t state)

Performs a single Subterranean round.

Parameters
stateSubterranean state to be transformed.
void subterranean_squeeze ( subterranean_state_t state,
unsigned char *  data,
unsigned  len 
)

Squeezes an arbitrary amount of data out of a Subterranean state.

Parameters
stateSubterranean state to extract the output from.
dataPoints to the data buffer to receive the output.
lenNumber of bytes to be extracted.