6#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_HOST)
14#include <esp_idf_version.h>
15#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
20#include <psa/crypto.h>
22#define USE_SHA256_MBEDTLS
23#include "mbedtls/sha256.h"
25#elif defined(USE_LIBRETINY)
26#define USE_SHA256_MBEDTLS
27#include "mbedtls/sha256.h"
28#elif defined(USE_ESP8266) || defined(USE_RP2040)
29#include <bearssl/bearssl_hash.h>
30#elif defined(USE_HOST)
31#include <openssl/evp.h>
33#error "SHA256 not supported on this platform"
57 void add(
const uint8_t *data,
size_t len)
override;
59 void add(
const std::string &data) { this->
add((
const uint8_t *) data.c_str(), data.length()); }
64 size_t get_size()
const override {
return 32; }
67#if defined(USE_SHA256_PSA)
68 psa_hash_operation_t
op_ = PSA_HASH_OPERATION_INIT;
69#elif defined(USE_SHA256_MBEDTLS)
72 mbedtls_sha256_context
ctx_{};
73#elif defined(USE_ESP8266) || defined(USE_RP2040)
76#elif defined(USE_HOST)
80#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.
SHA256 hash implementation.
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_