fix(tools): add key type validation and tighten test assertions in sign_firmware

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 06:50:51 -07:00
parent 031426e364
commit 87b30a64b2
2 changed files with 16 additions and 4 deletions

View File

@@ -1,7 +1,8 @@
import os, sys, tempfile
import sys
from pathlib import Path
import pytest
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric.utils import decode_dss_signature
@@ -59,5 +60,5 @@ def test_wrong_key_fails_verification(keypair, tmp_path):
from cryptography.hazmat.primitives.asymmetric.utils import encode_dss_signature
sig_der = encode_dss_signature(r, s)
with pytest.raises(Exception):
with pytest.raises(InvalidSignature):
other_key.public_key().verify(sig_der, b"firmware", ec.ECDSA(hashes.SHA256()))