Hmm, interesting. Does it make sense to put some structured data on the
exception instead of a proliferation of exception types?


On Sun, Feb 23, 2014 at 11:34 AM, Paul Kehrer <notifications@github.com>wrote:

> In cryptography/hazmat/backends/openssl/backend.py:
>
> > +class _RSASignatureContext(object):
> > +    def __init__(self, backend, private_key, padding, algorithm):
> > +        self._backend = backend
> > +        self._private_key = private_key
> > +        if not isinstance(padding, interfaces.AsymmetricPadding):
> > +            raise TypeError(
> > +                "Expected interface of interfaces.AsymmetricPadding")
> > +
> > +        if padding.name == "EMSA-PKCS1-v1_5":
> > +            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
> > +        else:
> > +            raise UnsupportedAsymmetricPadding
>
> If we use UnsupportedAlgorithm then the user will be unable to
> distinguish from the exception whether they have an unsupported padding or
> an unsupported hash algorithm, so I thought it might be a good idea to add
> a new exception for this.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/pyca/cryptography/pull/673/files#r9976677>
> .
>



-- 
"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