6#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_HOST)
13#if defined(USE_ESP32) || defined(USE_LIBRETINY)
14#include "mbedtls/sha256.h"
15#elif defined(USE_ESP8266) || defined(USE_RP2040)
16#include <bearssl/bearssl_hash.h>
17#elif defined(USE_HOST)
18#include <openssl/evp.h>
20#error "SHA256 not supported on this platform"
31 void add(
const uint8_t *data,
size_t len)
override;
33 void add(
const std::string &data) { this->
add((
const uint8_t *) data.c_str(), data.length()); }
38 size_t get_size()
const override {
return 32; }
41#if defined(USE_ESP32) || defined(USE_LIBRETINY)
42 mbedtls_sha256_context
ctx_{};
43#elif defined(USE_ESP8266) || defined(USE_RP2040)
46#elif defined(USE_HOST)
50#error "SHA256 not supported on this platform"
Base class for hash algorithms.
virtual void add(const uint8_t *data, size_t len)=0
Add bytes of data for the hash.
void calculate() override
size_t get_size() const override
Get the size of the hash in bytes (32 for SHA256)
void add(const uint8_t *data, size_t len) override
void add(const std::string &data)
mbedtls_sha256_context ctx_