TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
ts::Hash Class Referenceabstract

Abstract interface of hash functions. More...

Inheritance diagram for ts::Hash:

Public Member Functions

virtual ~Hash ()
 Virtual destructor.
 
virtual bool add (const void *data, size_t size)=0
 Add some part of the message to hash. More...
 
virtual size_t blockSize () const =0
 Size in bytes of the block used by the algorithm. More...
 
virtual bool getHash (void *hash, size_t bufsize, size_t *retsize=nullptr)=0
 Get the resulting hash value. More...
 
bool hash (const void *data, size_t data_size, void *hash, size_t hash_maxsize, size_t *hash_retsize=nullptr)
 Compute a hash in one operation. More...
 
virtual size_t hashSize () const =0
 Size in bytes of the resulting hash. More...
 
virtual bool init ()=0
 Reinitialize the computation of the hash. More...
 
virtual UString name () const =0
 Algorithm name (informational only). More...
 

Detailed Description

Abstract interface of hash functions.

Member Function Documentation

◆ name()

virtual UString ts::Hash::name ( ) const
pure virtual

Algorithm name (informational only).

Returns
The algorithm name.

Implemented in ts::SHA256, ts::MD5, ts::SHA1, and ts::SHA512.

◆ hashSize()

virtual size_t ts::Hash::hashSize ( ) const
pure virtual

Size in bytes of the resulting hash.

Returns
The size in bytes of the resulting hash.

Implemented in ts::SHA256, ts::MD5, ts::SHA1, and ts::SHA512.

◆ blockSize()

virtual size_t ts::Hash::blockSize ( ) const
pure virtual

Size in bytes of the block used by the algorithm.

Returns
The size in bytes of the block used by the algorithm. Informational only. Can be zero if non significant.

Implemented in ts::SHA256, ts::MD5, ts::SHA1, and ts::SHA512.

◆ init()

virtual bool ts::Hash::init ( )
pure virtual

Reinitialize the computation of the hash.

Returns
True on success, false on error.

Implemented in ts::SHA256, ts::MD5, ts::SHA1, and ts::SHA512.

◆ add()

virtual bool ts::Hash::add ( const void *  data,
size_t  size 
)
pure virtual

Add some part of the message to hash.

Can be called several times.

Parameters
[in]dataAddress of message part.
[in]sizeSize in bytes of message part.
Returns
True on success, false on error.

Implemented in ts::SHA256, ts::MD5, ts::SHA1, and ts::SHA512.

◆ getHash()

virtual bool ts::Hash::getHash ( void *  hash,
size_t  bufsize,
size_t *  retsize = nullptr 
)
pure virtual

Get the resulting hash value.

Parameters
[out]hashAddress of returned hash buffer.
[in]bufsizeSize in bytes of hash buffer.
[out]retsizeAddress of an integer receiving the actual returned hash size. Can be a null pointer (ignored).
Returns
True on success, false on error.

Implemented in ts::SHA256, ts::MD5, ts::SHA1, and ts::SHA512.

◆ hash()

bool ts::Hash::hash ( const void *  data,
size_t  data_size,
void *  hash,
size_t  hash_maxsize,
size_t *  hash_retsize = nullptr 
)
inline

Compute a hash in one operation.

Same in init() + add() + getHash().

Parameters
[in]dataAddress of message to hash.
[in]data_sizeSize in bytes of message to hash.
[out]hashAddress of returned hash buffer.
[in]hash_maxsizeSize in bytes of hash buffer.
[out]hash_retsizeAddress of an integer receiving the actual returned hash size. Can be a null pointer (ignored).
Returns
True on success, false on error.

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