TLS protocol: add handshake state validation