ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
HashGenerator Class Reference

Wrapper class which allows generating a hash of a given type from any arbitrary byte payload, which is hashable in chunks. More...

#include <HashGenerator.h>

Classes

struct  HashString
 Wrapper class for the char array that is big enough to hold the string representation of every possible hash algorithm. More...
 

Public Member Functions

 HashGenerator (void)=default
 Constructor. More...
 
 HashGenerator (HashGenerator const &other)=delete
 Deleted copy constructor. More...
 
void operator= (HashGenerator const &other)=delete
 Deleted copy assignment operator. More...
 
 ~HashGenerator (void)
 Destructor. More...
 
bool start (mbedtls_md_type_t const &type)
 Starts the hashing process. More...
 
bool update (uint8_t const *data, size_t const &length)
 Update the current hash value with new data. More...
 
HashString finish ()
 Calculates the final hash string representation and stops the hash calculation no further calls to update() will work, instead the same context can be reused to start another hash calculation operation with start() More...
 

Detailed Description

Wrapper class which allows generating a hash of a given type from any arbitrary byte payload, which is hashable in chunks.

Note
The class wraps around either the Arduino Seeed mbedtls library from Seed Studio (https://github.com/Seeed-Studio/Seeed_Arduino_mbedtls) or the offical ESP Mbed TLS implementation from Mbed TLS (https://github.com/Mbed-TLS/mbedtls), the latter takes precendence if it exists. This is done because it removes the need to include another library, because the component already exists on the system and we can therefore simply utilize that one. The ESP Mbed TLS implementationt works with both Espressif IDF v4.X and v5.X, meaning it is version idependent, this is the case because depending on the used version the implementation automatically adjusts to still initalize correctly. The class instance is meant to be started with start() which will then create the configuration for a hash of the given type and we then expect the complete binary payload to be called in multiple calls to update() and the final result to be read with finish(). Documentation about the specific use and caviates of the ESP Mbedt TLS implementation can be found here https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/mbedtls.html

Constructor & Destructor Documentation

◆ HashGenerator() [1/2]

HashGenerator::HashGenerator ( void  )
default

Constructor.

◆ HashGenerator() [2/2]

HashGenerator::HashGenerator ( HashGenerator const &  other)
delete

Deleted copy constructor.

Note
Copying an active HashGenerator is not possible and there are no settings or configuration to copy. Therefore copying is disabled alltogether
Parameters
otherOther instance we disallow copying from

◆ ~HashGenerator()

HashGenerator::~HashGenerator ( void  )

Destructor.

Member Function Documentation

◆ finish()

HashGenerator::HashString HashGenerator::finish ( )

Calculates the final hash string representation and stops the hash calculation no further calls to update() will work, instead the same context can be reused to start another hash calculation operation with start()

Returns
Hash string representation of the previously entered hashed binary data, if the hashing process failed the hash string representation will be empty

◆ operator=()

void HashGenerator::operator= ( HashGenerator const &  other)
delete

Deleted copy assignment operator.

Note
Copying an active HashGenerator is not possible and there are no settings or configuration to copy. Therefore copying is disabled alltogether
Parameters
otherOther instance we disallow copying from

◆ start()

bool HashGenerator::start ( mbedtls_md_type_t const &  type)

Starts the hashing process.

Parameters
typeSupported type of hash that should be generated from the given binary data
Returns
Whether initalizing and starting the hash calculation was successful or not

◆ update()

bool HashGenerator::update ( uint8_t const *  data,
size_t const &  length 
)

Update the current hash value with new data.

Parameters
dataNon owning pointer to the data that should be added to generate the hash. Does not need to kept alive as the update function copies the data by writing it into the hash function storage
lengthLength of data entered
Returns
Whether updating the hash for the given bytes was successful or not

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