libxcks
0.1.0.1
|
Computes the Whirlpool hash from a byte stream. More...
#include <whirlpool.hpp>
Public Member Functions | |
Whirlpool () | |
Default constructor. More... | |
void | reset () override |
Resets the Whirlpool hash to initial state of computation. More... | |
uint8_t * | getValue (uint8_t *buffer) const override |
Returns the Whirlpool hash value in the first 64 bytes of the given address. More... | |
size_t | getSize () const override |
Returns the minimal size to allocate in memory to store the hash with the getValue(buffer) method. More... | |
void | update (const uint8_t *buf, size_t len) override |
Updates the Whirlpool hash with specified array of bytes. More... | |
std::string | getName () const override |
Returns the name of the checksum or the hash algorithm. More... | |
ChecksumAlgoId | getID () const override |
Returns an unique identifier for the checksum or the hash algorithm. 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 ArrayString | getAltNames () const |
Returns the alternative name(s) of the checksum or the hash algorithm. More... | |
Static Public Member Functions | |
static std::string | getHashName () |
Returns the name of the hash algorithm. More... | |
static constexpr ChecksumAlgoId | getIdentifier () |
Returns an unique identifier for the hash algorithm. More... | |
static Checksum * | getNewInstance () |
Gets a new instance of this class. More... | |
Static Public Member Functions inherited from libxcks::Checksum | |
static ArrayString | getAlternativeNames () |
Returns the alternative name(s) of the checksum or the hash algorithm. More... | |
Protected Member Functions | |
void | finish (uint8_t *const result) |
Process the remaining bytes in the internal buffer and the usual prolog according to the standard. More... | |
void | process_buffer () |
The core Whirlpool transform. More... | |
Protected Attributes | |
uint8_t | bitLength [WHIRLPOOL_LENGTHBYTES] |
Global number of hashed bits (256-bit counter). More... | |
uint8_t | buffer [WHIRLPOOL_WBLOCKBYTES] |
Buffer of data to hash. More... | |
int | bufferBits |
Current number of bits on the buffer. More... | |
int | bufferPos |
Current (possibly incomplete) byte slot on the buffer. More... | |
uint64_t | hash [WHIRLPOOL_DIGESTQUADWORDS] |
The hashing state. More... | |
Static Protected Attributes | |
static const uint64_t | C0 [] |
Table used to compute the Whirlpool hash. More... | |
static const uint64_t | C1 [] |
Table used to compute the Whirlpool hash. More... | |
static const uint64_t | C2 [] |
Table used to compute the Whirlpool hash. More... | |
static const uint64_t | C3 [] |
Table used to compute the Whirlpool hash. More... | |
static const uint64_t | C4 [] |
Table used to compute the Whirlpool hash. More... | |
static const uint64_t | C5 [] |
Table used to compute the Whirlpool hash. More... | |
static const uint64_t | C6 [] |
Table used to compute the Whirlpool hash. More... | |
static const uint64_t | C7 [] |
Table used to compute the Whirlpool hash. More... | |
static const unsigned int | R = 10u |
The number of rounds of the internal dedicated block cipher. More... | |
static const uint64_t | rc [] |
Table used to compute the Whirlpool hash. More... | |
Additional Inherited Members | |
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 Whirlpool hash from a byte stream.
This class is a rewrite in C++ of the Whirlpool hash computing algorithm of the original C version written by Paulo S. L. M. Barreto and Vincent Rijmen. Please see the The WHIRLPOOL Hash Function web page for more informations.
Using this class in very simple:
Use the update method to provide to the class the bytes for computing the hash.
The Whirlpool hash value can be gotten by two ways:
The Whirlpool hash computing can be reseted by the reset method.
Definition at line 57 of file whirlpool.hpp.
libxcks::Whirlpool::Whirlpool | ( | ) |
Default constructor.
Definition at line 600 of file whirlpool.cpp.
|
protected |
Process the remaining bytes in the internal buffer and the usual prolog according to the standard.
result | A buffer of 64 byte that will contain the final hash. |
Definition at line 628 of file whirlpool.cpp.
|
inlinestatic |
Returns the name of the hash algorithm.
Definition at line 174 of file whirlpool.hpp.
|
inlineoverridevirtual |
Returns an unique identifier for the checksum or the hash algorithm.
Implements libxcks::Checksum.
Definition at line 164 of file whirlpool.hpp.
|
inlinestaticconstexpr |
Returns an unique identifier for the hash algorithm.
Definition at line 188 of file whirlpool.hpp.
|
inlineoverridevirtual |
Returns the name of the checksum or the hash algorithm.
Implements libxcks::Checksum.
Definition at line 150 of file whirlpool.hpp.
|
inlinestatic |
Gets a new instance of this class.
The caller is responsible of the deletion of the instance with the delete
operator.
Definition at line 201 of file whirlpool.hpp.
|
inlineoverridevirtual |
Returns the minimal size to allocate in memory to store the hash with the getValue(buffer) method.
Implements libxcks::Checksum.
Definition at line 120 of file whirlpool.hpp.
|
overridevirtual |
Returns the Whirlpool hash value in the first 64 bytes of the given address.
buffer | The buffer where the Whirlpool hash value will be stored. |
buffer
is correctly aligned for a 32 bits value. Implements libxcks::Checksum.
Definition at line 1020 of file whirlpool.cpp.
|
protected |
The core Whirlpool transform.
Definition at line 796 of file whirlpool.cpp.
|
overridevirtual |
Resets the Whirlpool hash to initial state of computation.
Implements libxcks::ChecksumEx.
Definition at line 610 of file whirlpool.cpp.
|
overridevirtual |
Updates the Whirlpool hash with specified array of bytes.
buf | The byte array to update the Whirlpool hash with. |
len | The number of bytes to use for the update. |
Implements libxcks::Checksum.
Definition at line 687 of file whirlpool.cpp.
|
protected |
Global number of hashed bits (256-bit counter).
Definition at line 70 of file whirlpool.hpp.
|
protected |
Buffer of data to hash.
Definition at line 71 of file whirlpool.hpp.
|
protected |
Current number of bits on the buffer.
Definition at line 72 of file whirlpool.hpp.
|
protected |
Current (possibly incomplete) byte slot on the buffer.
Definition at line 73 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 77 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 78 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 79 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 80 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 81 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 82 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 83 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 84 of file whirlpool.hpp.
|
protected |
The hashing state.
Definition at line 74 of file whirlpool.hpp.
|
staticprotected |
The number of rounds of the internal dedicated block cipher.
Definition at line 87 of file whirlpool.hpp.
|
staticprotected |
Table used to compute the Whirlpool hash.
Definition at line 88 of file whirlpool.hpp.