mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-14 03:30:02 +00:00
really query for internal entropy before sending external one
use strength to compute number of words
This commit is contained in:
parent
3cd07c4dea
commit
1e148a7b7b
@ -50,16 +50,17 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
# Provide entropy
|
||||
self.assertIsInstance(ret, proto.EntropyRequest)
|
||||
internal_entropy = self.client.debug.read_entropy()
|
||||
ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
|
||||
# Read internal entropy and generate mnemonic locally
|
||||
internal_entropy = self.client.debug.read_entropy()
|
||||
# Generate mnemonic locally
|
||||
entropy = generate_entropy(strength, internal_entropy, external_entropy)
|
||||
expected_mnemonic = Mnemonic('english').to_mnemonic(entropy)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(12):
|
||||
for _ in range(strength/32*3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_word()[0])
|
||||
self.client.debug.press_yes()
|
||||
@ -71,7 +72,7 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(12):
|
||||
for _ in range(strength/32*3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_word()[0])
|
||||
self.client.debug.press_yes()
|
||||
@ -112,9 +113,6 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
self.assertIsInstance(ret, proto.EntropyRequest)
|
||||
ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
@ -126,13 +124,17 @@ class TestDeviceReset(common.TrezorTest):
|
||||
pin_encoded = self.client.debug.encode_pin('654')
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Read internal entropy and generate mnemonic locally
|
||||
# Provide entropy
|
||||
self.assertIsInstance(ret, proto.EntropyRequest)
|
||||
internal_entropy = self.client.debug.read_entropy()
|
||||
ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
|
||||
# Generate mnemonic locally
|
||||
entropy = generate_entropy(strength, internal_entropy, external_entropy)
|
||||
expected_mnemonic = Mnemonic('english').to_mnemonic(entropy)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(12):
|
||||
for _ in range(strength/32*3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_word()[0])
|
||||
self.client.debug.press_yes()
|
||||
@ -144,7 +146,7 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(12):
|
||||
for _ in range(strength/32*3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_word()[0])
|
||||
self.client.debug.press_yes()
|
||||
@ -165,10 +167,12 @@ class TestDeviceReset(common.TrezorTest):
|
||||
# Do passphrase-protected action, PassphraseRequest should be raised
|
||||
resp = self.client.call_raw(proto.Ping(passphrase_protection=True))
|
||||
self.assertIsInstance(resp, proto.PassphraseRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
# Do PIN-protected action, PinRequest should be raised
|
||||
resp = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(resp, proto.PinMatrixRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
def test_failed_pin(self):
|
||||
external_entropy = 'zlutoucky kun upel divoke ody' * 2
|
||||
@ -185,9 +189,6 @@ class TestDeviceReset(common.TrezorTest):
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
self.assertIsInstance(ret, proto.EntropyRequest)
|
||||
ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
|
Loading…
Reference in New Issue
Block a user