Good point, perhaps suggest they just use MAX_LENGTH and be happy.


On Thu, Mar 20, 2014 at 11:32 AM, Alex Stapleton
<notifications@github.com>wrote:

> In cryptography/hazmat/backends/openssl/backend.py:
>
> > @@ -768,7 +824,13 @@ def _finalize_pkey_ctx(self, evp_pkey, pkey_size, evp_md):
> >          buf = self._backend._ffi.new("unsigned char[]", buflen[0])
> >          res = self._backend._lib.EVP_PKEY_sign(
> >              pkey_ctx, buf, buflen, data_to_sign, len(data_to_sign))
> > -        assert res == 1
> > +        if res != 1:
> > +            errors = self._backend._consume_errors()
> > +            assert errors[0].lib == self._backend._lib.ERR_LIB_RSA
> > +            assert (errors[0].reason ==
> > +                    self._backend._lib.RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE)
> > +            raise ValueError("Salt length too long for key size")
>
> Request a smaller salt? I don't think they can get this error for any
> reason other than manually entering a salt length that's too large?
> … <#144e0c4486c78a0d_>
> On 20 March 2014 17:47:48 Alex Gaynor <notifications@github.com> wrote: >
> @@ -768,7 +824,13 @@ def _finalize_pkey_ctx(self, evp_pkey, pkey_size,
> evp_md): > buf = self._backend._ffi.new("unsigned char[]", buflen[0]) > res
> = self._backend._lib.EVP_PKEY_sign( > pkey_ctx, buf, buflen, data_to_sign,
> len(data_to_sign)) > - assert res == 1 > + if res != 1: > + errors =
> self._backend._consume_errors() > + assert errors[0].lib ==
> self._backend._lib.ERR_LIB_RSA > + assert (errors[0].reason == > +
> self._backend._lib.RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE) > + raise
> ValueError("Salt length too long for key size") Same thing here, what is
> the user supposed to do with this info. --- Reply to this email directly or
> view it on GitHub:
> https://github.com/pyca/cryptography/pull/833/files#r10806977
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/pyca/cryptography/pull/833/files#r10809494>
> .
>



-- 
"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