cipher: Fix possible NULL dereference.

* cipher/md.c (_gcry_md_selftest): Check for spec being NULL.
--

Also removed left-over code in unused file cipher/test-getrusage.c.

Found by Hans-Christoph Steiner with cppcheck.
pubkey: Re-map all depreccated RSA algo numbers.

* cipher/pubkey.c (map_algo): Mape RSA_E and RSA_S.
random: Small patch for consistency and really burn the stack.

* random/rndlinux.c (_gcry_rndlinux_gather_random): s/int/size_t/.
(_gcry_rndlinux_gather_random): Replace memset by wipememory.
--

size_t was suggested by Marcus Meissner <meissner@suse.de>.  While
looking at the code I identified the useless (i.e. likely optimized
away) memset.
Bump LT version.

* configure.ac: Bumb LT version to C21/A1/R0.
--

This is to avoid conflicts with the 1.6 series.  Note that if we add a
new interface to 1.6 we would need to bump age again.
Drop automake-installed files

Drop files that are provided by automake. They are better to be in sync
with automake used.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Update .gitingore to ignore more files

* .gitignore: add more tests, temporary files, etc to the list of
ignored files.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Implement GOST 28147-89 "gammirovanie" mode

* cipher/Makefile.am, cipher/cipher-internal.h,
 cipher/cipher-ofbgost.c cipher/cipher.c src/gcrypt.h.in: GOST 28147-89
 declares special mode named "gammirovanie". It looks mostly like OFB
 mode, except that encrypted cipherstream is processed a little bit
 more. Implement it as a generic encryption mode (like it is done for
 AESWRAP).
* doc/gcrypt.texi: document GCRY_CIPHER_MODE_OFBGOST.

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

start adding ofbgost checks

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

OFBGOST improvements

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

OFBGOST -> CNTGOST

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

cntgost

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Fixup tests ordering for new automake

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>
gost 34.11-94 add OIDs

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
gost28147: add OIDs used to define cipher mode

* cipher/gost28147 (oids_gost28147): New.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
cipher/gost28147: generate optimized s-boxes from compact ones

* cipher/gost-s-box.c: New. Outputs optimized expanded representation of
  s-boxes (4x256) from compact 16x8 representation.
* cipher/Makefile.am: Add gost-sb.h dependency to gost28147.lo
* cipher/gost.h: Add sbox to the GOST28147_context structure.
* cipher/gost28147.c (gost_setkey): Set default s-box to test s-box from
  GOST R 34.11 (this was the only one S-box before).
* cipher/gost28147.c (gost_val): Use sbox from the context.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Support setting s-box for the ciphers that require it

* src/gcrypt.h.in (GCRYCTL_SET_SBOX, gcry_cipher_set_sbox): New.
* cipher/cipher.c (_gcry_cipher_ctl): pass GCRYCTL_SET_SBOX to
  set_extra_info callback.

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

cipher/gost28147.c (gost_set_extra_info, gost_set_sbox): New.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Add GOST R 34.11-94 variant using id-GostR3411-94-CryptoProParamSet

* src/gcrypt.h.in (GCRY_MD_GOSTR3411_CP): New.
* src/cipher.h (_gcry_digest_spec_gost3411_cp): New.
* cipher/gost28147.c (_gcry_gost_enc_one): Differentiate between
  CryptoPro and Test S-Boxes.
* cipher/gostr3411-94.c (_gcry_digest_spec_gost3411_cp,
  gost3411_cp_init): New.
* cipher/md.c (md_open): GCRY_MD_GOSTR3411_CP also uses B=32.

--
RFC4357 defines only two S-Boxes that should be used together with
GOST R 34.11-94 - a testing one (from standard itself, for testing only)
and CryptoPro one. Instead of adding a separate gcry_md_ctrl() function
just to switch s-boxes, add a separate MD algorithm using CryptoPro
S-box.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Update PBKDF2 tests with GOST R 34.11-94 test cases

* tests/t-kdf.c (check_pbkdf2): Add MD_GOSTR3411_CP test cases.

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

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Add Stribog OIDs from TC26 space

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
XXX: Add PBKDF2 tests for Stribog512 - failing for now

* tests/t-kdf.c (check_pbkdf2): Add Stribog512 test cases.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
XXX: ECC: GOST interprets numbers as LE, so we need to adapt

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