Fix two bugs with CommonCrypto GCM that can result in invalid output.

Bug 1: Call to AAD but no call to update. Get null tag bytes.
Bug 2: Call to update without call to AAD. Get null ciphertext bytes.

These bugs are ridiculous so there are comments added to try to help us avoid confusion in the future...

Fixes #1329
Thanks.


On Thu, Sep 11, 2014 at 5:34 PM, Paul Kehrer <notifications@github.com>
wrote:

> In cryptography/hazmat/backends/commoncrypto/ciphers.py:
>
> > @@ -164,6 +169,11 @@ def update(self, data):
> >          return self._backend._ffi.buffer(buf)[:]
> >
> >      def finalize(self):
> > +        # CommonCrypto has a yet another bug where you must make at least one
> > +        # call to update. If you pass just AAD and call finalize without a call
> > +        # to update you'll get null bytes for tag. The following update call
> > +        # prevents this issue, which is present in at least 10.8 and 10.9.
> > +        self.update(b"")
>
> I need to check my radar list. I'll drop radar numbers in the comments
> here too.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/pyca/cryptography/pull/1330/files#r17458020>.
>



-- 
"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