import of OpenSSL 0.9.8h
KNF.
repair some KNF missed by the script; ok jsing
KNF.
Use C99 initialisers for BIO_METHOD.
Implement an improved version of the EVP AEAD API. The
EVP_AEAD_CTX_{open,seal} functions previously returned an ssize_t that was
overloaded to indicate success/failure, along with the number of bytes
written as output. This change adds an explicit *out_len argument which
is used to return the number of output bytes and the return value is now
an int that is purely used to identify success or failure.

This change effectively rides the last libcrypto crank (although I do not
expect there to be many users of the EVP AEAD API currently).

Thanks to Adam Langley for providing the improved code that this diff is
based on.

ok miod@
There is no need to include <openssl/e_os2.h> here, except for the fact
that it brings in <openssl/opensslconf.h>, so just do that instead
(currently via apps.h).
Make sure all error paths in dtls1_buffer_record() invoke SSLErr by
factoring error handling.

ok jsing@
tls_decrypt_ticket(): memory leak and uncleaned EVP_CIPHER_CTX upon error.
We don't really to keep history in constructs such as:

#if 1 /* new with openssl 0.9.4 */
current code;
#else
obsolete code;
#endif
Unchecked malloc() return value in SSL_COMP_add_compression_method(), in the
!OPENSSL_NO_COMP case. Does not affect OpenBSD as we compile the opposite code
path.
Replace the following logic:

        if (nothing to allocate)
                ptr = malloc(1)
        else {
                if ((ptr = malloc(size to allocate))
                        memcpy(ptr, data to copy, size to allocate)
        }

        if (ptr == NULL)
                OMG ERROR

with a saner logic where the NULL pointer check if moved to the actual
malloc branch, so that we do not need to malloc a single byte, just to avoid
having a NULL pointer.

Whoever thought allocating a single byte was a smart idea was obviously
not taking his meds.

ok beck@ guenther@
initialize variable that can be used uninitialized

If EVP_DecryptInit_ex() returns NULL, j is incremented by a random amount.

clang warning:
pem/pem_lib.c:472:6: error: variable 'i' is used uninitialized whenever 'if' condition is false
      [-Werror,-Wsometimes-uninitialized]
        if (o)
            ^
pem/pem_lib.c:479:7: note: uninitialized use occurs here
        j += i;
             ^
pem/pem_lib.c:472:2: note: remove the 'if' if its condition is always true
        if (o)
        ^~~~~~
pem/pem_lib.c:446:7: note: initialize the variable 'i' to silence this warning
        int i, j, o, klen;
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.
do not include public headers as though they are local

Avoid having to use -I trickery to find public header files included as
though they are private.
do not pretend to support -rand in apps

Remove support for parsing the unused -rand option and the unused random
buffer variables.
use BIO_write instead of an unchecked write()

write() warns if its return value is unchecked. Replace with a BIO_write
like all of the surrounding code uses anyway.
sort out pqueue moving to a private interface

 adjust include
 avoid duplication of pqueue typedef