static int protocol_client_vencrypt_init(VncState *vs, uint8_t *data, size_t len)

{

    if (data[0] != 0 ||

        data[1] != 2) {

        VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)data[0], (int)data[1]);

        vnc_write_u8(vs, 1); /* Reject version */

        vnc_flush(vs);

        vnc_client_error(vs);

    } else {

        VNC_DEBUG("Sending allowed auth %d\n", vs->vd->subauth);

        vnc_write_u8(vs, 0); /* Accept version */

        vnc_write_u8(vs, 1); /* Number of sub-auths */

        vnc_write_u32(vs, vs->vd->subauth); /* The supported auth */

        vnc_flush(vs);

        vnc_read_when(vs, protocol_client_vencrypt_auth, 4);

    }

    return 0;

}

static int protocol_client_vencrypt_init(VncState *vs, uint8_t *data, size_t len)

{

    if (data[0] != 0 ||

        data[1] != 2) {

        VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)data[0], (int)data[1]);

        vnc_write_u8(vs, 1); 

        vnc_flush(vs);

        vnc_client_error(vs);

    } else {

        VNC_DEBUG("Sending allowed auth %d\n", vs->vd->subauth);

        vnc_write_u8(vs, 0); 

        vnc_write_u8(vs, 1); 

        vnc_write_u32(vs, vs->vd->subauth); 

        vnc_flush(vs);

        vnc_read_when(vs, protocol_client_vencrypt_auth, 4);

    }

    return 0;

}

static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)

{

    if (VAR_1[0] != 0 ||

        VAR_1[1] != 2) {

        VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)VAR_1[0], (int)VAR_1[1]);

        vnc_write_u8(VAR_0, 1); 

        vnc_flush(VAR_0);

        vnc_client_error(VAR_0);

    } else {

        VNC_DEBUG("Sending allowed auth %d\n", VAR_0->vd->subauth);

        vnc_write_u8(VAR_0, 0); 

        vnc_write_u8(VAR_0, 1); 

        vnc_write_u32(VAR_0, VAR_0->vd->subauth); 

        vnc_flush(VAR_0);

        vnc_read_when(VAR_0, protocol_client_vencrypt_auth, 4);

    }

    return 0;

}

static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)
{ if (VAR_1[0] != 0 ||
VAR_1[1] != 2) { VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)VAR_1[0], (int)VAR_1[1]); vnc_write_u8(VAR_0, 1); vnc_flush(VAR_0); vnc_client_error(VAR_0); } else { VNC_DEBUG("Sending allowed auth %d\n", VAR_0->vd->subauth); vnc_write_u8(VAR_0, 0); vnc_write_u8(VAR_0, 1); vnc_write_u32(VAR_0, VAR_0->vd->subauth); vnc_flush(VAR_0); vnc_read_when(VAR_0, protocol_client_vencrypt_auth, 4); } return 0; }