--- /dev/null
+--- qemu-kvm/ui/vnc-auth-vencrypt.c 2012-01-17 01:31:17.000000000 +0100
++++ qemu-kvm.new/ui/vnc-auth-vencrypt.c 2012-01-17 01:31:48.000000000 +0100
+@@ -143,6 +143,11 @@
+ vnc_read_when(vs, protocol_client_auth_plain_start, 8);
+ break;
+
++ case VNC_AUTH_VENCRYPT_PLAIN:
++ VNC_DEBUG("Start auth PLAIN\n");
++ vnc_read_when(vs, protocol_client_auth_plain_start, 8);
++ break;
++
+ case VNC_AUTH_VENCRYPT_TLSVNC:
+ case VNC_AUTH_VENCRYPT_X509VNC:
+ VNC_DEBUG("Start TLS auth VNC\n");
+@@ -226,25 +231,32 @@
+ {
+ int auth = read_u32(data, 0);
+
+- if (auth != vs->subauth) {
++ if (auth != vs->subauth && auth != VNC_AUTH_VENCRYPT_PLAIN) {
+ VNC_DEBUG("Rejecting auth %d\n", auth);
+ vnc_write_u8(vs, 0); /* Reject auth */
+ vnc_flush(vs);
+ vnc_client_error(vs);
+ } else {
+- VNC_DEBUG("Accepting auth %d, setting up TLS for handshake\n", auth);
+- vnc_write_u8(vs, 1); /* Accept auth */
+- vnc_flush(vs);
+-
+- if (vnc_tls_client_setup(vs, NEED_X509_AUTH(vs)) < 0) {
+- VNC_DEBUG("Failed to setup TLS\n");
+- return 0;
++ if (auth == VNC_AUTH_VENCRYPT_PLAIN) {
++ vs->subauth = auth;
++ start_auth_vencrypt_subauth(vs);
+ }
+-
+- VNC_DEBUG("Start TLS VeNCrypt handshake process\n");
+- if (vnc_start_vencrypt_handshake(vs) < 0) {
+- VNC_DEBUG("Failed to start TLS handshake\n");
+- return 0;
++ else
++ {
++ VNC_DEBUG("Accepting auth %d, setting up TLS for handshake\n", auth);
++ vnc_write_u8(vs, 1); /* Accept auth */
++ vnc_flush(vs);
++
++ if (vnc_tls_client_setup(vs, NEED_X509_AUTH(vs)) < 0) {
++ VNC_DEBUG("Failed to setup TLS\n");
++ return 0;
++ }
++
++ VNC_DEBUG("Start TLS VeNCrypt handshake process\n");
++ if (vnc_start_vencrypt_handshake(vs) < 0) {
++ VNC_DEBUG("Failed to start TLS handshake\n");
++ return 0;
++ }
+ }
+ }
+ return 0;
+@@ -259,10 +271,11 @@
+ vnc_flush(vs);
+ vnc_client_error(vs);
+ } else {
+- VNC_DEBUG("Sending allowed auth %d\n", vs->subauth);
++ VNC_DEBUG("Sending allowed auths %d %d\n", vs->subauth, VNC_AUTH_VENCRYPT_PLAIN);
+ vnc_write_u8(vs, 0); /* Accept version */
+- vnc_write_u8(vs, 1); /* Number of sub-auths */
++ vnc_write_u8(vs, 2); /* Number of sub-auths */
+ vnc_write_u32(vs, vs->subauth); /* The supported auth */
++ vnc_write_u32(vs, VNC_AUTH_VENCRYPT_PLAIN); /* Alternative supported auth */
+ vnc_flush(vs);
+ vnc_read_when(vs, protocol_client_vencrypt_auth, 4);
+ }
+--
+1.7.2.5
+