static int vnc_continue_handshake(struct VncState *vs) {

    int ret;



    if ((ret = gnutls_handshake(vs->tls_session)) < 0) {

       if (!gnutls_error_is_fatal(ret)) {

           VNC_DEBUG("Handshake interrupted (blocking)\n");

           if (!gnutls_record_get_direction(vs->tls_session))

               qemu_set_fd_handler(vs->csock, vnc_handshake_io, NULL, vs);

           else

               qemu_set_fd_handler(vs->csock, NULL, vnc_handshake_io, vs);

           return 0;

       }

       VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret));

       vnc_client_error(vs);

       return -1;

    }



    if (vs->vd->x509verify) {

	if (vnc_validate_certificate(vs) < 0) {

	    VNC_DEBUG("Client verification failed\n");

	    vnc_client_error(vs);

	    return -1;

	} else {

	    VNC_DEBUG("Client verification passed\n");

	}

    }



    VNC_DEBUG("Handshake done, switching to TLS data mode\n");

    vs->wiremode = VNC_WIREMODE_TLS;

    qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);



    return start_auth_vencrypt_subauth(vs);

}

static int vnc_continue_handshake(struct VncState *vs) {

    int ret;



    if ((ret = gnutls_handshake(vs->tls_session)) < 0) {

       if (!gnutls_error_is_fatal(ret)) {

           VNC_DEBUG("Handshake interrupted (blocking)\n");

           if (!gnutls_record_get_direction(vs->tls_session))

               qemu_set_fd_handler(vs->csock, vnc_handshake_io, NULL, vs);

           else

               qemu_set_fd_handler(vs->csock, NULL, vnc_handshake_io, vs);

           return 0;

       }

       VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret));

       vnc_client_error(vs);

       return -1;

    }



    if (vs->vd->x509verify) {

	if (vnc_validate_certificate(vs) < 0) {

	    VNC_DEBUG("Client verification failed\n");

	    vnc_client_error(vs);

	    return -1;

	} else {

	    VNC_DEBUG("Client verification passed\n");

	}

    }



    VNC_DEBUG("Handshake done, switching to TLS data mode\n");

    vs->wiremode = VNC_WIREMODE_TLS;

    qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);



    return start_auth_vencrypt_subauth(vs);

}

static int FUNC_0(struct VncState *VAR_0) {

    int VAR_1;



    if ((VAR_1 = gnutls_handshake(VAR_0->tls_session)) < 0) {

       if (!gnutls_error_is_fatal(VAR_1)) {

           VNC_DEBUG("Handshake interrupted (blocking)\n");

           if (!gnutls_record_get_direction(VAR_0->tls_session))

               qemu_set_fd_handler(VAR_0->csock, vnc_handshake_io, NULL, VAR_0);

           else

               qemu_set_fd_handler(VAR_0->csock, NULL, vnc_handshake_io, VAR_0);

           return 0;

       }

       VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(VAR_1));

       vnc_client_error(VAR_0);

       return -1;

    }



    if (VAR_0->vd->x509verify) {

	if (vnc_validate_certificate(VAR_0) < 0) {

	    VNC_DEBUG("Client verification failed\n");

	    vnc_client_error(VAR_0);

	    return -1;

	} else {

	    VNC_DEBUG("Client verification passed\n");

	}

    }



    VNC_DEBUG("Handshake done, switching to TLS data mode\n");

    VAR_0->wiremode = VNC_WIREMODE_TLS;

    qemu_set_fd_handler2(VAR_0->csock, NULL, vnc_client_read, vnc_client_write, VAR_0);



    return start_auth_vencrypt_subauth(VAR_0);

}

static int FUNC_0(struct VncState *VAR_0) { int VAR_1; if ((VAR_1 = gnutls_handshake(VAR_0->tls_session)) < 0) { if (!gnutls_error_is_fatal(VAR_1)) { VNC_DEBUG("Handshake interrupted (blocking)\n"); if (!gnutls_record_get_direction(VAR_0->tls_session))
qemu_set_fd_handler(VAR_0->csock, vnc_handshake_io, NULL, VAR_0); else
qemu_set_fd_handler(VAR_0->csock, NULL, vnc_handshake_io, VAR_0); return 0; } VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(VAR_1)); vnc_client_error(VAR_0); return -1; } if (VAR_0->vd->x509verify) { if (vnc_validate_certificate(VAR_0) < 0) { VNC_DEBUG("Client verification failed\n"); vnc_client_error(VAR_0); return -1; } else { VNC_DEBUG("Client verification passed\n"); } } VNC_DEBUG("Handshake done, switching to TLS data mode\n"); VAR_0->wiremode = VNC_WIREMODE_TLS; qemu_set_fd_handler2(VAR_0->csock, NULL, vnc_client_read, vnc_client_write, VAR_0); return start_auth_vencrypt_subauth(VAR_0); }