Public Access
OTA: clean refusal report in ota_push.py; shorter signature error
The device refuses at the header and hangs up mid-transfer; the push client now says so instead of crashing on the reset. The error fits a Toast (47 characters). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -30,7 +30,7 @@ void UpdateParser::parseHeader() {
|
||||
if (sigLen == 0 || sigLen > update::kMaxSignature) return fail("missing signature");
|
||||
uint8_t digest[32];
|
||||
Sha256::hash(h, update::kSignedBytes, digest);
|
||||
if (!verifier_.verify(digest, h + 82, sigLen)) return fail("bad signature: not signed with this device's key");
|
||||
if (!verifier_.verify(digest, h + 82, sigLen)) return fail("bad signature (wrong key)");
|
||||
|
||||
downgrade_ = versionOlder(version_, installed_);
|
||||
if (!sink_.begin(imageSize_)) return fail("could not prepare the update slot");
|
||||
|
||||
+13
-3
@@ -15,6 +15,18 @@ def main():
|
||||
sys.exit(__doc__)
|
||||
path, host = sys.argv[1:3]
|
||||
data = open(path, "rb").read()
|
||||
try:
|
||||
reply = push(data, host)
|
||||
except (ConnectionResetError, BrokenPipeError):
|
||||
# The device checks the header first and hangs up on a refused update mid-transfer.
|
||||
print()
|
||||
print("device: refused the update and closed the connection (the reason is on its screen)")
|
||||
sys.exit(1)
|
||||
print(f"device: {reply or '(no answer)'}")
|
||||
sys.exit(0 if reply.startswith("OK") else 1)
|
||||
|
||||
|
||||
def push(data, host):
|
||||
with socket.create_connection((host, PORT), timeout=15) as s:
|
||||
s.settimeout(60)
|
||||
sent, last = 0, -1
|
||||
@@ -44,9 +56,7 @@ def main():
|
||||
break
|
||||
reply += part
|
||||
print()
|
||||
reply = reply.decode(errors="replace").strip()
|
||||
print(f"device: {reply or '(no answer)'}")
|
||||
sys.exit(0 if reply.startswith("OK") else 1)
|
||||
return reply.decode(errors="replace").strip()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user