More KNF.
There is no point in checking if a pointer is non-NULL before calling free,
since free already does this for us. Also remove some pointless NULL
assignments, where the result from malloc(3) is immediately assigned to the
same variable.

ok miod@
EVP_MD_CTX_create() calls malloc and can return NULL. However, only one of
the calls in libssl actually checks the return value before using it. Add
NULL checks for the remaining three calls.

ok miod@
Refactor tls1_change_cipher_state() and split the compression handling out
from the cipher and message digest handling, allowing for upcoming changes.

Based on Adam Langley's chromium diffs.

ok miod@
More KNF.
Add missing NULL checks for calls to ssl_replace_hash(). This function
calls EVP_MD_CTX_create(), which will return NULL if it fails to allocate
memory.

ok miod@
Fix another two cases where the return value of ssl_replace_hash() is
unchecked.

In the case of tls1_change_cipher_state(), it is fairly pointless to use
ssl_replace_hash(), since it does not initialise the hash and there is
special handling required in the DTLS write case. Instead, just inline
the part of ssl_replace_hash() that is needed and only
ssl_clear_hash_ctx() the write hash in the non-DTLS case.

Also add a detailed comment explaining why there needs to be specialised
handling for DTLS write context and where the contexts are actually freed.

ok miod@
When you have functions that perform specific functions, use them.

EVP_CIPHER_CTX_free() does a NULL check, then calls EVP_CIPHER_CTX_cleanup()
and frees the memory. COMP_CTX_free() also had its own NULL check, so there
is no point in duplicating that here.

ok beck@
Make it substantially easier to identify protocol version requirements
by adding an enc_flags field to the ssl3_enc_method, specifying four flags
that are used with this field and providing macros for evaluating these
conditions. Currently the version requirements are identified by
continually checking the version number and other criteria.

This change also adds separate SSL3_ENC_METHOD data for TLS v1.1 and v1.2,
since they have different enc_flags from TLS v1.

Based on changes in OpenSSL head.

No objection from miod@
use calloc, from Benjamin Baier
repair KNF indent
unidef DH, ECDH, and ECDSA. there's no purpose to a libssl without them.
ok deraadt jsing
consistent braces
line up else better
no space before label
kssl is dead.
Any sane platform has stdio. Stop pretending we will ever use a platform
that does not.
"fire bomb" tedu@
Make make includes work again without kssl.h
remove back compat that was already disabled back in 1998.
from Alexander Schrijver
Everything sane has stdio, and FILE *. we don't need ifdefs for this.
ok to firebomb from tedu@