ESPHome 2026.1.0-dev
Loading...
Searching...
No Matches
esphome::hmac_sha256::HmacSHA256 Class Reference

#include <hmac_sha256.h>

Public Member Functions

 HmacSHA256 ()=default
 
 ~HmacSHA256 ()
 
void init (const uint8_t *key, size_t len)
 Initialize a new HMAC-SHA256 digest computation.
 
void init (const char *key, size_t len)
 
void init (const std::string &key)
 
void add (const uint8_t *data, size_t len)
 Add bytes of data for the digest.
 
void add (const char *data, size_t len)
 
void calculate ()
 Compute the digest, based on the provided data.
 
void get_bytes (uint8_t *output)
 Retrieve the HMAC-SHA256 digest as bytes.
 
void get_hex (char *output)
 Retrieve the HMAC-SHA256 digest as hex characters.
 
bool equals_bytes (const uint8_t *expected)
 Compare the digest against a provided byte-encoded digest (32 bytes).
 
bool equals_hex (const char *expected)
 Compare the digest against a provided hex-encoded digest (64 bytes).
 

Protected Attributes

mbedtls_md_context_t ctx_ {}
 
uint8_t digest_ [SHA256_DIGEST_SIZE] {}
 
sha256::SHA256 ihash_
 
sha256::SHA256 ohash_
 

Static Protected Attributes

static constexpr size_t SHA256_DIGEST_SIZE = 32
 

Detailed Description

Definition at line 16 of file hmac_sha256.h.

Constructor & Destructor Documentation

◆ HmacSHA256()

esphome::hmac_sha256::HmacSHA256::HmacSHA256 ( )
default

◆ ~HmacSHA256()

esphome::hmac_sha256::HmacSHA256::~HmacSHA256 ( )
default

Definition at line 13 of file hmac_sha256.cpp.

Member Function Documentation

◆ add() [1/2]

void esphome::hmac_sha256::HmacSHA256::add ( const char * data,
size_t len )
inline

Definition at line 28 of file hmac_sha256.h.

◆ add() [2/2]

void esphome::hmac_sha256::HmacSHA256::add ( const uint8_t * data,
size_t len )

Add bytes of data for the digest.

Definition at line 22 of file hmac_sha256.cpp.

◆ calculate()

void esphome::hmac_sha256::HmacSHA256::calculate ( )

Compute the digest, based on the provided data.

Definition at line 24 of file hmac_sha256.cpp.

◆ equals_bytes()

bool esphome::hmac_sha256::HmacSHA256::equals_bytes ( const uint8_t * expected)

Compare the digest against a provided byte-encoded digest (32 bytes).

Definition at line 34 of file hmac_sha256.cpp.

◆ equals_hex()

bool esphome::hmac_sha256::HmacSHA256::equals_hex ( const char * expected)

Compare the digest against a provided hex-encoded digest (64 bytes).

Definition at line 38 of file hmac_sha256.cpp.

◆ get_bytes()

void esphome::hmac_sha256::HmacSHA256::get_bytes ( uint8_t * output)

Retrieve the HMAC-SHA256 digest as bytes.

The output must be able to hold 32 bytes or more.

Definition at line 26 of file hmac_sha256.cpp.

◆ get_hex()

void esphome::hmac_sha256::HmacSHA256::get_hex ( char * output)

Retrieve the HMAC-SHA256 digest as hex characters.

The output must be able to hold 64 bytes or more.

Definition at line 28 of file hmac_sha256.cpp.

◆ init() [1/3]

void esphome::hmac_sha256::HmacSHA256::init ( const char * key,
size_t len )
inline

Definition at line 23 of file hmac_sha256.h.

◆ init() [2/3]

void esphome::hmac_sha256::HmacSHA256::init ( const std::string & key)
inline

Definition at line 24 of file hmac_sha256.h.

◆ init() [3/3]

void esphome::hmac_sha256::HmacSHA256::init ( const uint8_t * key,
size_t len )

Initialize a new HMAC-SHA256 digest computation.

Definition at line 15 of file hmac_sha256.cpp.

Field Documentation

◆ ctx_

mbedtls_md_context_t esphome::hmac_sha256::HmacSHA256::ctx_ {}
protected

Definition at line 50 of file hmac_sha256.h.

◆ digest_

uint8_t esphome::hmac_sha256::HmacSHA256::digest_[SHA256_DIGEST_SIZE] {}
protected

Definition at line 51 of file hmac_sha256.h.

◆ ihash_

sha256::SHA256 esphome::hmac_sha256::HmacSHA256::ihash_
protected

Definition at line 53 of file hmac_sha256.h.

◆ ohash_

sha256::SHA256 esphome::hmac_sha256::HmacSHA256::ohash_
protected

Definition at line 54 of file hmac_sha256.h.

◆ SHA256_DIGEST_SIZE

size_t esphome::hmac_sha256::HmacSHA256::SHA256_DIGEST_SIZE = 32
staticconstexprprotected

Definition at line 49 of file hmac_sha256.h.


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