libxcks  0.1.0.1
libxcks::Tiger Class Referencefinal

Computes the Tiger hash from a byte stream. More...

#include <tiger.hpp>

Inheritance diagram for libxcks::Tiger:
Collaboration diagram for libxcks::Tiger:

Public Member Functions

 Tiger ()
 Default constructor. More...
 
void reset () override
 Resets the Tiger hash to initial state of computation. More...
 
uint8_t * getValue (uint8_t *buffer) const override
 Returns the Tiger hash value in the first 24 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 Tiger 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 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...
 

Protected Member Functions

void finish ()
 Process the remaining bytes in the internal buffer and the usual prolog according to the standard. More...
 
void transform (uint8_t *data)
 Transform the message X which consists of 8 64-bit-words. More...
 
void round (uint64_t &a, uint64_t &b, uint64_t &c, uint64_t x, int mul)
 Helper function for Tiger's computing. More...
 
void pass (uint64_t &a, uint64_t &b, uint64_t &c, uint64_t *x, int mul)
 Helper function for Tiger's computing. More...
 
void key_schedule (uint64_t *x)
 Helper function for Tiger's computing. More...
 

Protected Attributes

uint64_t a
 First part of the state of computation. More...
 
uint64_t b
 Second part of the state of computation. More...
 
uint64_t c
 Third part of the state of computation. More...
 
uint32_t nblocks
 Number of blocks. More...
 
int count
 Current size of the input buffer. More...
 
uint8_t ibuffer [64]
 Input buffer. More...
 

Static Protected Attributes

static const uint64_t sbox1 [256]
 Table used to compute the Tiger hash. More...
 
static const uint64_t sbox2 [256]
 Table used to compute the Tiger hash. More...
 
static const uint64_t sbox3 [256]
 Table used to compute the Tiger hash. More...
 
static const uint64_t sbox4 [256]
 Table used to compute the Tiger hash. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from libxcks::LibgcryptHash
static uint32_t rol (uint32_t x, int n)
 Rotate the 32 bit unsigned integer x by n bits left. More...
 
static uint32_t ror (uint32_t x, int n)
 Rotate the 32 bit unsigned integer x by n bits right. 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...
 

Detailed Description

Computes the Tiger hash from a byte stream.

This class is a rewrite in C++ of the Tiger hash computing algorithm present in the Libgcrypt. Please see the GNU Privacy Guard project website 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 Tiger hash value can be gotten by two ways:

  • The getValue method which puts the Tiger hash value in an array of 24 bytes.
  • The toString method which returns the Tiger hash value in a string.

The Tiger hash computing can be reseted by the reset method.

Definition at line 56 of file tiger.hpp.

Constructor & Destructor Documentation

◆ Tiger()

libxcks::Tiger::Tiger ( )

Default constructor.

Definition at line 579 of file tiger.cpp.

Member Function Documentation

◆ finish()

void libxcks::Tiger::finish ( )
protected

Process the remaining bytes in the internal buffer and the usual prolog according to the standard.

Definition at line 604 of file tiger.cpp.

◆ getHashName()

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

Returns the name of the hash algorithm.

Returns
The name of the hash algorithm.

Definition at line 194 of file tiger.hpp.

◆ getID()

ChecksumAlgoId libxcks::Tiger::getID ( ) const
inlineoverridevirtual

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 184 of file tiger.hpp.

◆ getIdentifier()

static constexpr ChecksumAlgoId libxcks::Tiger::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 208 of file tiger.hpp.

◆ getName()

std::string libxcks::Tiger::getName ( ) const
inlineoverridevirtual

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 170 of file tiger.hpp.

◆ getNewInstance()

static Checksum* libxcks::Tiger::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 221 of file tiger.hpp.

◆ getSize()

size_t libxcks::Tiger::getSize ( ) const
inlineoverridevirtual

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 102 of file tiger.hpp.

◆ getValue()

uint8_t * libxcks::Tiger::getValue ( uint8_t *  buffer) const
overridevirtual

Returns the Tiger hash value in the first 24 bytes of the given address.

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

Implements libxcks::Checksum.

Definition at line 824 of file tiger.cpp.

◆ key_schedule()

void libxcks::Tiger::key_schedule ( uint64_t *  x)
protected

Helper function for Tiger's computing.

I don't really want to know what it does. :o)

Parameters
xA parameter.

Definition at line 799 of file tiger.cpp.

◆ pass()

void libxcks::Tiger::pass ( uint64_t &  a,
uint64_t &  b,
uint64_t &  c,
uint64_t *  x,
int  mul 
)
protected

Helper function for Tiger's computing.

I don't really want to know what it does. :o)

Parameters
aA parameter.
bAnother parameter.
cAnother parameter.
xAnother parameter.
mulAnother parameter.

Definition at line 782 of file tiger.cpp.

◆ reset()

void libxcks::Tiger::reset ( )
overridevirtual

Resets the Tiger hash to initial state of computation.

Implements libxcks::LibgcryptHash.

Definition at line 589 of file tiger.cpp.

◆ round()

void libxcks::Tiger::round ( uint64_t &  a,
uint64_t &  b,
uint64_t &  c,
uint64_t  x,
int  mul 
)
protected

Helper function for Tiger's computing.

I don't really want to know what it does. :o)

Parameters
aA parameter.
bAnother parameter.
cAnother parameter.
xAnother parameter.
mulAnother parameter.

Definition at line 763 of file tiger.cpp.

◆ transform()

void libxcks::Tiger::transform ( uint8_t *  data)
protected

Transform the message X which consists of 8 64-bit-words.

It is assumed that data has the lenght of 8 64-bit-words.

Parameters
dataThe data to process.

Definition at line 712 of file tiger.cpp.

◆ update()

void libxcks::Tiger::update ( const uint8_t *  buf,
size_t  len 
)
overridevirtual

Updates the Tiger hash with specified array of bytes.

Parameters
bufThe byte array to update the Tiger hash with.
lenThe number of bytes to use for the update.

Implements libxcks::Checksum.

Definition at line 671 of file tiger.cpp.

Member Data Documentation

◆ a

uint64_t libxcks::Tiger::a
protected

First part of the state of computation.

Definition at line 60 of file tiger.hpp.

◆ b

uint64_t libxcks::Tiger::b
protected

Second part of the state of computation.

Definition at line 61 of file tiger.hpp.

◆ c

uint64_t libxcks::Tiger::c
protected

Third part of the state of computation.

Definition at line 62 of file tiger.hpp.

◆ count

int libxcks::Tiger::count
protected

Current size of the input buffer.

Definition at line 65 of file tiger.hpp.

◆ ibuffer

uint8_t libxcks::Tiger::ibuffer[64]
protected

Input buffer.

Definition at line 66 of file tiger.hpp.

◆ nblocks

uint32_t libxcks::Tiger::nblocks
protected

Number of blocks.

Definition at line 64 of file tiger.hpp.

◆ sbox1

const uint64_t libxcks::Tiger::sbox1
staticprotected

Table used to compute the Tiger hash.

Definition at line 69 of file tiger.hpp.

◆ sbox2

const uint64_t libxcks::Tiger::sbox2
staticprotected

Table used to compute the Tiger hash.

Definition at line 70 of file tiger.hpp.

◆ sbox3

const uint64_t libxcks::Tiger::sbox3
staticprotected

Table used to compute the Tiger hash.

Definition at line 71 of file tiger.hpp.

◆ sbox4

const uint64_t libxcks::Tiger::sbox4
staticprotected

Table used to compute the Tiger hash.

Definition at line 72 of file tiger.hpp.


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