refactored openssl's tls1_process_heartbeat