mirror of
https://github.com/esphome/esphome.git
synced 2025-09-22 13:12:22 +01:00
fix libretiny
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace esphome::sha256 {
|
||||
|
||||
#ifdef USE_ESP32
|
||||
#if defined(USE_ESP32) || defined(USE_LIBRETINY)
|
||||
|
||||
SHA256::~SHA256() {
|
||||
if (this->ctx_) {
|
||||
@@ -106,35 +106,6 @@ void SHA256::calculate() {
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(USE_ARDUINO)
|
||||
|
||||
SHA256::~SHA256() = default;
|
||||
|
||||
void SHA256::init() {
|
||||
if (!this->ctx_) {
|
||||
this->ctx_ = std::make_unique<SHA256Context>();
|
||||
}
|
||||
this->ctx_->sha.reset();
|
||||
this->ctx_->calculated = false;
|
||||
}
|
||||
|
||||
void SHA256::add(const uint8_t *data, size_t len) {
|
||||
if (!this->ctx_) {
|
||||
this->init();
|
||||
}
|
||||
this->ctx_->sha.update(data, len);
|
||||
}
|
||||
|
||||
void SHA256::calculate() {
|
||||
if (!this->ctx_) {
|
||||
this->init();
|
||||
}
|
||||
if (!this->ctx_->calculated) {
|
||||
this->ctx_->sha.finalize(this->ctx_->hash, 32);
|
||||
this->ctx_->calculated = true;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#error "SHA256 not supported on this platform"
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user