Since this is a library, place issetugid() before every getenv()
ok miod
Fix memory leak.

Thanks to Brenk Cook.

OK from miod@
Actually make BIO_set_tcp_ndelay() work - TCP_NODELAY will not magically
appear by itself.

ok beck@ miod@
Replace 48 lines of code with a single inet_pton() call. The previous
handrolled version could not even make use of sscanf(), since that would
not work with a certain antiquated compiler.

It is worth noting that there is a tiny change in behaviour - previously
calling BIO_get_host_ip() with something that looked like it might be a
valid IP address (for example, "1." or even ".") would result in it
returning failure rather than trying a BIO_gethostbyname() - now we'll
always try a BIO_gethostbyname() if it was not a valid IPv4 address.

ok beck@ miod@ deraadt@
Some KNF.
If a chacha operation does not consume all of the generated key stream,
ensure that we save it and consume it on subsequent writes. Otherwise we
end up discarding part of the key stream and instead generate a new block
at the start of the next write.

This was only an issue for callers that did multiple writes that are not
multiples of 64 bytes - in particular, the ChaCha20Poly1305 usage does not
hit this problem since it performs encryption in a single-shot. For the
same reason, this is also a non-issue when openssl(1) is used to encrypt
with ChaCha.

Issue identified by insane coder; reported to bugs@ by Joseph M. Schwartz.

ok beck@
Remove BIO_f_reliable(), guilty of playing with EVP_MD_CTX internals it
should not know anything about. Verified not to be used in ports; riding upon
the recent libcrypto major bump.
Remove ancient workaround for previous century's compilers in the declaration
of CRYPTO_EX_DATA; riding upon the libcrypto major bump.
Remove previously commented out wrong code, as well as the comment saying this
is incorrect code.
Unifdef -UNO_SYS_TYPES_H
fix type string conversion warning

ASN1_STRING_data returns an unsigned char *, but strlcat's second
parameter is a const char *
remove unused static datastructures

Neither of these is used anywhere within their object files.
Check output of write() to stdout
add missing stdint. include for uint32_t, etc.
remove typecasts on password_callback

Rather than casting password_callback to the correct function pointer
signature at every call site, change it to match the signature instead.
replace malloc(strlen())/strlcpy with strdup

clang complains that we are using len(src) as the length field for
strlcpy. Note that this is just an open-coded strdup anyway.
include <limits.h> for LONG_MIN/LONG_MAX