Bitcoin Forum

Bitcoin => Electrum => Topic started by: iron888 on November 25, 2018, 08:39:34 PM



Title: Incorrect IV length error in Electrum console
Post by: iron888 on November 25, 2018, 08:39:34 PM
Hello, I can open my password-protected wallet locally via GUI without any problems, but when I try to access electrum password-protected functions on server using console I get this error:

Code:
Server-side exception: <Fault -32603: Server error: File "/usr/local/lib/python3.5/dist-packages/electrum/crypto.py", line 118, in pw_decode | electrum.util.InvalidPassword: Incorrect password
>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/electrum/crypto.py", line 116, in pw_decode
    d = to_string(DecodeAES(secret, s), "utf8")
  File "/usr/local/lib/python3.5/dist-packages/electrum/crypto.py", line 102, in DecodeAES
    s = aes_decrypt_with_iv(secret, iv, e)
  File "/usr/local/lib/python3.5/dist-packages/electrum/crypto.py", line 80, in aes_decrypt_with_iv
    cipher = AES.new(key, AES.MODE_CBC, iv)
  File "/usr/local/lib/python3.5/dist-packages/Cryptodome/Cipher/AES.py", line 225, in new
    return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/Cryptodome/Cipher/__init__.py", line 79, in _create_cipher
    return modes[mode](factory, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/Cryptodome/Cipher/_mode_cbc.py", line 287, in _create_cbc_cipher
    factory.block_size)
ValueError: Incorrect IV length (it must be 16 bytes long)

During handling of the above exception, another exception occurred:
Code:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/jsonrpclib/SimpleJSONRPCServer.py", line 376, in _dispatch
    return func(*params)
  File "/usr/local/lib/python3.5/dist-packages/electrum/daemon.py", line 287, in run_cmdline
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/electrum/commands.py", line 87, in func_wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/electrum/commands.py", line 360, in getseed
    s = self.wallet.get_seed(password)
  File "/usr/local/lib/python3.5/dist-packages/electrum/wallet.py", line 1375, in get_seed
    return self.keystore.get_seed(password)
  File "/usr/local/lib/python3.5/dist-packages/electrum/keystore.py", line 217, in get_seed
    return pw_decode(self.seed, password)
  File "/usr/local/lib/python3.5/dist-packages/electrum/crypto.py", line 118, in pw_decode
    raise InvalidPassword()
electrum.util.InvalidPassword: Incorrect password
Traceback (most recent call last):
  File "/usr/local/bin/electrum", line 465, in <module>
    result = server.run_cmdline(config_options)
  File "/usr/local/lib/python3.5/dist-packages/jsonrpclib/jsonrpc.py", line 650, in __call__
    return self.__send(self.__name, args)
  File "/usr/local/lib/python3.5/dist-packages/jsonrpclib/jsonrpc.py", line 532, in _request
    check_for_errors(response)
  File "/usr/local/lib/python3.5/dist-packages/jsonrpclib/jsonrpc.py", line 1220, in check_for_errors
    raise ProtocolError((code, message))
jsonrpclib.jsonrpc.ProtocolError: (-32603, 'Server error: File "/usr/local/lib/python3.5/dist-packages/electrum/crypto.py", line 118, in pw_decode | electrum.util.InvalidPassword: Incorrect password\n')

How to fix it?


Title: Re: Incorrect IV length error in Electrum console
Post by: jackg on November 25, 2018, 08:50:47 PM
What command are you trying to run that gives this error, can you isolate it or is it in a script somewhere?


Title: Re: Incorrect IV length error in Electrum console
Post by: iron888 on November 25, 2018, 08:58:21 PM
What command are you trying to run that gives this error, can you isolate it or is it in a script somewhere?
For example when calling
Code:
electrum getseed


Title: Re: Incorrect IV length error in Electrum console
Post by: jackg on November 25, 2018, 09:01:25 PM
There is a stackoverflow thread with the solution here, have you tried this? https://stackoverflow.com/questions/42485408/getting-error-of-invalid-iv-length-while-using-aes-256-cbc-for-encryption-in-nod


That’s not directly electrum but it looks like it’s with the aes encryption in general, but I could be completely wrong.

Add code to work out how big the actual inputted password is otherwise and return the results here (in bytes).