Fix possible segv if NULL is passed as cert.

* src/cert.c (ksba_cert_get_digest_algo): Fix !cert case.
--

Found by Hans-Christoph Steiner with cppcheck.
tests: Fix warning about unused var.

* tests/t-dnparser.c (main): Drop unneeded var INPUTLEN.
Update gpl.texi to build with current texinfo

* gpl.texi: Fix sections nears the end of numbered GPL part.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Merge _ksba_keyinfo_to_sexp into cryptval_to_sexp

* src/keyinfo.c (cryptval_to_sexp): Add mode 2 support suitable to
  replace parse keyinfo data.
* src/keyinfo.c (_ksba_keyinfo_to_sexp): Use new cryptval_to_sexp
  mode dedicated to keyinfo parsing.

--
_ksba_keyinfo_to_sexp and cryptval_to_sexp share lots of common code.
Merge them to be less error prone.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Merge functions that convert from sexp to der

* src/keyinfo.c (cryptval_from_sexp): New. Contains code merged from
  _ksba_keyinfo_from_sexp and _ksba_algoinfo_from_sexp functions.
* src/keyinfo.c (_ksba_algoinfo_from_sexp, _ksba_keyinfo_from_sexp): Use
  cryptval_from_sexp function.

Merge two functions translating S-expressions to DER representation.
They share great amount of code, so merge is benefitable.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Drop outdated missing script

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Fix print_sexp and print_sexp_hex

* tests/t-common.h (print_sexp, print_sexp_hex): advance pointer on
  closing brace.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Reuse common test functions in cert-basic test

* tests/cert-basic.c (xmalloc, print_hex, print_sexp, print_time,
  print_dn): Drop.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
tests: Pass -no-install to libtool

* tests/Makefile.am: add AM_LDFLAGS = -no-install

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
cryptval_to_sexp: add ability to skip the element in DER

* src/keyinfo.c (cryptval_to_sexp): if elem points to underscore skip
  the current DER element.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Add function to parse private key information

* src/keyinfo.c (privkey_algo_table): Add a table with private key
  description.
* src/keyinfo.c (cryptval_to_sexp): Add mode 3 that parses private keys
  according to privkey_algo_table.
* src/keyinfo.c (_ksba_privkey_to_sexp): Parse der via cryptval_to_sexp.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Add PKCS#8 private key parsing support

* src/ksba.h (ksba_priv_key_s, ksba_priv_key_t): New.
* src/privkey.c: New.
* src/tmttv2.asn (PrivateKeyInfo, PrivateKey): Add from RFC 5208.
* src/visibility.c (ksba_priv_key_new, ksba_priv_key_release,
  ksba_priv_key_parse_der, ksba_priv_key_get_private_key): New.
* tests/t-privkey.c: Simple information dumper for private keys.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Enable optional valgrind for testsuite

* configure.ac: Enable gnulib valgrind module.
* gl/m4/gnulib.m4: Enable valgrind module.
* tests/Makefile.am: Enable valgrind as LOG_COMPILER.
* gl/m4/valgrind-tests.m4: New

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Fix two memory leaks in cert-basic test

* tests/cert-basic.c (one_file): add/move xfree calls to always free
  allocated memory.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Adapt mkoidtbl script to newer dumpasn1 database format

* tests/mkoidtbl.awk: optionally parse oid at OID line.

--

Debian jessie currently has dumpasn1 version 20130608-1. It uses
dumpasn1.cfg with slightly different format:

OID = 0 2 262 1 10
Comment = Deutsche Telekom
Description = Telesec

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Fix memory leak in crl parsing code.

* src/crl.c (store_one_entry_extension): Free memory at oid variable -
  otherwise libksba leaks memory on crl parsing.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Don't add dummy extension, if certificate contained no extensions

* src/cert.c (read_extensions): Handle a case where ASN parser added
  explicit empty extension as if there were no extensions at all.

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

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Add initial Gost support

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