Commit this before the head-scratching leads to premature baldness:
    memset(a->data, 0, (unsigned int)a->max);
but the decl is:
    size_t max;
size_t could be larger than int, especially in some of the systems OpenSSL
purports to support.

How do _intentionally truncating_ casts like enter into a codebase?
Lack of understanding of C, at a minimum.  Generally the objects are
small, but this code is _intentionally unready_ for large objects.
ok miod
There is no need for is{upper,lower}() tests before to{lower,uppper}(),
since all other characters are mapped through transparently.
ok jsing
In tls1_setup_key_block(), use the correct IV length for GCM mode, which
results in the key block length calculation also being correct. Rename a
number of variables so that their purpose becomes clear and simplify some
of the code.

Inspired by Adam Langley's chromium diffs.

ok miod@
Overhaul the key block handling in tls1_change_cipher_state() - use
meaningful variable names with pointer arithmitic, rather than n, i, j
and p with array indexing.

Based on Adam Langley's chromium diffs.

ok miod@