Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Input strings must be a multiple of 16 in length #24

Open
daxdebor1 opened this issue Jan 29, 2021 · 4 comments
Open

ValueError: Input strings must be a multiple of 16 in length #24

daxdebor1 opened this issue Jan 29, 2021 · 4 comments

Comments

@daxdebor1
Copy link

Hello,
I am a bit noob here, but trying to use pywallet to decrypt wallet.dat.
Password is right, I know, checked in corecrypto.
But when trying to dumpwallet with passphrase:
Traceback (most recent call last):
File "pywallet.py", line 3592, in
read_wallet(json_db, db_env, wallet_name, True, True, "", options.dumpbalanc
e is not None)
File "pywallet.py", line 2555, in read_wallet
secret = crypter.Decrypt(ckey)
File "pywallet.py", line 739, in Decrypt
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).decrypt(data)[0:32]
File "D:\Bitcoin\Python\lib\site-packages\Crypto\Cipher\blockalgo.py", line 29
5, in decrypt
return self._cipher.decrypt(ciphertext)
ValueError: Input strings must be a multiple of 16 in length

I am running the python 2.7 with pycrypto and last pywallet from jackjack.
I know, the problem is probably not with pywallet, but AES, but any advice is very welcome.

p.s. running on windows.

Thanks! Dax

@jackjack-jj
Copy link
Owner

jackjack-jj commented Jan 30, 2021

Hi, what is the version of your wallet? Is it bitcoin-core?
Could you send me a new, empty wallet that triggers the bug?

@daxdebor1
Copy link
Author

daxdebor1 commented Jan 30, 2021

Hi JackJack,
yes, its bitcoin-core, various versions, tried as well fixwallet.py etc.
The passphrase is correct, when I write a wrong1 into pywallet.py, it says encrypted and pass incorrect.
when I write the correct, it writes mentioned ValueError. I do not have the new, empty that triggers the bug.
Edit: I tried as well several Pywallets. Most of them have the same Error. Just Pywallet SSL wrote "NameError: global name 'ctypes' is not defined" and Pywallet Crypter pure wrote "IndexError: list index out of range"
Any ideas? Sorry for spamming. :)
Thanks, Dax.

@jackjack-jj
Copy link
Owner

Sorry, didn't get the notification
FWIW I just pushed a version with a bit less stupid crypter loading
Now for your problem, I get a segfault with the SSL crypter so let's focus on the 2 other ones

For pycrypto, I don't get where the problem is as the data is padded using append_PKCS7_padding
You could replace it with that though to see what you get:

def append_PKCS7_padding(s):
	"""return s padded to a multiple of 16-bytes by PKCS7 padding"""
	numpads = 16 - (len(s)%16)
	r = s + numpads*chr(numpads)
	print(repr(r))
	return r

Does the string has a size of a multiple of 16? It sounds like a Windows encoding-related bug but that's strange I never heard of that before
I'll try that on Windows when I have a chance

Can you post the entire traceback of the crypto pure error?

@daxdebor1
Copy link
Author

Hello JackJack,
thanks for your reply.
I downloaded your last version of pywallet.py (updated ca 2 days ago).
I changed the padding as your recommendation.
the message same as following:
Traceback (most recent call last):
File "D:\Bitcoin\Python\pywalletpo.py", line 3923, in
read_wallet(json_db, db_env, wallet_name, True, True, "", not(options.dumpba
lance is None))
File "D:\Bitcoin\Python\pywalletpo.py", line 2775, in read_wallet
secret = crypter.Decrypt(ckey)
File "D:\Bitcoin\Python\pywalletpo.py", line 908, in Decrypt
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).decrypt(data)[0:32]
File "D:\bitcoin\Python\lib\site-packages\Crypto\Cipher\blockalgo.py", line 29
5, in decrypt
return self._cipher.decrypt(ciphertext)
ValueError: Input strings must be a multiple of 16 in length

To be honest, I am not that skilled, not sure, how to check the padding.
I do have the Python 2.7. and pycrypto-2.6.win-amd64-py2.7.
A bit strange, the mentioned blockalgo.py and overall Crypto Cipher is from 2012. Not sure if there might be a newer version?
I really appreciate your support.
If you prefer, please, do not hesitate to contact me on my e-mail: daxdebor@gmail.com and we could discuss faster and in more details.
Thanks.
Dax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants