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

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

#include <xof.h>

Public Member Functions

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

Detailed Description

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

ASCON-XOFA 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::hasha class:

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

The output length should be set to zero for arbitrary-length output. The ascon::xofa 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 694 of file xof.h.

Constructor & Destructor Documentation

◆ xofa_with_output_length() [1/4]

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

Constucts a new ASCON-XOFA object.

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

Definition at line 703 of file xof.h.

◆ xofa_with_output_length() [2/4]

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

Constructs a copy of another ASCON-XOFA object.

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

Definition at line 717 of file xof.h.

◆ xofa_with_output_length() [3/4]

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

Constructs a new ASCON-XOFA 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 732 of file xof.h.

◆ xofa_with_output_length() [4/4]

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

Constructs a new ASCON-XOFA 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 748 of file xof.h.

◆ ~xofa_with_output_length()

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

Destroys this ASCON-XOFA object.

Definition at line 758 of file xof.h.

Member Function Documentation

◆ absorb() [1/4]

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

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

Parameters
dataReference to the byte array to absorb.

Definition at line 823 of file xof.h.

◆ absorb() [2/4]

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

Absorbs the contents of a NUL-terminated C string into this ASCON-XOFA 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 812 of file xof.h.

◆ absorb() [3/4]

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

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

Parameters
strReference to the string to absorb.

Definition at line 890 of file xof.h.

◆ absorb() [4/4]

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

Absorbs more input data into this ASCON-XOFA 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 798 of file xof.h.

◆ operator=()

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

Copies the state of another ASCON-XOFA 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-XOFA object.

Definition at line 771 of file xof.h.

◆ pad()

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

Absorbs enough zeroes into this ASCON-XOFA 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 863 of file xof.h.

◆ reset()

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

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

Definition at line 784 of file xof.h.

◆ squeeze() [1/2]

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

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

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

Definition at line 846 of file xof.h.

◆ squeeze() [2/2]

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

Squeezes output data from this ASCON-XOFA 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 834 of file xof.h.

◆ state() [1/2]

template<size_t outlen>
inline ::ascon_xofa_state_t* ascon::xofa_with_output_length< outlen >::state ( )
inline

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

Returns
A reference to the state.

Definition at line 873 of file xof.h.

◆ state() [2/2]

template<size_t outlen>
const ::ascon_xofa_state_t* ascon::xofa_with_output_length< outlen >::state ( ) const
inline

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

Returns
A constant reference to the state.

Definition at line 880 of file xof.h.


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