Skip to content

Commit 7f538a9

Browse files
committed
test(reset): assert display_random is ignored on every product
Firmware 7.14.3 now ignores ResetDevice.display_random, as 7.14.2 and 7.15 already did, so no supported product draws an internal-entropy screen. The version predicate these two tests used is therefore gone. Rather than drop the flag from the request, both tests keep display_random=True and assert the device does NOT answer with a ButtonRequest. That turns a branch that merely tolerated the screen into a regression guard: if any firmware starts honouring the field again, these fail. That is worth guarding because the value the screen rendered is the exact 32 bytes whose complement this host supplies -- the suite answers EntropyRequest itself -- so the screen plus our own external_entropy is the seed pre-image.
1 parent 8649abe commit 7f538a9

1 file changed

Lines changed: 20 additions & 42 deletions

File tree

tests/test_msg_resetdevice.py

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,12 @@ def test_reset_device_24_words(self):
317317
def test_reset_device_pin(self):
318318
external_entropy = b'zlutoucky kun upel divoke ody' * 2
319319
strength = 128
320-
# Whether the Internal Entropy screen appears is NOT monotonic in
321-
# version, so no floor expresses it. 7.14.2 refuses the legacy
322-
# display_random request outright (reset.c: "(void)display_random"),
323-
# 7.14.3 still honours it for already-shipped 7.14-line hosts and
324-
# renders all 32 bytes of int_entropy, and 7.15 removes the screen
325-
# again. Only the 7.14.3 band shows it.
326-
shows_entropy_screen = (self.firmware_at_least("7.14.3")
327-
and not self.firmware_at_least("7.15.0"))
320+
# display_random is ignored by every supported product. 7.14.2 always
321+
# did; 7.14.3 and 7.15 now do too. The request below deliberately sets
322+
# it to True so this test fails if any firmware starts honouring it
323+
# again: the device half it would render is the exact 32 bytes whose
324+
# complement this host supplies, so the screen plus our own
325+
# external_entropy is the seed pre-image.
328326

329327
ret = self.client.call_raw(proto.ResetDevice(display_random=True,
330328
strength=strength,
@@ -333,19 +331,10 @@ def test_reset_device_pin(self):
333331
language='english',
334332
label='test'))
335333

336-
# display_random=True above is deliberate: the field stays in the wire
337-
# schema for host compatibility. Firmware that refuses it does so
338-
# because internal entropy is seed
339-
# pre-image material, and a host that sets the flag and reads that
340-
# screen once can compute SHA256(shown || ext) and derive the seed.
341-
#
342-
# Branch on the version rather than skipping the test: everything below
343-
# (PIN entry, EntropyRequest/Ack, mnemonic derivation) is version-
344-
# independent and must keep running on older firmware.
345-
if shows_entropy_screen:
346-
self.assertIsInstance(ret, proto.ButtonRequest)
347-
self.client.debug.press_yes()
348-
ret = self.client.call_raw(proto.ButtonAck())
334+
self.assertNotIsInstance(
335+
ret, proto.ButtonRequest,
336+
'display_random must be ignored: firmware answered the reset with a '
337+
'ButtonRequest, which means an internal-entropy screen was drawn')
349338
self.assertIsInstance(ret, proto.PinMatrixRequest)
350339
self.client._capture_oled_after_animation(1.05, (192, 256, 0, 64))
351340

@@ -415,14 +404,12 @@ def test_reset_device_pin(self):
415404
def test_failed_pin(self):
416405
external_entropy = 'zlutoucky kun upel divoke ody' * 2
417406
strength = 128
418-
# Whether the Internal Entropy screen appears is NOT monotonic in
419-
# version, so no floor expresses it. 7.14.2 refuses the legacy
420-
# display_random request outright (reset.c: "(void)display_random"),
421-
# 7.14.3 still honours it for already-shipped 7.14-line hosts and
422-
# renders all 32 bytes of int_entropy, and 7.15 removes the screen
423-
# again. Only the 7.14.3 band shows it.
424-
shows_entropy_screen = (self.firmware_at_least("7.14.3")
425-
and not self.firmware_at_least("7.15.0"))
407+
# display_random is ignored by every supported product. 7.14.2 always
408+
# did; 7.14.3 and 7.15 now do too. The request below deliberately sets
409+
# it to True so this test fails if any firmware starts honouring it
410+
# again: the device half it would render is the exact 32 bytes whose
411+
# complement this host supplies, so the screen plus our own
412+
# external_entropy is the seed pre-image.
426413

427414
ret = self.client.call_raw(proto.ResetDevice(display_random=True,
428415
strength=strength,
@@ -431,19 +418,10 @@ def test_failed_pin(self):
431418
language='english',
432419
label='test'))
433420

434-
# display_random=True above is deliberate: the field stays in the wire
435-
# schema for host compatibility. Firmware that refuses it does so
436-
# because internal entropy is seed
437-
# pre-image material, and a host that sets the flag and reads that
438-
# screen once can compute SHA256(shown || ext) and derive the seed.
439-
#
440-
# Branch on the version rather than skipping the test: everything below
441-
# (PIN entry, EntropyRequest/Ack, mnemonic derivation) is version-
442-
# independent and must keep running on older firmware.
443-
if shows_entropy_screen:
444-
self.assertIsInstance(ret, proto.ButtonRequest)
445-
self.client.debug.press_yes()
446-
ret = self.client.call_raw(proto.ButtonAck())
421+
self.assertNotIsInstance(
422+
ret, proto.ButtonRequest,
423+
'display_random must be ignored: firmware answered the reset with a '
424+
'ButtonRequest, which means an internal-entropy screen was drawn')
447425
self.assertIsInstance(ret, proto.PinMatrixRequest)
448426
self.client._capture_oled_after_animation(1.05, (192, 256, 0, 64))
449427

0 commit comments

Comments
 (0)