Do handshake processing. Type is one of HANDSHAKE_*, data is the
contents of the packet, and raw is the raw packet received (needed
for supporting SSLv2 hello messages).
This function returns 0 if hadshake is in progress, 1 if handshake
is finished, and -1 if a fatal error occured. It uses the
send_packet() function to trasnmit packets.