mirror of
https://github.com/esphome/esphome.git
synced 2025-09-23 05:32:22 +01:00
preen
This commit is contained in:
@@ -540,11 +540,11 @@ template<typename HashClass> bool ESPHomeOTAComponent::perform_hash_auth_(const
|
|||||||
// Use hex_buffer1 for nonce
|
// Use hex_buffer1 for nonce
|
||||||
hasher.get_hex(hex_buffer1);
|
hasher.get_hex(hex_buffer1);
|
||||||
hex_buffer1[Traits::HEX_SIZE] = '\0';
|
hex_buffer1[Traits::HEX_SIZE] = '\0';
|
||||||
ESP_LOGV("esphome.ota", "Auth: %s Nonce is %s", Traits::NAME, hex_buffer1);
|
ESP_LOGV(TAG, "Auth: %s Nonce is %s", Traits::NAME, hex_buffer1);
|
||||||
|
|
||||||
// Send nonce
|
// Send nonce
|
||||||
if (!this->writeall_(reinterpret_cast<uint8_t *>(hex_buffer1), Traits::HEX_SIZE)) {
|
if (!this->writeall_(reinterpret_cast<uint8_t *>(hex_buffer1), Traits::HEX_SIZE)) {
|
||||||
ESP_LOGW("esphome.ota", "Auth: Writing %s nonce failed", Traits::NAME);
|
ESP_LOGW(TAG, "Auth: Writing %s nonce failed", Traits::NAME);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,11 +555,11 @@ template<typename HashClass> bool ESPHomeOTAComponent::perform_hash_auth_(const
|
|||||||
|
|
||||||
// Receive cnonce into hex_buffer2
|
// Receive cnonce into hex_buffer2
|
||||||
if (!this->readall_(reinterpret_cast<uint8_t *>(hex_buffer2), Traits::HEX_SIZE)) {
|
if (!this->readall_(reinterpret_cast<uint8_t *>(hex_buffer2), Traits::HEX_SIZE)) {
|
||||||
ESP_LOGW("esphome.ota", "Auth: Reading %s cnonce failed", Traits::NAME);
|
ESP_LOGW(TAG, "Auth: Reading %s cnonce failed", Traits::NAME);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hex_buffer2[Traits::HEX_SIZE] = '\0';
|
hex_buffer2[Traits::HEX_SIZE] = '\0';
|
||||||
ESP_LOGV("esphome.ota", "Auth: %s CNonce is %s", Traits::NAME, hex_buffer2);
|
ESP_LOGV(TAG, "Auth: %s CNonce is %s", Traits::NAME, hex_buffer2);
|
||||||
|
|
||||||
// Add cnonce to hash
|
// Add cnonce to hash
|
||||||
hasher.add(hex_buffer2, Traits::HEX_SIZE);
|
hasher.add(hex_buffer2, Traits::HEX_SIZE);
|
||||||
@@ -568,21 +568,21 @@ template<typename HashClass> bool ESPHomeOTAComponent::perform_hash_auth_(const
|
|||||||
hasher.calculate();
|
hasher.calculate();
|
||||||
hasher.get_hex(hex_buffer1);
|
hasher.get_hex(hex_buffer1);
|
||||||
hex_buffer1[Traits::HEX_SIZE] = '\0';
|
hex_buffer1[Traits::HEX_SIZE] = '\0';
|
||||||
ESP_LOGV("esphome.ota", "Auth: %s Result is %s", Traits::NAME, hex_buffer1);
|
ESP_LOGV(TAG, "Auth: %s Result is %s", Traits::NAME, hex_buffer1);
|
||||||
|
|
||||||
// Receive response - reuse hex_buffer2
|
// Receive response - reuse hex_buffer2
|
||||||
if (!this->readall_(reinterpret_cast<uint8_t *>(hex_buffer2), Traits::HEX_SIZE)) {
|
if (!this->readall_(reinterpret_cast<uint8_t *>(hex_buffer2), Traits::HEX_SIZE)) {
|
||||||
ESP_LOGW("esphome.ota", "Auth: Reading %s response failed", Traits::NAME);
|
ESP_LOGW(TAG, "Auth: Reading %s response failed", Traits::NAME);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hex_buffer2[Traits::HEX_SIZE] = '\0';
|
hex_buffer2[Traits::HEX_SIZE] = '\0';
|
||||||
ESP_LOGV("esphome.ota", "Auth: %s Response is %s", Traits::NAME, hex_buffer2);
|
ESP_LOGV(TAG, "Auth: %s Response is %s", Traits::NAME, hex_buffer2);
|
||||||
|
|
||||||
// Compare
|
// Compare
|
||||||
bool matches = memcmp(hex_buffer1, hex_buffer2, Traits::HEX_SIZE) == 0;
|
bool matches = memcmp(hex_buffer1, hex_buffer2, Traits::HEX_SIZE) == 0;
|
||||||
|
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
ESP_LOGW("esphome.ota", "Auth failed! %s passwords do not match", Traits::NAME);
|
ESP_LOGW(TAG, "Auth failed! %s passwords do not match", Traits::NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
|
Reference in New Issue
Block a user