Raise ValueError if the password doesn't fit

Fixes #1235. OpenSSL only allows password up to 1024 bytes.
Turns out that if you raise an error inside a callback from C then the function returns 0 anyway. I'm refactoring this a bit more now :)