TSDuck Version 3.15-955 (TSDuck - The MPEG Transport Stream Toolkit)
ts::SHA256 Class Reference

SHA-256 hash. More...

Inheritance diagram for ts::SHA256:
Collaboration diagram for ts::SHA256:

Public Member Functions

 SHA256 ()
 Constructor.
 
virtual bool add (const void *data, size_t size) override
 Add some part of the message to hash. More...
 
virtual size_t blockSize () const override
 Size in bytes of the block used by the algorithm. More...
 
virtual bool getHash (void *hash, size_t bufsize, size_t *retsize=0) override
 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=0)
 Compute a hash in one operation. More...
 
virtual size_t hashSize () const override
 Size in bytes of the resulting hash. More...
 
virtual bool init () override
 Reinitialize the computation of the hash. More...
 
virtual UString name () const override
 Algorithm name (informational only). More...
 

Static Public Attributes

static const size_t BLOCK_SIZE = 64
 SHA-256 block size in bytes.
 
static const size_t HASH_SIZE = 32
 SHA-256 hash size in bytes.
 

Detailed Description

SHA-256 hash.

Member Function Documentation

◆ name()

virtual UString ts::SHA256::name ( ) const
inlineoverridevirtual

Algorithm name (informational only).

Returns
The algorithm name.

Implements ts::Hash.

◆ hashSize()

virtual size_t ts::SHA256::hashSize ( ) const
inlineoverridevirtual

Size in bytes of the resulting hash.

Returns
The size in bytes of the resulting hash.

Implements ts::Hash.

◆ blockSize()

virtual size_t ts::SHA256::blockSize ( ) const
inlineoverridevirtual

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.

Implements ts::Hash.

◆ init()

virtual bool ts::SHA256::init ( )
overridevirtual

Reinitialize the computation of the hash.

Returns
True on success, false on error.

Implements ts::Hash.

◆ add()

virtual bool ts::SHA256::add ( const void *  data,
size_t  size 
)
overridevirtual

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.

Implements ts::Hash.

◆ getHash()

virtual bool ts::SHA256::getHash ( void *  hash,
size_t  bufsize,
size_t *  retsize = 0 
)
overridevirtual

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.

Implements ts::Hash.

◆ hash()

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

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: