mirror of
https://github.com/esphome/esphome.git
synced 2025-09-27 07:32:22 +01:00
dry
This commit is contained in:
@@ -554,16 +554,14 @@ bool ESPHomeOTAComponent::perform_hash_auth_(HashBase *hasher, const std::string
|
|||||||
hasher->init();
|
hasher->init();
|
||||||
|
|
||||||
// Generate nonce seed bytes
|
// Generate nonce seed bytes
|
||||||
uint32_t r1 = random_uint32();
|
uint32_to_bytes(random_uint32(), nonce_bytes);
|
||||||
uint32_to_bytes(r1, nonce_bytes);
|
|
||||||
|
|
||||||
if (nonce_len == 4) {
|
if (nonce_len == 4) {
|
||||||
// MD5: 4 bytes from one random uint32
|
// MD5: 4 bytes from one random uint32
|
||||||
hasher->add(nonce_bytes, 4);
|
hasher->add(nonce_bytes, 4);
|
||||||
} else {
|
} else {
|
||||||
// SHA256: 8 bytes from two random uint32s
|
// SHA256: 8 bytes from two random uint32s
|
||||||
uint32_t r2 = random_uint32();
|
uint32_to_bytes(random_uint32(), nonce_bytes + 4);
|
||||||
uint32_to_bytes(r2, nonce_bytes + 4);
|
|
||||||
hasher->add(nonce_bytes, 8);
|
hasher->add(nonce_bytes, 8);
|
||||||
}
|
}
|
||||||
hasher->calculate();
|
hasher->calculate();
|
||||||
|
Reference in New Issue
Block a user