Keccak core sponge function. More...
#include <KeccakCore.h>
Public Member Functions | |
KeccakCore () | |
Constructs a new Keccak sponge function. More... | |
~KeccakCore () | |
Destroys this Keccak sponge function after clearing all sensitive information. | |
size_t | capacity () const |
Returns the capacity of the sponge function in bits. More... | |
void | setCapacity (size_t capacity) |
Sets the capacity of the Keccak sponge function in bits. More... | |
size_t | blockSize () const |
Returns the input block size for the sponge function in bytes. More... | |
void | reset () |
Resets the Keccak sponge function ready for a new session. More... | |
void | update (const void *data, size_t size) |
Updates the Keccak sponge function with more input data. More... | |
void | pad (uint8_t tag) |
Pads the last block of input data to blockSize(). More... | |
void | extract (void *data, size_t size) |
Extracts data from the Keccak sponge function. More... | |
void | clear () |
Clears all sensitive data from this object. | |
Keccak core sponge function.
KeccakCore provides the core sponge function for different capacities. It is used to implement Hash algorithms such as SHA3.
References: http://en.wikipedia.org/wiki/SHA-3
Definition at line 29 of file KeccakCore.h.
KeccakCore::KeccakCore | ( | ) |
Constructs a new Keccak sponge function.
The capacity() will initially be set to 1536, which normally won't be of much use to the caller. The constructor should be followed by a call to setCapacity() to select the capacity of interest.
Definition at line 49 of file KeccakCore.cpp.
|
inline |
Returns the input block size for the sponge function in bytes.
The block size is (1600 - capacity()) / 8.
Definition at line 38 of file KeccakCore.h.
size_t KeccakCore::capacity | ( | ) | const |
Returns the capacity of the sponge function in bits.
Definition at line 71 of file KeccakCore.cpp.
void KeccakCore::extract | ( | void * | data, |
size_t | size | ||
) |
Extracts data from the Keccak sponge function.
data | The data buffer to fill with extracted data. |
size | The number number of bytes of extracted data that are required. |
If more than blockSize() bytes are required, the sponge function will be invoked to generate additional data.
Definition at line 201 of file KeccakCore.cpp.
void KeccakCore::pad | ( | uint8_t | tag | ) |
Pads the last block of input data to blockSize().
tag | The tag byte to add to the padding to identify SHA3 (0x06), SHAKE (0x1F), or the plain pre-standardized version of Keccak (0x01). |
The sponge function will be invoked to process the completed padding block.
Definition at line 174 of file KeccakCore.cpp.
void KeccakCore::reset | ( | ) |
Resets the Keccak sponge function ready for a new session.
Definition at line 109 of file KeccakCore.cpp.
void KeccakCore::setCapacity | ( | size_t | capacity | ) |
Sets the capacity of the Keccak sponge function in bits.
capacity | The capacity of the Keccak sponge function in bits which should be a multiple of 64 and between 64 and 1536. |
Definition at line 89 of file KeccakCore.cpp.
void KeccakCore::update | ( | const void * | data, |
size_t | size | ||
) |
Updates the Keccak sponge function with more input data.
data | The extra input data to incorporate. |
size | The size of the new data to incorporate. |
This function will invoke the sponge function whenever a full blockSize() bytes of input data have been accumulated. Call pad() after the last block to finalize the input before calling extract().
Definition at line 128 of file KeccakCore.cpp.