mpi: mpi-pow improvement.

* mpi/mpi-pow.c (gcry_mpi_powm): New implementation of left-to-right
k-ary exponentiation.
--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

For the Yarom/Falkner flush+reload cache side-channel attack, we
changed the code so that it always calls the multiplication routine
(even if we can skip it to get result).  This results some performance
regression.

This change is for recovering performance with efficient algorithm.
sexp: Add function gcry_sexp_extract_param.

* src/gcrypt.h.in (_GCRY_GCC_ATTR_SENTINEL): New.
(gcry_sexp_extract_param): New.
* src/visibility.c (gcry_sexp_extract_param): New.
* src/visibility.h (gcry_sexp_extract_param): Add hack to detect
internal use.
* cipher/pubkey-util.c (_gcry_pk_util_extract_mpis): Move and split
into ...
* src/sexp.c (_gcry_sexp_vextract_param)
(_gcry_sexp_extract_param): this.  Change all callers.  Add support for buffer
descriptors and a path option/

* tests/tsexp.c (die, hex2buffer, hex2mpi, hex2mpiopa): New.
(cmp_mpihex, cmp_bufhex): New.
(check_extract_param): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
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>
ecc: 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-util.c (_gcry_pk_util_parse_flaglist,
  _gcry_pk_util_preparse_sigval): 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.
* tests/curves.c: correct N_CURVES as we now have 2 more curves.

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

Removed some comments from the new curve definitions in ecc-curves.c
to avoid line wrapping.  Eventually we will develop a precompiler to
avoid parsing those hex strings. -wk
Avoid void* pointer arithmetic

* tests/tsexp.c (check_extract_param): Cast void* pointers to char*
before doing arithmetics.
--

GCC was complaining:
tsexp.c: In function ‘check_extract_param’:
tsexp.c:938:44: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
tsexp.c:944:46: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
tsexp.c:955:44: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
tsexp.c:961:46: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
arcfour: more optimized version for non-i386 architectures

* cipher/arcfour.c (ARCFOUR_context): Reorder members.
(do_encrypt_stream) [!__i386__]: Faster implementation for non-i386.
(do_arcfour_setkey): Avoid modulo operations.
--

Patch adds faster arcfour implementation for non-i386 architectures. New code
is not activated on i386 as performance would regress. This is because i386
does not have enough registers hold new variables.

Speed up on Intel i5-4570 (x86_64): 1.56x
Speed up on ARM Cortex-A8: 1.18x

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>