bmonkaba / ga-bitbot

Automatically exported from code.google.com/p/ga-bitbot
GNU General Public License v3.0
0 stars 0 forks source link

"encrypt_api_key.py" cant create key with pycrypto #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When trying to create the api key an error appear with the following output:

Generating the encrypted API KEY file...
Traceback (most recent call last):
  File "encrypt_api_key.py", line 59, in <module>
    encryptor = AES.new(hash_pass, AES.MODE_CBC)
  File "/usr/lib/python2.7/dist-packages/Crypto/Cipher/AES.py", line 94, in new
    return AESCipher(key, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/Crypto/Cipher/AES.py", line 59, in __init__
    blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py", line 141, in __init__
    self._cipher = factory.new(key, *args, **kwargs)
ValueError: IV must be 16 bytes long

This happens because with AES with CBC mode the parameter IV isn't optional 
anymore.

https://bugs.launchpad.net/pycrypto/+bug/1018283

Original issue reported on code.google.com by andremos...@gmail.com on 29 Nov 2012 at 12:27

GoogleCodeExporter commented 9 years ago
After some search i (probably) found a solution, the diff is attached.

Original comment by andremos...@gmail.com on 29 Nov 2012 at 1:08

Attachments:

GoogleCodeExporter commented 9 years ago
Well, its not that easy, after some research i found that the VI parameter must 
be saved to be used in the file MtGoxHMAC.py.
I created a file where the data is saved and later read by MtGoxHMAC.
But MtGoxHMAC is using a completely broken api, so nothing work after all.

Original comment by andremos...@gmail.com on 29 Nov 2012 at 8:03

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Fixed on repo.
AES encryption is now using the iv parameter.

The supplied diff was close, I just needed to prepend the encrypted data with 
the plain text IV parameter before saving. Then to decode, the plain text iv 
data is first extracted from the beginning of the encrypted file and used to 
initialize AES.

Any previously generated encrypted key files will need to be regenerated to use 
the new method.

The issue with MtGoxHMAC was that it was moved into a library folder which 
broke the hard coded file path links to the config folder. This exception is 
caught but the error message didn't consider this condition. I just moved the 
file back into the main folder for now - it should work.

Original comment by brian.mo...@gmail.com on 2 Dec 2012 at 5:29

GoogleCodeExporter commented 9 years ago
I re-encrypted my keys and am running the bcbookie script without issues.
fix verified.

Original comment by brian.mo...@gmail.com on 2 Dec 2012 at 6:31