KeccakTools
|
#include <duplex.h>
Public Member Functions | |
Duplex (const Transformation *aF, const PaddingRule *aPad, unsigned int aRate) | |
void | duplexing (const UINT8 *input, unsigned int inputLengthInBits, UINT8 *output, unsigned int desiredOutputLengthInBits) |
unsigned int | getCapacity () |
unsigned int | getMaximumInputLength () |
unsigned int | getMaximumOutputLength () |
virtual string | getDescription () const |
Protected Member Functions | |
void | computeRhoMax () |
Protected Attributes | |
const Transformation * | f |
const PaddingRule * | pad |
unsigned int | capacity |
unsigned int | rate |
unsigned int | rho_max |
auto_ptr< UINT8 > | state |
Friends | |
ostream & | operator<< (ostream &a, const Duplex &duplex) |
Class implementing the duplex construction.
Duplex::Duplex | ( | const Transformation * | aF, |
const PaddingRule * | aPad, | ||
unsigned int | aRate | ||
) |
The constructor. The transformation, padding rule and rate are given to the constructor, while the capacity is computed from the function width and the requested rate. The duplex construction is initialized.
aF | A pointer to the transformation used in the sponge construction. |
aPad | A pointer to the padding rule used in the sponge construction. |
aRate | The desired value of the rate (in bits), not necessarily a multiple of 8. |
void Duplex::computeRhoMax | ( | ) | [protected] |
Internal method to compute ρ_max, the maximum input length. This value is such that an input message fits in one block after padding.
void Duplex::duplexing | ( | const UINT8 * | input, |
unsigned int | inputLengthInBits, | ||
UINT8 * | output, | ||
unsigned int | desiredOutputLengthInBits | ||
) |
Method that performs a duplexing call. The input data is given as a sequence of bytes. Within each byte, the bits are understood to be ordered from the least significant bit to the most significant bit. The output data are given using the same structure.
input | The input data. When inputLengthInBits is not a multiple of 8, the last bits of data must be in the least significant bits of the last byte. |
inputLengthInBits | The length in bits of the data provided in input. This value does not need to be a multiple of 8. |
output | The buffer where to store the output data. |
desiredOutputLengthInBits | The length in bits of the output. |
unsigned int Duplex::getCapacity | ( | ) |
Method that returns the capacity of the sponge function.
string Duplex::getDescription | ( | ) | const [virtual] |
Method that returns a string with a description of itself.
unsigned int Duplex::getMaximumInputLength | ( | ) |
Method that returns the maximum input length in bits of the duplexing() method.
unsigned int Duplex::getMaximumOutputLength | ( | ) |
Method that returns the maximum output length in bits of the duplexing() method.
ostream& operator<< | ( | ostream & | a, |
const Duplex & | duplex | ||
) | [friend] |
Method that prints a brief description of the sponge function.
unsigned int Duplex::capacity [protected] |
The capacity of the duplex construction.
const Transformation* Duplex::f [protected] |
The transformation (or permutation) used by the sponge construction. The memory allocated by f is assumed to belong to the caller; this class does not free the allocated memory.
const PaddingRule* Duplex::pad [protected] |
The padding rule used by the sponge construction. The memory allocated by pad is assumed to belong to the caller; this class does not free the allocated memory.
unsigned int Duplex::rate [protected] |
The rate of the duplex construction.
unsigned int Duplex::rho_max [protected] |
The maximum input length of the duplex construction.
auto_ptr<UINT8> Duplex::state [protected] |
The state of the duplex construction.