libxcks  0.1.0.1
libxcks::RIPEMD160 Class Referencefinal

Computes the RIPE-MD160 hash from a byte stream. More...

#include <rmd160.hpp>

Inheritance diagram for libxcks::RIPEMD160:
Collaboration diagram for libxcks::RIPEMD160:

Public Member Functions

 RIPEMD160 ()
 Default constructor. More...
 
void reset () override
 Resets the RIPE-MD160 hash to initial state of computation. More...
 
uint8_t * getValue (uint8_t *buffer) const override
 Returns the RIPE-MD160 hash value in the first 20 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 RIPE-MD160 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...
 
ArrayString getAltNames () const
 Returns the alternative names of the RIPE-MD160 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...
 

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 ArrayString getAlternativeNames ()
 Returns the alternative names of the RIPE-MD160 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 16 32-bit-words. More...
 

Protected Attributes

uint32_t h0
 First part of the state of computation. More...
 
uint32_t h1
 Second part of the state of computation. More...
 
uint32_t h2
 Third part of the state of computation. More...
 
uint32_t h3
 Fourth part of the state of computation. More...
 
uint32_t h4
 Fifth 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...
 

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 RIPE-MD160 hash from a byte stream.

This class is a rewrite in C++ of the RIPE-MD160 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 RIPE-MD160 hash value can be gotten by two ways:

  • The getValue method which puts the RIPE-MD160 hash value in an array of 20 bytes.
  • The toString method which returns the RIPE-MD160 hash value in a string.

The RIPE-MD160 hash computing can be reseted by the reset method.

Definition at line 56 of file rmd160.hpp.

Constructor & Destructor Documentation

◆ RIPEMD160()

libxcks::RIPEMD160::RIPEMD160 ( )

Default constructor.

Definition at line 112 of file rmd160.cpp.

Member Function Documentation

◆ finish()

void libxcks::RIPEMD160::finish ( )
protected

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

Definition at line 139 of file rmd160.cpp.

◆ getAlternativeNames()

ArrayString libxcks::RIPEMD160::getAlternativeNames ( )
static

Returns the alternative names of the RIPE-MD160 hash algorithm.

Returns
The alternative names of the RIPE-MD160 hash algorithm.

Definition at line 501 of file rmd160.cpp.

◆ getAltNames()

ArrayString libxcks::RIPEMD160::getAltNames ( ) const
inlinevirtual

Returns the alternative names of the RIPE-MD160 hash algorithm.

Returns
The alternative names of the RIPE-MD160 hash algorithm.

Reimplemented from libxcks::Checksum.

Definition at line 164 of file rmd160.hpp.

◆ getHashName()

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

Returns the name of the hash algorithm.

Returns
The name of the hash algorithm.

Definition at line 154 of file rmd160.hpp.

◆ getID()

ChecksumAlgoId libxcks::RIPEMD160::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 144 of file rmd160.hpp.

◆ getIdentifier()

static constexpr ChecksumAlgoId libxcks::RIPEMD160::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 178 of file rmd160.hpp.

◆ getName()

std::string libxcks::RIPEMD160::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 130 of file rmd160.hpp.

◆ getNewInstance()

static Checksum* libxcks::RIPEMD160::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 198 of file rmd160.hpp.

◆ getSize()

size_t libxcks::RIPEMD160::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 98 of file rmd160.hpp.

◆ getValue()

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

Returns the RIPE-MD160 hash value in the first 20 bytes of the given address.

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

Implements libxcks::Checksum.

Definition at line 486 of file rmd160.cpp.

◆ reset()

void libxcks::RIPEMD160::reset ( )
overridevirtual

Resets the RIPE-MD160 hash to initial state of computation.

Implements libxcks::LibgcryptHash.

Definition at line 122 of file rmd160.cpp.

◆ transform()

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

Transform the message X which consists of 16 32-bit-words.

It is assumed that data has the lenght of 16 32-bit-words.

Parameters
dataThe data to process.

Definition at line 247 of file rmd160.cpp.

◆ update()

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

Updates the RIPE-MD160 hash with specified array of bytes.

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

Implements libxcks::Checksum.

Definition at line 206 of file rmd160.cpp.

Member Data Documentation

◆ count

int libxcks::RIPEMD160::count
protected

Current size of the input buffer.

Definition at line 67 of file rmd160.hpp.

◆ h0

uint32_t libxcks::RIPEMD160::h0
protected

First part of the state of computation.

Definition at line 60 of file rmd160.hpp.

◆ h1

uint32_t libxcks::RIPEMD160::h1
protected

Second part of the state of computation.

Definition at line 61 of file rmd160.hpp.

◆ h2

uint32_t libxcks::RIPEMD160::h2
protected

Third part of the state of computation.

Definition at line 62 of file rmd160.hpp.

◆ h3

uint32_t libxcks::RIPEMD160::h3
protected

Fourth part of the state of computation.

Definition at line 63 of file rmd160.hpp.

◆ h4

uint32_t libxcks::RIPEMD160::h4
protected

Fifth part of the state of computation.

Definition at line 64 of file rmd160.hpp.

◆ ibuffer

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

Input buffer.

Definition at line 68 of file rmd160.hpp.

◆ nblocks

uint32_t libxcks::RIPEMD160::nblocks
protected

Number of blocks.

Definition at line 66 of file rmd160.hpp.


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