libxcks  0.1.0.1
libxcks::SHA3_512 Class Referencefinal

Computes the SHA3-512 hash from a byte stream. More...

#include <keccak.hpp>

Inheritance diagram for libxcks::SHA3_512:
Collaboration diagram for libxcks::SHA3_512:

Public Member Functions

 SHA3_512 ()
 Default constructor. More...
 
uint8_t * getValue (uint8_t *buffer) const override final
 Returns the SHA3-512 hash value in the first 64 bytes of the given address. More...
 
size_t getSize () const override final
 Returns the minimal size to allocate in memory to store the hash with the getValue(buffer) method. More...
 
std::string getName () const override final
 Returns the name of the checksum or the hash algorithm. More...
 
ArrayString getAltNames () const override final
 Returns the alternative names of the SHA3-512 hash algorithm. More...
 
ChecksumAlgoId getID () const override final
 Returns an unique identifier for the checksum or the hash algorithm. More...
 
- Public Member Functions inherited from libxcks::AbstractKeccakImpl
 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...
 

Static Public Member Functions

static std::string getHashName ()
 Returns the name of the hash algorithm. More...
 
static ArrayString getAlternativeNames ()
 Returns the alternative names of the SHA3-512 hash algorithm. More...
 
static constexpr ChecksumAlgoId getIdentifier ()
 Returns an unique identifier for the hash algorithm. More...
 
static ChecksumgetNewInstance ()
 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...
 

Additional Inherited Members

- Protected Member Functions inherited from libxcks::AbstractKeccakImpl
void finish ()
 Process the remaining bytes in the internal buffer and the usual prolog according to the standard. 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...
 
- Protected Attributes inherited from libxcks::AbstractKeccakImpl
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 inherited from libxcks::AbstractKeccakImpl
static constexpr unsigned SHA3_KECCAK_SPONGE_WORDS = (1600 / 8) / sizeof(uint64_t)
 'Words' here refers to uint64_t More...
 

Detailed Description

Computes the SHA3-512 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.

Using this class in very simple:
Use the update method to provide to the class the bytes for computing the hash.

The SHA3-512 hash value can be gotten by two ways:

  • The getValue method which puts the SHA3-512 hash value in an array of 64 bytes.
  • The toString method which returns the SHA3-512 hash value in a string.

The SHA3-512 hash computing can be reseted by the reset method.

Definition at line 521 of file keccak.hpp.

Constructor & Destructor Documentation

◆ SHA3_512()

libxcks::SHA3_512::SHA3_512 ( )
inline

Default constructor.

Definition at line 527 of file keccak.hpp.

Member Function Documentation

◆ getAlternativeNames()

ArrayString libxcks::SHA3_512::getAlternativeNames ( )
static

Returns the alternative names of the SHA3-512 hash algorithm.

Returns
The alternative names of the SHA3-512 hash algorithm.

Definition at line 365 of file keccak.cpp.

◆ getAltNames()

ArrayString libxcks::SHA3_512::getAltNames ( ) const
inlinefinaloverridevirtual

Returns the alternative names of the SHA3-512 hash algorithm.

Returns
The alternative names of the SHA3-512 hash algorithm.

Reimplemented from libxcks::Checksum.

Definition at line 563 of file keccak.hpp.

◆ getHashName()

static std::string libxcks::SHA3_512::getHashName ( )
inlinestatic

Returns the name of the hash algorithm.

Returns
The name of the hash algorithm.

Definition at line 587 of file keccak.hpp.

◆ getID()

ChecksumAlgoId libxcks::SHA3_512::getID ( ) const
inlinefinaloverridevirtual

Returns an unique identifier for the checksum or the hash algorithm.

Remarks
The unique ID should be the CRC32 checksum of the algorithm's name returned by getName() but it's only a convention.
Returns
An unique identifier for the checksum or the hash algorithm.

Implements libxcks::Checksum.

Definition at line 577 of file keccak.hpp.

◆ getIdentifier()

static constexpr ChecksumAlgoId libxcks::SHA3_512::getIdentifier ( )
inlinestaticconstexpr

Returns an unique identifier for the hash algorithm.

Remarks
The unique ID should be the CRC32 checksum of the algorithm's name returned by getHashName() but it's only a convention.
Returns
An unique identifier for the hash algorithm.

Definition at line 608 of file keccak.hpp.

◆ getName()

std::string libxcks::SHA3_512::getName ( ) const
inlinefinaloverridevirtual

Returns the name of the checksum or the hash algorithm.

Returns
The name of the checksum or the hash algorithm.

Implements libxcks::Checksum.

Definition at line 553 of file keccak.hpp.

◆ getNewInstance()

static Checksum* libxcks::SHA3_512::getNewInstance ( )
inlinestatic

Gets a new instance of this class.

The caller is responsible of the deletion of the instance with the delete operator.

Returns
A new instance of this class.

Definition at line 621 of file keccak.hpp.

◆ getSize()

size_t libxcks::SHA3_512::getSize ( ) const
inlinefinaloverridevirtual

Returns the minimal size to allocate in memory to store the hash with the getValue(buffer) method.

Returns
The minimal size to allocate in memory to store the hash with the getValue(buffer) method.

Implements libxcks::Checksum.

Definition at line 546 of file keccak.hpp.

◆ getValue()

uint8_t * libxcks::SHA3_512::getValue ( uint8_t *  buffer) const
finaloverridevirtual

Returns the SHA3-512 hash value in the first 64 bytes of the given address.

Parameters
bufferThe buffer where the SHA3-512 hash value will be stored.
Returns
The address of the buffer.
Remarks
The memory for the 64 bytes must have been allocated before calling this method.

Implements libxcks::Checksum.

Definition at line 350 of file keccak.cpp.


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