Skip to content

Commit 7231374

Browse files
committed
test(hive): expect non-printable messages to be rejected
Firmware now refuses non-printable Hive messages (domain separation closes the cross-chain message->transaction signature oracle), so the test that asserted a binary buffer signs is inverted to expect the SyntaxError.
1 parent c475482 commit 7231374

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

tests/test_msg_hive.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,17 +528,21 @@ def test_hive_sign_message_all_roles(self):
528528
self.assertEqual(len(seen), 3) # role keys must be distinct
529529

530530
def test_hive_sign_message_nonprintable_bytes(self):
531-
"""Raw (non-printable) buffers sign too — Keychain accepts serialized
532-
Buffer payloads, shown on-device as a hex preview."""
531+
"""Non-printable buffers are REFUSED. A Hive transaction digest is
532+
SHA256(chain_id || serialized_tx) over binary bytes, so a binary
533+
"message" equal to C || tx would hash to a valid transaction signature
534+
on any fork chain C. Restricting signable messages to printable ASCII
535+
keeps them in a domain disjoint from every transaction preimage, closing
536+
that cross-chain message->transaction signature oracle."""
533537
self.requires_firmware("7.15.0")
534538
self.requires_message("HiveSignMessage")
535539
self.setup_mnemonic_nopin_nopassphrase()
536540

537-
message = bytes(range(0, 48)) # starts 0x00... — nothing like the chain id
538-
posting = hive.get_public_key(self.client, hive_path(ROLE_POSTING), show_display=False)
539-
resp = hive.sign_message(self.client, hive_path(ROLE_POSTING), message)
540-
self.assertEqual(self._recover_message_signer(message, resp.signature),
541-
posting.raw_public_key)
541+
from keepkeylib.client import CallException
542+
message = bytes(range(0, 48)) # non-printable bytes
543+
with self.assertRaises(CallException) as ctx:
544+
hive.sign_message(self.client, hive_path(ROLE_POSTING), message)
545+
self.assertIn("printable", str(ctx.exception))
542546

543547
def test_hive_sign_message_long_printable_ok(self):
544548
"""Printable text over the 128-byte display budget still signs — it

0 commit comments

Comments
 (0)