+1 on reviewing on a PR on that specific use case. :-)


On Fri, Nov 22, 2013 at 2:35 PM, Paul Kehrer <notifications@github.com>wrote:

> In cryptography/hazmat/bindings/openssl/backend.py:
>
> > @@ -193,6 +193,24 @@ def create_symmetric_encryption_ctx(self, cipher, mode):
> >      def create_symmetric_decryption_ctx(self, cipher, mode):
> >          return _CipherContext(self, cipher, mode, _CipherContext._DECRYPT)
> >
> > +    def _handle_error(self):
> > +        code = self.lib.ERR_get_error()
> > +        assert code != 0
> > +        lib = self.lib.ERR_GET_LIB(code)
> > +        func = self.lib.ERR_GET_FUNC(code)
> > +        reason = self.lib.ERR_GET_REASON(code)
> > +
> > +        if lib == self.lib.ERR_LIB_EVP:
> > +            if func == self.lib.EVP_F_EVP_ENCRYPTFINAL_EX:
> > +                if reason == self.lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH:
> > +                    raise IncorrectPadding
> > +            elif func == self.lib.EVP_F_EVP_DECRYPTFINAL_EX:
> > +                if reason == self.lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH:
> > +                    raise IncorrectPadding
> > +        raise SystemError(
>
> So this is perhaps a cover-your-ass desire. I'd like to have a generic
> error to cover for the tag verification case in GCM. When a GCM tag
> verification error occurs the retval from CipherFinal_ex is 0, but
> ERR_get_error() also returns 0. We could assume that this case is ALWAYS a
> tag verification failure and raise TagError, but what if that's not true?
>
> We could also punt on this issue, land this patch, then take it up as a
> separate discussion item in the GCM PR. I'm fine with that (in fact, that
> makes more sense to me than trying to support a use case we haven't landed
> yet)
>
> I'm [image: :+1:] on this for now then. For coverage we can just nocover
> it since we'll be revisiting it shortly?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/pyca/cryptography/pull/274/files#r7871092>
> .
>



-- 
"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