libxcks
0.1.0.1
|
Computes the Keccak hash from a byte stream. More...
#include <keccak.hpp>
Public Member Functions | |
AbstractKeccakImpl ()=delete | |
Disable default constructor. More... | |
AbstractKeccakImpl (const unsigned size, const bool isSHA3Hash=true) | |
Constructs a new Keccak or SHA3 implementation with a hash of size bytes. More... | |
void | reset () override final |
Resets the Keccak hash to initial value. More... | |
void | update (const uint8_t *buf, size_t len) override final |
Updates the Keccak hash with specified array of bytes. More... | |
Public Member Functions inherited from libxcks::ChecksumEx | |
std::string | toString (const bool hexInUpperCase=false) const override |
Returns the hash value has a string. More... | |
Public Member Functions inherited from libxcks::Checksum | |
virtual | ~Checksum () |
Destructor. More... | |
virtual uint8_t * | getValue (uint8_t *buffer) const =0 |
Returns the checksum value in the first bytes of the given address. More... | |
virtual size_t | getSize () const =0 |
Returns the minimal size to allocate in memory to store the checksum with the getValue(buffer) method. More... | |
virtual std::string | getName () const =0 |
Returns the name of the checksum or the hash algorithm. More... | |
virtual ArrayString | getAltNames () const |
Returns the alternative name(s) of the checksum or the hash algorithm. More... | |
virtual ChecksumAlgoId | getID () const =0 |
Returns an unique identifier for the checksum or the hash algorithm. More... | |
Protected Member Functions | |
void | finish () |
Process the remaining bytes in the internal buffer and the usual prolog according to the standard. More... | |
Protected Attributes | |
uint64_t | saved |
The portion of the input message that we didn't consume yet. More... | |
uint64_t | state [SHA3_KECCAK_SPONGE_WORDS] |
Keccak's state in 'words'. More... | |
unsigned | byteIndex |
0..7–the next byte after the set one (starts from 0; 0–none are buffered). More... | |
unsigned | wordIndex |
0..24–the next word to integrate input (starts from 0). More... | |
const unsigned | capacityWords |
The double size of the hash output in words (e.g. 16 for Keccak 512). More... | |
const bool | useSHA3Hash |
true if result is SHA3 hash, false if "original" Keccak hash. More... | |
Static Protected Attributes | |
static constexpr unsigned | SHA3_KECCAK_SPONGE_WORDS = (1600 / 8) / sizeof(uint64_t) |
'Words' here refers to uint64_t More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from libxcks::Checksum | |
static ArrayString | getAlternativeNames () |
Returns the alternative name(s) of the checksum or the hash algorithm. More... | |
Static Protected Member Functions inherited from libxcks::ChecksumEx | |
static uint32_t | swapOnLE (const uint32_t value) |
Swaps bytes on little endian architectures. More... | |
static uint32_t | swapOnBE (const uint32_t value) |
Swaps bytes on big endian architectures. More... | |
static uint64_t | swapOnLE (const uint64_t value) |
Swaps bytes on little endian architectures. More... | |
static uint64_t | swapOnBE (const uint64_t value) |
Swaps bytes on big endian architectures. More... | |
Computes the Keccak hash from a byte stream.
This class is a rewrite in C++ of the Keccak hash computing algorithm present in the SHA3IUF's GitHub repository.
This abstract class implements the Keccak and SHA3 hashes computing.
Definition at line 43 of file keccak.hpp.
|
delete |
Disable default constructor.
libxcks::AbstractKeccakImpl::AbstractKeccakImpl | ( | const unsigned | size, |
const bool | isSHA3Hash = true |
||
) |
Constructs a new Keccak or SHA3 implementation with a hash of size
bytes.
Default constructor.
[in] | size | The size of the hash in bytes. |
[in] | isSHA3Hash | true if result is SHA3 hash, false if "original" Keccak hash. |
Definition at line 45 of file keccak.cpp.
|
protected |
Process the remaining bytes in the internal buffer and the usual prolog according to the standard.
Definition at line 220 of file keccak.cpp.
|
finaloverridevirtual |
Resets the Keccak hash to initial value.
Implements libxcks::ChecksumEx.
Definition at line 56 of file keccak.cpp.
|
finaloverridevirtual |
Updates the Keccak hash with specified array of bytes.
buf | The byte array to update the Keccak hash with. |
len | The number of bytes to use for the update. |
Implements libxcks::Checksum.
Definition at line 69 of file keccak.cpp.
|
protected |
0..7–the next byte after the set one (starts from 0; 0–none are buffered).
Definition at line 51 of file keccak.hpp.
|
protected |
The double size of the hash output in words (e.g. 16 for Keccak 512).
Definition at line 53 of file keccak.hpp.
|
protected |
The portion of the input message that we didn't consume yet.
Definition at line 49 of file keccak.hpp.
|
staticconstexprprotected |
'Words' here refers to uint64_t
Definition at line 47 of file keccak.hpp.
|
protected |
Keccak's state in 'words'.
Definition at line 50 of file keccak.hpp.
|
protected |
true
if result is SHA3 hash, false
if "original" Keccak hash.
Definition at line 54 of file keccak.hpp.
|
protected |
0..24–the next word to integrate input (starts from 0).
Definition at line 52 of file keccak.hpp.