1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-22 05:02:23 +01:00
This commit is contained in:
J. Nick Koston
2025-09-19 15:54:17 -06:00
parent 6215199c1a
commit e721e8c203
3 changed files with 9 additions and 4 deletions

View File

@@ -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():

View File

@@ -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>;

View File

@@ -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!")