3#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_HOST)
10#if defined(USE_ESP32) || defined(USE_LIBRETINY)
15 mbedtls_md_init(&this->
ctx_);
16 const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256);
17 mbedtls_md_setup(&this->
ctx_, md_info, 1);
18 mbedtls_md_hmac_starts(&this->
ctx_, key,
len);
52 memset(ipad, 0,
sizeof(ipad));
60 memcpy(ipad, key,
len);
62 memcpy(opad, ipad,
sizeof(opad));
void get_hex(char *output)
Retrieve the hash as hex characters. Output buffer must hold get_size() * 2 + 1 bytes.
bool equals_hex(const char *expected)
Compare the hash against a provided hex-encoded hash.
bool equals_bytes(const uint8_t *expected)
Compare the hash against a provided byte-encoded hash.
void get_bytes(uint8_t *output)
Retrieve the hash as bytes.
bool equals_bytes(const uint8_t *expected)
Compare the digest against a provided byte-encoded digest (32 bytes).
mbedtls_md_context_t ctx_
uint8_t digest_[SHA256_DIGEST_SIZE]
static constexpr size_t SHA256_DIGEST_SIZE
bool equals_hex(const char *expected)
Compare the digest against a provided hex-encoded digest (64 bytes).
void add(const uint8_t *data, size_t len)
Add bytes of data for the digest.
void get_hex(char *output)
Retrieve the HMAC-SHA256 digest as hex characters.
void get_bytes(uint8_t *output)
Retrieve the HMAC-SHA256 digest as bytes.
void calculate()
Compute the digest, based on the provided data.
void init(const uint8_t *key, size_t len)
Initialize a new HMAC-SHA256 digest computation.
SHA256 hash implementation.
void calculate() override
void add(const uint8_t *data, size_t len) override
constexpr size_t SHA256_DIGEST_SIZE
constexpr size_t HMAC_BLOCK_SIZE
char * format_hex_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length)
Format byte array as lowercase hex to buffer (base implementation).