1
0

password unification refactor: move methods from wallet to daemon

Note in particular that check_password_for_directory was not safe to use while the daemon had wallets loaded,
as the same file would have two corresponding Wallet() instances in memory. This was specifically handled in
the kivy GUI, on the caller side, by stopping-before and reloading-after the wallets; but it was dirty to
have the caller handle this.
This commit is contained in:
SomberNight
2022-07-06 18:33:08 +02:00
parent c71f00cc8e
commit c463f5e23d
4 changed files with 97 additions and 86 deletions

View File

@@ -146,6 +146,8 @@ class WalletStorage(Logger):
@staticmethod
def get_eckey_from_password(password):
if password is None:
password = ""
secret = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'), b'', iterations=1024)
ec_key = ecc.ECPrivkey.from_arbitrary_size_secret(secret)
return ec_key
@@ -160,6 +162,7 @@ class WalletStorage(Logger):
raise WalletFileException('no encryption magic for version: %s' % v)
def decrypt(self, password) -> None:
"""Raises an InvalidPassword exception on invalid password"""
if self.is_past_initial_decryption():
return
ec_key = self.get_eckey_from_password(password)