ASCON Suite
Public Member Functions | List of all members
ascon::xof_with_output_length< outlen > Class Template Reference

ASCON-XOF with a specific output length. More...

#include <xof.h>

Public Member Functions

 xof_with_output_length ()
 Constucts a new ASCON-XOF object. More...
 
 xof_with_output_length (const ascon::xof_with_output_length< outlen > &other)
 Constructs a copy of another ASCON-XOF object. More...
 
 xof_with_output_length (const char *function_name, const unsigned char *custom=0, size_t customlen=0)
 Constructs a new ASCON-XOF object with a named function and customization string. More...
 
 xof_with_output_length (const char *function_name, const ascon::byte_array &custom)
 Constructs a new ASCON-XOF object with a named function and customization string. More...
 
 ~xof_with_output_length ()
 Destroys this ASCON-XOF object. More...
 
xof_with_output_length< outlen > & operator= (const ascon::xof_with_output_length< outlen > &other)
 Copies the state of another ASCON-XOF object into this one. More...
 
void reset ()
 Resets this ASCON-XOF object back to the initial state. More...
 
void absorb (const unsigned char *data, size_t len)
 Absorbs more input data into this ASCON-XOF object. More...
 
void absorb (const char *str)
 Absorbs the contents of a NUL-terminated C string into this ASCON-XOF object. More...
 
void absorb (const ascon::byte_array &data)
 Absorbs the contents of a byte array into this ASCON-XOF object. More...
 
void squeeze (unsigned char *data, size_t len)
 Squeezes output data from this ASCON-XOF object. More...
 
ascon::byte_array squeeze (size_t len)
 Squeezes data out of this ASCON-XOF object as a byte array. More...
 
void pad ()
 Absorbs enough zeroes into this ASCON-XOF object to pad the input to the next multiple of the block rate. More...
 
inline ::ascon_xof_state_tstate ()
 Gets a reference to the C version of the ASCON-XOF state. More...
 
const ::ascon_xof_state_tstate () const
 Gets a constant reference to the C version of the ASCON-XOF state. More...
 
void absorb (const std::string &str)
 Absorbs the contents of a standard C++ string into this ASCON-XOF object. More...
 

Detailed Description

template<size_t outlen>
class ascon::xof_with_output_length< outlen >

ASCON-XOF with a specific output length.

This template takes the desired output length in bytes as a parameter. For example, the following produces a result identical to the ascon::hash class:

unsigned char output[32];
hash.absorb("Hello, World!");
hash.squeeze(output, sizeof(output));
ASCON-XOF with a specific output length.
Definition: xof.h:441
void squeeze(unsigned char *data, size_t len)
Squeezes output data from this ASCON-XOF object.
Definition: xof.h:583
void absorb(const unsigned char *data, size_t len)
Absorbs more input data into this ASCON-XOF object.
Definition: xof.h:544

The output length should be set to zero for arbitrary-length output. The ascon::xof type provides a convenient alias for this use case:

unsigned char output2[64];
x.absorb("Hello, World!");
x.squeeze(output2, sizeof(output2));

Definition at line 440 of file xof.h.

Constructor & Destructor Documentation

◆ xof_with_output_length() [1/4]

template<size_t outlen>
ascon::xof_with_output_length< outlen >::xof_with_output_length ( )
inline

Constucts a new ASCON-XOF object.

After construction, the new object is ready to accept input data with absorb().

Definition at line 449 of file xof.h.

◆ xof_with_output_length() [2/4]

template<size_t outlen>
ascon::xof_with_output_length< outlen >::xof_with_output_length ( const ascon::xof_with_output_length< outlen > &  other)
inline

Constructs a copy of another ASCON-XOF object.

Parameters
otherThe other object to copy, which must have the same output length as this class.

Definition at line 463 of file xof.h.

◆ xof_with_output_length() [3/4]

template<size_t outlen>
ascon::xof_with_output_length< outlen >::xof_with_output_length ( const char *  function_name,
const unsigned char *  custom = 0,
size_t  customlen = 0 
)
inlineexplicit

Constructs a new ASCON-XOF object with a named function and customization string.

Parameters
function_nameName of the function; e.g. "KMAC". May be NULL or empty for no function name.
customPoints to the customization string.
customlenNumber of bytes in the customization string.

Definition at line 478 of file xof.h.

◆ xof_with_output_length() [4/4]

template<size_t outlen>
ascon::xof_with_output_length< outlen >::xof_with_output_length ( const char *  function_name,
const ascon::byte_array custom 
)
inline

Constructs a new ASCON-XOF object with a named function and customization string.

Parameters
function_nameName of the function; e.g. "KMAC". May be NULL or empty for no function name.
customThe customization string.

Definition at line 494 of file xof.h.

◆ ~xof_with_output_length()

template<size_t outlen>
ascon::xof_with_output_length< outlen >::~xof_with_output_length ( )
inline

Destroys this ASCON-XOF object.

Definition at line 504 of file xof.h.

Member Function Documentation

◆ absorb() [1/4]

template<size_t outlen>
void ascon::xof_with_output_length< outlen >::absorb ( const ascon::byte_array data)
inline

Absorbs the contents of a byte array into this ASCON-XOF object.

Parameters
dataReference to the byte array to absorb.

Definition at line 572 of file xof.h.

◆ absorb() [2/4]

template<size_t outlen>
void ascon::xof_with_output_length< outlen >::absorb ( const char *  str)
inline

Absorbs the contents of a NUL-terminated C string into this ASCON-XOF object.

Parameters
strPoints to the C string to absorb.

If str is NULL, then this function is equivalent to absorbing the empty string into the state.

Definition at line 558 of file xof.h.

◆ absorb() [3/4]

template<size_t outlen>
void ascon::xof_with_output_length< outlen >::absorb ( const std::string &  str)
inline

Absorbs the contents of a standard C++ string into this ASCON-XOF object.

Parameters
strReference to the string to absorb.

Definition at line 639 of file xof.h.

◆ absorb() [4/4]

template<size_t outlen>
void ascon::xof_with_output_length< outlen >::absorb ( const unsigned char *  data,
size_t  len 
)
inline

Absorbs more input data into this ASCON-XOF object.

Parameters
dataPoints to the input data to be absorbed into the state.
lenLength of the input data to be absorbed into the state.

Definition at line 544 of file xof.h.

◆ operator=()

template<size_t outlen>
xof_with_output_length<outlen>& ascon::xof_with_output_length< outlen >::operator= ( const ascon::xof_with_output_length< outlen > &  other)
inline

Copies the state of another ASCON-XOF object into this one.

Parameters
otherThe other object to copy, which must have the same output length as this class.
Returns
A reference to this ASCON-XOF object.

Definition at line 517 of file xof.h.

◆ pad()

template<size_t outlen>
void ascon::xof_with_output_length< outlen >::pad ( )
inline

Absorbs enough zeroes into this ASCON-XOF object to pad the input to the next multiple of the block rate.

Does nothing if the state is already aligned on a multiple of the block rate.

This function can avoid unnecessary XOR-with-zero operations to save some time when padding is required.

Definition at line 612 of file xof.h.

◆ reset()

template<size_t outlen>
void ascon::xof_with_output_length< outlen >::reset ( )
inline

Resets this ASCON-XOF object back to the initial state.

Definition at line 530 of file xof.h.

◆ squeeze() [1/2]

template<size_t outlen>
ascon::byte_array ascon::xof_with_output_length< outlen >::squeeze ( size_t  len)
inline

Squeezes data out of this ASCON-XOF object as a byte array.

Parameters
lenThe number of bytes to squeeze out.
Returns
A byte array containing the squeezed data.

Definition at line 595 of file xof.h.

◆ squeeze() [2/2]

template<size_t outlen>
void ascon::xof_with_output_length< outlen >::squeeze ( unsigned char *  data,
size_t  len 
)
inline

Squeezes output data from this ASCON-XOF object.

Parameters
dataPoints to the output buffer to receive the squeezed data.
lenNumber of bytes of data to squeeze out of the state.

Definition at line 583 of file xof.h.

◆ state() [1/2]

template<size_t outlen>
inline ::ascon_xof_state_t* ascon::xof_with_output_length< outlen >::state ( )
inline

Gets a reference to the C version of the ASCON-XOF state.

Returns
A reference to the state.

Definition at line 622 of file xof.h.

◆ state() [2/2]

template<size_t outlen>
const ::ascon_xof_state_t* ascon::xof_with_output_length< outlen >::state ( ) const
inline

Gets a constant reference to the C version of the ASCON-XOF state.

Returns
A constant reference to the state.

Definition at line 629 of file xof.h.


The documentation for this class was generated from the following file: