mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +00:00
core/slip39: remove _encrypt
This commit is contained in:
parent
cb94454618
commit
53ca61ab00
@ -208,20 +208,6 @@ def _get_salt(identifier: int) -> bytes:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _encrypt(
|
|
||||||
master_secret: bytes, passphrase: bytes, iteration_exponent: int, identifier: int
|
|
||||||
) -> bytes:
|
|
||||||
l = master_secret[: len(master_secret) // 2]
|
|
||||||
r = master_secret[len(master_secret) // 2 :]
|
|
||||||
salt = _get_salt(identifier)
|
|
||||||
for i in range(_ROUND_COUNT):
|
|
||||||
(l, r) = (
|
|
||||||
r,
|
|
||||||
xor(l, _round_function(i, passphrase, iteration_exponent, salt, r)),
|
|
||||||
)
|
|
||||||
return r + l
|
|
||||||
|
|
||||||
|
|
||||||
def decrypt(
|
def decrypt(
|
||||||
identifier: int,
|
identifier: int,
|
||||||
iteration_exponent: int,
|
iteration_exponent: int,
|
||||||
|
@ -155,14 +155,14 @@ class TestMsgResetDeviceT2(TrezorTest):
|
|||||||
assert resp.passphrase_protection is False
|
assert resp.passphrase_protection is False
|
||||||
|
|
||||||
|
|
||||||
def validate_mnemonics(mnemonics, threshold, expected_secret):
|
def validate_mnemonics(mnemonics, threshold, expected_ems):
|
||||||
# We expect these combinations to recreate the secret properly
|
# We expect these combinations to recreate the secret properly
|
||||||
for test_group in combinations(mnemonics, threshold):
|
for test_group in combinations(mnemonics, threshold):
|
||||||
# TODO: HOTFIX, we should fix this properly by modifying and unifying the python-shamir-mnemonic API
|
# TODO: HOTFIX, we should fix this properly by modifying and unifying the python-shamir-mnemonic API
|
||||||
ms = shamir.combine_mnemonics(test_group)
|
ms = shamir.combine_mnemonics(test_group)
|
||||||
identifier, iteration_exponent, _, _, _ = shamir._decode_mnemonics(test_group)
|
identifier, iteration_exponent, _, _, _ = shamir._decode_mnemonics(test_group)
|
||||||
ems = shamir._encrypt(ms, b"", iteration_exponent, identifier)
|
ems = shamir._encrypt(ms, b"", iteration_exponent, identifier)
|
||||||
assert ems == expected_secret
|
assert ems == expected_ems
|
||||||
# We expect these combinations to raise MnemonicError
|
# We expect these combinations to raise MnemonicError
|
||||||
for test_group in combinations(mnemonics, threshold - 1):
|
for test_group in combinations(mnemonics, threshold - 1):
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
|
Loading…
Reference in New Issue
Block a user