Move automake conditionals added by commit d512b25f out of Makefile.inc

Commit d512b25f69a1b6778881f6b4b5ff9cfc6023be42 added automake
conditionals to Makefile.inc but since Makefile.inc is included
from Makefile for all other build systems that does not work.

This commit instead adds Makefile.OpenSSL.inc and Makefile.libgcrypt.inc
and moves the automake conditional to its proper place, src/Makefile.am.

The automake conditional includes the correct Makefile.$name.inc per
the crypto library selection/detection done by configure.

All non-autotools build system files in libssh2 are hardcoded to use
OpenSSL and do not get a conditional but at least there is some reuse
because they can all include the new Makefile.OpenSSL.inc.
.gitignore: Ignore files like src/libssh2_config.h.in~
openssl: initialise the digest context before calling EVP_DigestInit()

When using the OpenSSL libraries in FIPS mode, the function call
EVP_DigestInit() is actually #defined to FIPS_digestinit().
Unfortunately wheres EVP_DigestInit() initialises the context and then
calls EVP_DigestInit_ex(), this function assumes that the context has
been pre-initialised and crashes when it isn't.

Bug: https://trac.libssh2.org/ticket/279

Fixes #279
Fix missing `_libssh2_error` in `_libssh2_channel_write`.

In one case, the error code from `_libssh2_transport_read` was being returned from `_libssh2_channel_write` without setting it as the last error by calling `_libssh2_error`.  This commit fixes that.

Found when using a session whose socket had been inadvertently destroyed.  The calling code got confused because via `libssh2_session_last_error` it appeared no error had occurred, despite one being returned from the previous function.
Fixed two potential use-after-frees of the payload buffer

The first might occur if _libssh2_packet_add returns an error, as
fullpacket_state wasn't reset to idle so if it were possible for
fullpacket to be called again, it would return to the same state
handler and re-use the freed p->packet buffer.

The second could occur if decrypt returned an error, as it freed the
packet buffer but did not clear total_num, meaning that freed buffer
could be written into again later.
Fixed a few memory leaks in error paths
userauth: Fixed an attempt to free from stack on error
Fixed a few typos
agent_list_identities: Fixed memory leak on OOM
knownhosts: Abort if the hosts buffer is too small

This could otherwise cause a match on the wrong host
knownhost: Fix DSS keys being detected as unknown.

I missing `else` meant ssh-dss format keys were being re-detected as unknown format.
knownhost: Restore behaviour of `libssh2_knownhost_writeline` with short buffer.

Commit 85c6627c changed the behaviour of `libssh2_knownhost_writeline` so that it stopped returning the number of bytes needed when the given buffer was too small.  Also, the function changed such that is might write to part of the buffer before realising it is too small.

This commit restores the original behaviour, whilst keeping the unknown-key-type functionality that 85c6627c.  Instead of writing to the buffer piecemeal, the length of the various parts is calculated up front and the buffer written only if there is enough space.  The calculated necessary size is output in `outlen` regardless of whether the buffer was written to.

The main use-case for the original behaviour that this commit restores is to allow passing in a NULL buffer to get the actual buffer size needed, before calling the function again with the buffer allocated to the exact size required.
sftp_close_handle: ensure the handle is always closed

Errors are reported on return, but otherwise the close path is
completed as much as possible and the handle is freed on exit.
channel_close: Close the channel even in the case of errors
Fix non-autotools builds: Always define the LIBSSH2_OPENSSL CPP macro

Commit d512b25f69a1b6778881f6b4b5ff9cfc6023be42 introduced a crypto
library abstraction in the autotools build system, to allow us to more
easily support new crypto libraries. In that process it was found that
all other build system which we support are hard-coded to build with
OpenSSL. Commit f5c1a0d98bd51aeb24aca3d49c7c81dcf8bd858d fixes automake
introduced into non-autotools build systems but still overlooked the
CPP macro saying that we are using OpenSSL.

Thanks to Marc Hörsken for identifying this issue and proposing a fix
for win32/{GNUmakefile,config.mk}. This commit uses a slightly different
approach but the end result is the same.
pem.c: always compile pem.c independently of crypto backend
knownhost.c: fixed that 'key_type_len' may be used uninitialized

../src/knownhost.c: In function 'libssh2_knownhost_readline':
../src/knownhost.c:651:16: warning: 'key_type_len' may be used
uninitialized in this function [-Wmaybe-uninitialized]
             rc = knownhost_add(hosts, hostbuf, NULL,
                ^
../src/knownhost.c:745:12: note: 'key_type_len' was declared here
     size_t key_type_len;
            ^
Added Windows Cryptography API: Next Generation based backend
publickey_packet_receive: avoid junk in returned pointers

clang-analyzer found this risk it would return a non-initialized pointer
in a success case
channel_receive_window_adjust: store windows size always

Avoid it sometimes returning without storing it, leaving calling
functions with unknown content!

Detected by clang-analyzer