URI: 
       tMerge pull request #4563 from spesmilo/remove_pbkdf2 - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit bdb8220a1aef0ddeea28c0c56bbda4c5bc041edb
   DIR parent b4b862b0cc7930396f1350783019f61db8bf7a12
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Wed, 18 Jul 2018 14:49:36 +0200
       
       Merge pull request #4563 from spesmilo/remove_pbkdf2
       
       remove pbkdf2 dependency, use stdlib instead
       Diffstat:
         M contrib/requirements/requirements.… |       1 -
         M electrum/keystore.py                |       7 +++----
         M electrum/mnemonic.py                |       3 +--
         M electrum/plugins/digitalbitbox/dig… |       4 ++--
         M electrum/storage.py                 |       6 +++---
         M run_electrum                        |       1 -
       
       6 files changed, 9 insertions(+), 13 deletions(-)
       ---
   DIR diff --git a/contrib/requirements/requirements.txt b/contrib/requirements/requirements.txt
       t@@ -1,6 +1,5 @@
        pyaes>=0.1a1
        ecdsa>=0.9
       -pbkdf2
        requests
        qrcode
        protobuf
   DIR diff --git a/electrum/keystore.py b/electrum/keystore.py
       t@@ -552,13 +552,12 @@ def bip39_normalize_passphrase(passphrase):
            return normalize('NFKD', passphrase or '')
        
        def bip39_to_seed(mnemonic, passphrase):
       -    import pbkdf2, hashlib, hmac
       +    import hashlib, hmac
            PBKDF2_ROUNDS = 2048
            mnemonic = normalize('NFKD', ' '.join(mnemonic.split()))
            passphrase = bip39_normalize_passphrase(passphrase)
       -    return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase,
       -                         iterations = PBKDF2_ROUNDS, macmodule = hmac,
       -                         digestmodule = hashlib.sha512).read(64)
       +    return hashlib.pbkdf2_hmac('sha512', mnemonic.encode('utf-8'),
       +        b'mnemonic' + passphrase.encode('utf-8'), iterations = PBKDF2_ROUNDS)
        
        # returns tuple (is_checksum_valid, is_wordlist_valid)
        def bip39_is_checksum_valid(mnemonic):
   DIR diff --git a/electrum/mnemonic.py b/electrum/mnemonic.py
       t@@ -30,7 +30,6 @@ import unicodedata
        import string
        
        import ecdsa
       -import pbkdf2
        
        from .util import print_error
        from .bitcoin import is_old_seed, is_new_seed
       t@@ -131,7 +130,7 @@ class Mnemonic(object):
                PBKDF2_ROUNDS = 2048
                mnemonic = normalize_text(mnemonic)
                passphrase = normalize_text(passphrase)
       -        return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
       +        return hashlib.pbkdf2_hmac('sha512', mnemonic.encode('utf-8'), b'electrum' + passphrase.encode('utf-8'), iterations = PBKDF2_ROUNDS)
        
            def mnemonic_encode(self, i):
                n = len(self.wordlist)
   DIR diff --git a/electrum/plugins/digitalbitbox/digitalbitbox.py b/electrum/plugins/digitalbitbox/digitalbitbox.py
       t@@ -120,8 +120,8 @@ class DigitalBitbox_Client():
        
        
            def stretch_key(self, key):
       -        import pbkdf2, hmac
       -        return to_hexstr(pbkdf2.PBKDF2(key, b'Digital Bitbox', iterations = 20480, macmodule = hmac, digestmodule = hashlib.sha512).read(64))
       +        import hmac
       +        return to_hexstr(hashlib.pbkdf2_hmac('sha512', key.encode('utf-8'), b'Digital Bitbox', iterations = 20480))
        
        
            def backup_password_dialog(self):
   DIR diff --git a/electrum/storage.py b/electrum/storage.py
       t@@ -29,7 +29,7 @@ import json
        import copy
        import re
        import stat
       -import pbkdf2, hmac, hashlib
       +import hmac, hashlib
        import base64
        import zlib
        from collections import defaultdict
       t@@ -165,7 +165,7 @@ class WalletStorage(PrintError):
        
            @staticmethod
            def get_eckey_from_password(password):
       -        secret = pbkdf2.PBKDF2(password, '', iterations=1024, macmodule=hmac, digestmodule=hashlib.sha512).read(64)
       +        secret = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'), b'', iterations=1024)
                ec_key = ecc.ECPrivkey.from_arbitrary_size_secret(secret)
                return ec_key
        
       t@@ -637,7 +637,7 @@ class WalletStorage(PrintError):
                    # version 1.9.8 created v6 wallets when an incorrect seed was entered in the restore dialog
                    msg += '\n\nThis file was created because of a bug in version 1.9.8.'
                    if self.get('master_public_keys') is None and self.get('master_private_keys') is None and self.get('imported_keys') is None:
       -                # pbkdf2 was not included with the binaries, and wallet creation aborted.
       +                # pbkdf2 (at that time an additional dependency) was not included with the binaries, and wallet creation aborted.
                        msg += "\nIt does not contain any keys, and can safely be removed."
                    else:
                        # creation was complete if electrum was run from source
   DIR diff --git a/run_electrum b/run_electrum
       t@@ -46,7 +46,6 @@ def check_imports():
                import ecdsa
                import requests
                import qrcode
       -        import pbkdf2
                import google.protobuf
                import jsonrpclib
            except ImportError as e: