1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-03 18:42:23 +01:00
This commit is contained in:
J. Nick Koston
2025-09-23 09:49:42 -05:00
parent 7ac0f1c9a2
commit 174cdac5e1

View File

@@ -555,15 +555,10 @@ bool ESPHomeOTAComponent::perform_hash_auth_(HashBase *hasher, const std::string
// Generate nonce seed bytes // Generate nonce seed bytes
uint32_to_bytes(random_uint32(), nonce_bytes); uint32_to_bytes(random_uint32(), nonce_bytes);
if (nonce_len > 4) {
if (nonce_len == 4) {
// MD5: 4 bytes from one random uint32
hasher->add(nonce_bytes, 4);
} else {
// SHA256: 8 bytes from two random uint32s
uint32_to_bytes(random_uint32(), nonce_bytes + 4); uint32_to_bytes(random_uint32(), nonce_bytes + 4);
hasher->add(nonce_bytes, 8);
} }
hasher->add(nonce_bytes, nonce_len);
hasher->calculate(); hasher->calculate();
// Generate and send nonce // Generate and send nonce