dlitz/pycrypto — pull request #69 by jkfritcher (2013-12-25 00:18:07+00:00)
Title: PBKDF2() does not correctly handle a salt that is string in Python 3

Greetings,

In Python 3, the PBKDF2 function does not correctly handle a salt that is passed to it as a string, as the PyDoc suggests it should. I checked the test cases for the KDF functions and they're only passing byte arrays and not strings. I corrected the problem by handling the salt like the password and passing the salt through tobytes() before doing anything.

````
>>> from Crypto.Protocol.KDF import PBKDF2
>>> PBKDF2('PasswordPasswordPassword', 'SaltSaltSalt')
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.3/site-packages/Crypto/Protocol/KDF.py", line 116, in PBKDF2
U = previousU = prf(password,salt+struct.pack(">I", i))
TypeError: Can't convert 'bytes' object to str implicitly
````

Thanks!