Ahhhh. Yes, some other name would be good, I had no idea that you had to
transmit the data yourself and that it wasn't in the message. (Fuck
cryptography)

Alex


On Sun, Nov 24, 2013 at 8:00 AM, Paul Kehrer <notifications@github.com>wrote:

> In docs/hazmat/primitives/symmetric-encryption.rst:
>
> > +                                        to be 96-bit by NIST, but can be up to
> > +                                        2\ :sup:`64` - 1 bits. Do not reuse an
> > +                                        ``initialization_vector`` with a given
> > +                                        ``key``.
> > +
> > +    .. doctest::
> > +
> > +        >>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
> > +        >>> cipher = Cipher(algorithms.AES(key), modes.GCM(iv))
> > +        >>> encryptor = cipher.encryptor()
> > +        >>> encryptor.add_data(b"authenticated but encrypted payload")
> > +        >>> ct = encryptor.update(b"a secret message") + encryptor.finalize()
> > +        >>> tag = encryptor.tag
> > +        >>> cipher = Cipher(algorithms.AES(key), modes.GCM(iv, tag))
> > +        >>> decryptor = cipher.decryptor()
> > +        >>> decryptor.add_data(b"authenticated but encrypted payload")
>
> Think of add_data as a method that mixes data into the tag state but does
> not encrypt. For a decryption to be successful you must supply the same
> authenticated data you did during encryption, so you have to call add_dataon both contexts.
>
> Would it be more clear to call it something like authenticated_datainstead of
> add_data? add_data arguably implies the data is being stored (rather than
> simply processed through the GHASH algorithm and not retained directly).
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/pyca/cryptography/pull/176/files#r7879076>
> .
>



-- 
"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