chore(tests): adjust THP pairing tests to the new `code_code_entry` encoding [no changelog]
What changed, and why it matters
This is a test-only change that updates how a numeric pairing code is converted into bytes for Trezor's THP (Trezor Host Protocol) pairing tests. It switches from raw binary encoding of the number to a 6-digit ASCII string encoding. The change does not touch any production firmware or host library code, only a single Python test file.
No security action required. This is a test maintenance commit. Reviewers may optionally verify the new ASCII encoding matches the intended THP pairing-code format in the production implementation.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies tests/device_tests/thp/test_pairing.py. Previously, the pairing code (an integer) was encoded as a 6-byte big-endian binary value via code.to_bytes(6, ‘big’). The change encodes it as a zero-padded 6-digit ASCII decimal string via f”{code:06}”.encode(‘ascii’). This aligns the test with a new code_code_entry encoding format. No cryptographic constants, protocol logic, or non-test code is changed.
Changed components
tests/device_tests/thp/test_pairing.pyInspect captured patch +3 / −1
diff --git a/tests/device_tests/thp/test_pairing.py b/tests/device_tests/thp/test_pairing.py
index 271005a2d..588576257 100644
--- a/tests/device_tests/thp/test_pairing.py
+++ b/tests/device_tests/thp/test_pairing.py
@@ -141,7 +141,9 @@ def test_pairing_code_entry(
cpace = Cpace(handshake_hash=protocol.handshake_hash)
cpace.random_bytes = os.urandom
- cpace.generate_keys_and_secret(code.to_bytes(6, "big"), cpace_trezor_public_key)
+ cpace.generate_keys_and_secret(
+ f"{code:06}".encode("ascii"), cpace_trezor_public_key
+ )
sha_ctx = sha256(cpace.shared_secret)
tag = sha_ctx.digest()
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.