Rework TLS handshake state machine
The current implementation of the TLS handshake state machine consists of huge chunks of switch
statements. This is making it difficult to enhance the code, in particular when any corner case handling is needed.
It would be helpful if that part is rewritten using the State pattern or alike.