proto_read_null_string: alloc space for NULL byte too.
rpc_C_Finalize: Change order of pReserved-check.

This matches the PKCS#11 specification better, and also matches
the test cases for softhsm.
Check pkcs11_initialized in a number of functions.

This harmonizes with the softhsm test suite.
indent
Call C_Finalize when client disconnects.

Necessary to close all ongoing sessions.
More input validation.
proto_read_attribute_array: allow len == 0

Since proto_write_attribute_array() happily writes arrays with len == 0,
we should probably parse them. Tounge in cheek.
proto_read_byte_array: Don't miss n_array when ! valid.

Sending side gck_rpc_message_write_byte_array() adds length data
when valid == 0, so receiving code (this) need to parse that obviosly.
Debug output return values in hex, to match pkcs11.h.
proto_read_byte_array: Don't pass size_t to egg_buffer_get_uint32.

Passing size_t to _get_uint32 might leave garbage in top 32 bits of size_t
on 64 bits platforms. While initializing the size_t to 0 would probably
work, using a temporary uint32_t and casting that is more explicit IMO.
proto_read_byte_buffer: Support undefined buffer size.

A number of PKCS#11 functions take a pointer to a buffer size as
argument. To be a transparent proxy of PKCS#11 calls, it is necessary to
support invoking these functions with a NULL pointer. pkcs11-proxy used
to send the buffer size as an integer and create a pointer to the integer
on the server side, but this is different to the backend PKCS#11 module
in some cases.

E.g. the C_Encrypt call is specified to have side effectes (finalizing)
when called with a NULL encrypted data length. The softhsm test suite
exposed that these side effects never occured because the NULL data length
pointer was conveyed as a valid pointer to the integer zero.

Since an additional uint8_t was added to "byte buffers", this is an
backwards incompatible change. As such, the version number in the protocol
greeting was increased (GCK_RPC_HANDSHAKE).
Check pkcs11_initialized "everywhere".

Since PKCS#11 module initialization is done globally on the server side,
the real PKCS#11 modules check for initialization is made a no-op. The
only place it is possible to check for proper initialization by the
application is here - on the client side.
Remove obsolete input data checks.

Remove a bunch of input data checks now that byte buffers support
NULL data length pointers in order to be as transparent as possible.
rpc_C_GenerateKeyPair: Remove redundant check.
Merge pull request #7 from fredrikt/master

several bug fixes