mpi: Add special format GCRYMPI_FMT_OPAQUE.

* src/gcrypt.h.in (GCRYMPI_FMT_OPAQUE): New.
(_gcry_sexp_nth_opaque_mpi): Remove.
* src/sexp.c (gcry_sexp_nth_mpi): Add support for GCRYMPI_FMT_OPAQUE.
(_gcry_sexp_vextract_param): Replace removed function by
GCRYMPI_FMT_OPAQUE.
--

Using a new formatting mode is easier than to add a dedicated
extraction function for opaque MPIs.

Signed-off-by: Werner Koch <wk@gnupg.org>
ecc: Change keygrip computation for Ed25519+EdDSA.

* cipher/ecc.c (compute_keygrip): Rework.
* cipher/ecc-eddsa.c (_gcry_ecc_eddsa_ensure_compact): New.
* cipher/ecc-curves.c (_gcry_ecc_update_curve_param): New.
* tests/keygrip.c (key_grips): Add flag param and test cases for
Ed25519.
--

The keygrip for Ed25519+EdDSA has not yet been used - thus it is
possible to change it.  Using the compact representation saves us the
recovering of x from the standard representation.  Compacting is
basically free.
ecc: Fix some memory leaks

* cipher/ecc-curves.c (_gcry_mpi_ec_new): Free ec->b before assigning.
* cipher/ecc.c (nist_generate_key): Release Q.
* cipher/ecc-eddsa.c (_gcry_ecc_eddsa_genkey): Ditto.
--

_gcry_mpi_ec_new: Fixing memory leak detected with valgrind; if 'b' is
non-NULL, the code in ec_p_init (ec.c:379) already makes a copy of
'b', so before we clobber ctx->b here, we need to at least release the
old value (however, it would of course be nicer to not first make a
copy of b in the first place, but this is the most localized change to
get rid of the memory leak).

nist_generate_key: Fixing rather obvious local leak; Q is first
initialized, then used, copied into the result but never released.
ecc: Fix key generation for a plain Ed25519 key.

* cipher/ecc.c (nist_generate_key): Use custom code for ED25519.
--

I wish there would a an RFC for Curve25519 - the description in the
paper is easy to misunderstand for a non-mathematician.  Source code
and a paper are nice but a proper description (like those in the HAC)
would be better.  Problem spotted by Florian Dold.

Signed-off-by: Werner Koch <wk@gnupg.org>
Initial implementation of GCM

Currently it is still quite slow.

Still no support for generate_iv(). Is it really necessary?

TODO: Merge/reuse cipher-internal state used by CCM.

Changelog entry will be present in final patch submission.

Changes since v1:
- 6x-7x speedup.
- added bench-slope support

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
GCM optimizations
Add Intel PCLMUL acceleration for GCM
GCM: use counter mode code for speed-up
GCM: Tweak Intel PCLMUL ghash loop for small speed-up

#ifdef __x86_64__
      if (nblocks >= 4)
        {
          do
            {
              buf += 4 * blocksize;
              nblocks -= 4;
            }
          while (nblocks >= 4);
        }
#endif
Add aggregated bulk processing for GCM on x86-64

--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
GCM: Add stack burning
GCM: Add clearing and checking of marks.tag
GCM: add FIPS mode restrictions