I think that the message is acceptable but a note about small keys might be 
of some help I suppose. I am also +1 on ValueError now :-)


On 20 March 2014 17:47:08 Alex Gaynor <notifications@github.com> wrote:

> >              if self._backend._lib.Cryptography_HAS_PKEY_CTX:
> >                  self._finalize_method = self._finalize_pkey_ctx
> >                  self._padding_enum = self._backend._lib.RSA_PKCS1_PADDING
> >              else:
> >                  self._finalize_method = self._finalize_pkcs1
> > +        elif isinstance(padding, PSS):
> > +            if not isinstance(padding._mgf, MGF1):
> > +                raise UnsupportedAlgorithm(
> > +                    "Only MGF1 is supported by this backend"
> > +                )
> > +
> > +            # Size of key in bytes - 2 is the maximum
> > +            # PSS signature length (salt length is checked later)
> > +            key_size_bytes = int(math.ceil(private_key.key_size / 8.0))
> > +            if key_size_bytes - algorithm.digest_size - 2 < 0:
> > +                raise ValueError("Digest too large for key size.")
>
> I think `ValueError` is ok, but the error string shoudl give the developer 
> a bit more actionable advice. "Use a bigger  key" or somethig.
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/pyca/cryptography/pull/833/files#r10806946