I am trying to get AES encryption to work through the PyCrypto library in Python.
I read in the password from the user and salt from a file. I then call PBKDF2 to generate a key from the textual password
PBKDF2(self.master_password, salt, 32)
I then generate an IV using the Random.get_random_bytes
IV = Random.get_random_bytes(len(key))
I then create a Counter from the Crypto.Util package
ctr = Counter.new(32, IV)
Then I create an AES object
e = AES.new(key, AES.MODE_CTR, counter=ctr)
However when I call e to encrypt
e.encrypt(user_name)
I get the following error
CTR counter function returned string not of length 16
From the way I understand this error means that the block cipher is 16 bytes which matches with the documentation I found at
https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.AES-module.html
I tried changing it to a 32 byte block size by create the AES object like this
AES_Encryptor = AES.new(key, AES.MODE_CTR, counter=ctr, block_size=32)
but then I get the following error
'block_size' is an invalid keyword argument for this function
If someone could point me towards the right direction that'd be great.