mirror of
https://github.com/esphome/esphome.git
synced 2025-09-22 05:02:23 +01:00
preen
This commit is contained in:
@@ -32,7 +32,7 @@ def supports_sha256() -> bool:
|
|||||||
return bool(CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2040 or CORE.is_libretiny)
|
return bool(CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2040 or CORE.is_libretiny)
|
||||||
|
|
||||||
|
|
||||||
def AUTO_LOAD():
|
def AUTO_LOAD() -> list[str]:
|
||||||
"""Conditionally auto-load sha256 only on platforms that support it."""
|
"""Conditionally auto-load sha256 only on platforms that support it."""
|
||||||
base_components = ["md5", "socket"]
|
base_components = ["md5", "socket"]
|
||||||
if supports_sha256():
|
if supports_sha256():
|
||||||
|
@@ -102,7 +102,6 @@ static const uint8_t FEATURE_SUPPORTS_COMPRESSION = 0x01;
|
|||||||
static const uint8_t FEATURE_SUPPORTS_SHA256_AUTH = 0x02;
|
static const uint8_t FEATURE_SUPPORTS_SHA256_AUTH = 0x02;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Template traits for hash algorithms
|
|
||||||
template<typename HashClass> struct HashTraits;
|
template<typename HashClass> struct HashTraits;
|
||||||
|
|
||||||
template<> struct HashTraits<md5::MD5Digest> {
|
template<> struct HashTraits<md5::MD5Digest> {
|
||||||
@@ -121,7 +120,6 @@ template<> struct HashTraits<sha256::SHA256> {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Template helper for hash-based authentication
|
|
||||||
template<typename HashClass> bool perform_hash_auth(ESPHomeOTAComponent *ota, const std::string &password) {
|
template<typename HashClass> bool perform_hash_auth(ESPHomeOTAComponent *ota, const std::string &password) {
|
||||||
using Traits = HashTraits<HashClass>;
|
using Traits = HashTraits<HashClass>;
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@ import random
|
|||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from esphome.core import EsphomeError
|
from esphome.core import EsphomeError
|
||||||
from esphome.helpers import resolve_ip_address
|
from esphome.helpers import resolve_ip_address
|
||||||
@@ -228,7 +229,13 @@ def perform_ota(
|
|||||||
else:
|
else:
|
||||||
upload_contents = file_contents
|
upload_contents = file_contents
|
||||||
|
|
||||||
def perform_auth(sock, password, hash_func, nonce_size, hash_name):
|
def perform_auth(
|
||||||
|
sock: socket.socket,
|
||||||
|
password: str,
|
||||||
|
hash_func: Any,
|
||||||
|
nonce_size: int,
|
||||||
|
hash_name: str,
|
||||||
|
) -> None:
|
||||||
"""Perform challenge-response authentication using specified hash algorithm."""
|
"""Perform challenge-response authentication using specified hash algorithm."""
|
||||||
if not password:
|
if not password:
|
||||||
raise OTAError("ESP requests password, but no password given!")
|
raise OTAError("ESP requests password, but no password given!")
|
||||||
|
Reference in New Issue
Block a user