Raise ValueError if the password doesn't fit

Fixes #1235. OpenSSL only allows password up to 1024 bytes.
Let's not rely on that :-)


On Thu, Jul 10, 2014 at 2:44 PM, Alex Stapleton <notifications@github.com>
wrote:

> In cryptography/hazmat/backends/openssl/backend.py:
>
> > @@ -490,14 +490,19 @@ def _pem_password_cb(self, password):
> >          def pem_password_cb(buf, size, writing, userdata):
> >              pem_password_cb.called += 1
> >
> > -            if not password or len(password) >= size:
> > -                return 0
> > -            else:
> > +            if len(password) < size:
>
> 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 :)
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/pyca/cryptography/pull/1252/files#r14795717>.
>



-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084