ec: Use mpi_mulm instead of mpi_powm.

* mpi/ec.c (ec_pow2): New.
(ec_powm): Remove call to mpi_abs.
(dup_point_weierstrass, dup_point_twistededwards)
(add_points_weierstrass, add_points_twistededwards)
(_gcry_mpi_ec_curve_point): Use ec_pow2.

Signed-off-by: Werner Koch <wk@gnupg.org>
pk: Add algo id GCRY_PK_ECC and deprecate ECDSA and ECDH.

* src/gcrypt.h.in (GCRY_PK_ECC): New.
* cipher/pubkey.c (map_algo): New.
(spec_from_algo, gcry_pk_get_param, _gcry_pk_selftest): Use it.
* cipher/ecc.c (selftests_ecdsa): Report using GCRY_PK_ECC.
(run_selftests): Simplify.
(ecdh_names, ecdsa_names): Merge into a new ecc_names.
(_gcry_pubkey_spec_ecdh, _gcry_pubkey_spec_ecdsa): Merge into new
_gcry_pubkey_spec_ecc.
--

The algo ids are actually a relict from Libgcrypt's former life as
GnuPG's crypto code.  They don't make much sense anymore and are often
not needed.

This patch requires some changes to the GnuPG 2.1 code (which has
still not been released).  For example the secret key transfer between
gpg and gpg-agent (gpg --export and gpg --import).  Fortunately this
will also require to add usage flags to the secret key storage of
gpg-agent which is is something we should have done a long time ago.

Signed-off-by: Werner Koch <wk@gnupg.org>
Merge branch 'master' of git://git.gnupg.org/libgcrypt
ecc: Allow the use of an uncompressed public key.

* cipher/ecc.c (eddsa_encodepoint): Factor most code out to ...
(eddsa_encode_x_y): new fucntion.
(eddsa_decodepoint): Allow use of an uncompressed public key.
* tests/t-ed25519.c (N_TESTS): Adjust.
* tests/t-ed25519.inp: Add test 1025.
Merge branch 'master' of git://git.gnupg.org/libgcrypt
ecc: Fix highly unlikely endless loop in sign_ecdsa.

* cipher/ecc.c (sign_ecdsa): Turn while-do into do-while loops.
--

Reported-by: Dmitry Eremin-Solenikov
Signed-off-by: Werner Koch <wk@gnupg.org>
Merge branch 'master' of git://git.gnupg.org/libgcrypt
OFBGOST -> CNTGOST

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Fix 256-bit ecdsa test key definition

* tests/basic.c (check_pubkey): fix nistp256 testing key declaration -
  add missing comma.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Check that secret keys are valid while running basic pubkey tests

* tests/basic.c (do_check_one_pubkey): call gcry_pk_testkey on passed
  secret keys.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Add support for GOST R 34.10-2001/-2012 signatures

* src/cipher.h: define PUBKEY_FLAG_GOST
* cipher/ecc-curves.c: add GOST2001-test and GOST2012-test curves
  defined in standards. Typical applications would use either those
  curves, or curves defined in RFC 4357 (will be added later).
* cipher/ecc.c (sign_gost, verify_gost): New.
  (ecc_sign, ecc_verify): use sign_gost/verify_gost if PUBKEY_FLAG_GOST
  is set.
  (ecc_names): add "gost" for gost signatures.
* cipher/pubkey.c (sexp_data_to_mpi): set PUBKEY_FLAG_GOST if gost flag
  is present in s-exp.
* tests/benchmark.c (ecc_bench): also benchmark GOST signatures.
* tests/basic.c (check_pubkey): add two public keys from
  GOST R 34.10-2012 standard.
  (check_pubkey_sign_ecdsa): add two data sets to check gost signatures.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>