ia64/xen-unstable

changeset 16270:5cc6a30faf69

qemu vnc auth 2/4: Revert current VNC auth support

This patch reverts the current Xen specific implementation of VNC
authentication from the QEMU code. This is basically reverting
11840:02506a744315. The idea here is to get the VNC code back to more
closely match upstream QEMU, before applying the upstream auth
patches.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
author Keir Fraser <keir@xensource.com>
date Tue Oct 30 09:24:17 2007 +0000 (2007-10-30)
parents d25ab83a89e3
children f7026f931e60
files tools/ioemu/Makefile.target tools/ioemu/d3des.c tools/ioemu/d3des.h tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/vnc.c tools/ioemu/xenstore.c
line diff
     1.1 --- a/tools/ioemu/Makefile.target	Tue Oct 30 09:22:27 2007 +0000
     1.2 +++ b/tools/ioemu/Makefile.target	Tue Oct 30 09:24:17 2007 +0000
     1.3 @@ -457,7 +457,6 @@ ifdef CONFIG_SDL
     1.4  VL_OBJS+=sdl.o x_keymap.o
     1.5  endif
     1.6  VL_OBJS+=vnc.o
     1.7 -VL_OBJS+=d3des.o
     1.8  ifdef CONFIG_COCOA
     1.9  VL_OBJS+=cocoa.o
    1.10  COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
    1.11 @@ -518,9 +517,6 @@ sdl.o: sdl.c keymaps.c sdl_keysym.h
    1.12  vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h
    1.13  	$(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
    1.14  
    1.15 -d3des.o: d3des.c d3des.h
    1.16 -	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
    1.17 -
    1.18  sdlaudio.o: sdlaudio.c
    1.19  	$(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
    1.20  
     2.1 --- a/tools/ioemu/d3des.c	Tue Oct 30 09:22:27 2007 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,434 +0,0 @@
     2.4 -/*
     2.5 - * This is D3DES (V5.09) by Richard Outerbridge with the double and
     2.6 - * triple-length support removed for use in VNC.  Also the bytebit[] array
     2.7 - * has been reversed so that the most significant bit in each byte of the
     2.8 - * key is ignored, not the least significant.
     2.9 - *
    2.10 - * These changes are:
    2.11 - *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
    2.12 - *
    2.13 - * This software is distributed in the hope that it will be useful,
    2.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    2.16 - */
    2.17 -
    2.18 -/* D3DES (V5.09) -
    2.19 - *
    2.20 - * A portable, public domain, version of the Data Encryption Standard.
    2.21 - *
    2.22 - * Written with Symantec's THINK (Lightspeed) C by Richard Outerbridge.
    2.23 - * Thanks to: Dan Hoey for his excellent Initial and Inverse permutation
    2.24 - * code;  Jim Gillogly & Phil Karn for the DES key schedule code; Dennis
    2.25 - * Ferguson, Eric Young and Dana How for comparing notes; and Ray Lau,
    2.26 - * for humouring me on.
    2.27 - *
    2.28 - * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge.
    2.29 - * (GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992.
    2.30 - */
    2.31 -
    2.32 -#include "d3des.h"
    2.33 -
    2.34 -static void scrunch(unsigned char *, unsigned long *);
    2.35 -static void unscrun(unsigned long *, unsigned char *);
    2.36 -static void desfunc(unsigned long *, unsigned long *);
    2.37 -static void cookey(unsigned long *);
    2.38 -
    2.39 -static unsigned long KnL[32] = { 0L };
    2.40 -
    2.41 -static unsigned short bytebit[8]	= {
    2.42 -	01, 02, 04, 010, 020, 040, 0100, 0200 };
    2.43 -
    2.44 -static unsigned long bigbyte[24] = {
    2.45 -	0x800000L,	0x400000L,	0x200000L,	0x100000L,
    2.46 -	0x80000L,	0x40000L,	0x20000L,	0x10000L,
    2.47 -	0x8000L,	0x4000L,	0x2000L,	0x1000L,
    2.48 -	0x800L, 	0x400L, 	0x200L, 	0x100L,
    2.49 -	0x80L,		0x40L,		0x20L,		0x10L,
    2.50 -	0x8L,		0x4L,		0x2L,		0x1L	};
    2.51 -
    2.52 -/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
    2.53 -
    2.54 -static unsigned char pc1[56] = {
    2.55 -	56, 48, 40, 32, 24, 16,  8,	 0, 57, 49, 41, 33, 25, 17,
    2.56 -	 9,  1, 58, 50, 42, 34, 26,	18, 10,  2, 59, 51, 43, 35,
    2.57 -	62, 54, 46, 38, 30, 22, 14,	 6, 61, 53, 45, 37, 29, 21,
    2.58 -	13,  5, 60, 52, 44, 36, 28,	20, 12,  4, 27, 19, 11,  3 };
    2.59 -
    2.60 -static unsigned char totrot[16] = {
    2.61 -	1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
    2.62 -
    2.63 -static unsigned char pc2[48] = {
    2.64 -	13, 16, 10, 23,  0,  4,  2, 27, 14,  5, 20,  9,
    2.65 -	22, 18, 11,  3, 25,  7, 15,  6, 26, 19, 12,  1,
    2.66 -	40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
    2.67 -	43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 };
    2.68 -
    2.69 -void deskey(key, edf)	/* Thanks to James Gillogly & Phil Karn! */
    2.70 -unsigned char *key;
    2.71 -int edf;
    2.72 -{
    2.73 -	register int i, j, l, m, n;
    2.74 -	unsigned char pc1m[56], pcr[56];
    2.75 -	unsigned long kn[32];
    2.76 -
    2.77 -	for ( j = 0; j < 56; j++ ) {
    2.78 -		l = pc1[j];
    2.79 -		m = l & 07;
    2.80 -		pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0;
    2.81 -		}
    2.82 -	for( i = 0; i < 16; i++ ) {
    2.83 -		if( edf == DE1 ) m = (15 - i) << 1;
    2.84 -		else m = i << 1;
    2.85 -		n = m + 1;
    2.86 -		kn[m] = kn[n] = 0L;
    2.87 -		for( j = 0; j < 28; j++ ) {
    2.88 -			l = j + totrot[i];
    2.89 -			if( l < 28 ) pcr[j] = pc1m[l];
    2.90 -			else pcr[j] = pc1m[l - 28];
    2.91 -			}
    2.92 -		for( j = 28; j < 56; j++ ) {
    2.93 -		    l = j + totrot[i];
    2.94 -		    if( l < 56 ) pcr[j] = pc1m[l];
    2.95 -		    else pcr[j] = pc1m[l - 28];
    2.96 -		    }
    2.97 -		for( j = 0; j < 24; j++ ) {
    2.98 -			if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
    2.99 -			if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
   2.100 -			}
   2.101 -		}
   2.102 -	cookey(kn);
   2.103 -	return;
   2.104 -	}
   2.105 -
   2.106 -static void cookey(raw1)
   2.107 -register unsigned long *raw1;
   2.108 -{
   2.109 -	register unsigned long *cook, *raw0;
   2.110 -	unsigned long dough[32];
   2.111 -	register int i;
   2.112 -
   2.113 -	cook = dough;
   2.114 -	for( i = 0; i < 16; i++, raw1++ ) {
   2.115 -		raw0 = raw1++;
   2.116 -		*cook	 = (*raw0 & 0x00fc0000L) << 6;
   2.117 -		*cook	|= (*raw0 & 0x00000fc0L) << 10;
   2.118 -		*cook	|= (*raw1 & 0x00fc0000L) >> 10;
   2.119 -		*cook++ |= (*raw1 & 0x00000fc0L) >> 6;
   2.120 -		*cook	 = (*raw0 & 0x0003f000L) << 12;
   2.121 -		*cook	|= (*raw0 & 0x0000003fL) << 16;
   2.122 -		*cook	|= (*raw1 & 0x0003f000L) >> 4;
   2.123 -		*cook++ |= (*raw1 & 0x0000003fL);
   2.124 -		}
   2.125 -	usekey(dough);
   2.126 -	return;
   2.127 -	}
   2.128 -
   2.129 -void cpkey(into)
   2.130 -register unsigned long *into;
   2.131 -{
   2.132 -	register unsigned long *from, *endp;
   2.133 -
   2.134 -	from = KnL, endp = &KnL[32];
   2.135 -	while( from < endp ) *into++ = *from++;
   2.136 -	return;
   2.137 -	}
   2.138 -
   2.139 -void usekey(from)
   2.140 -register unsigned long *from;
   2.141 -{
   2.142 -	register unsigned long *to, *endp;
   2.143 -
   2.144 -	to = KnL, endp = &KnL[32];
   2.145 -	while( to < endp ) *to++ = *from++;
   2.146 -	return;
   2.147 -	}
   2.148 -
   2.149 -void des(inblock, outblock)
   2.150 -unsigned char *inblock, *outblock;
   2.151 -{
   2.152 -	unsigned long work[2];
   2.153 -
   2.154 -	scrunch(inblock, work);
   2.155 -	desfunc(work, KnL);
   2.156 -	unscrun(work, outblock);
   2.157 -	return;
   2.158 -	}
   2.159 -
   2.160 -static void scrunch(outof, into)
   2.161 -register unsigned char *outof;
   2.162 -register unsigned long *into;
   2.163 -{
   2.164 -	*into	 = (*outof++ & 0xffL) << 24;
   2.165 -	*into	|= (*outof++ & 0xffL) << 16;
   2.166 -	*into	|= (*outof++ & 0xffL) << 8;
   2.167 -	*into++ |= (*outof++ & 0xffL);
   2.168 -	*into	 = (*outof++ & 0xffL) << 24;
   2.169 -	*into	|= (*outof++ & 0xffL) << 16;
   2.170 -	*into	|= (*outof++ & 0xffL) << 8;
   2.171 -	*into	|= (*outof   & 0xffL);
   2.172 -	return;
   2.173 -	}
   2.174 -
   2.175 -static void unscrun(outof, into)
   2.176 -register unsigned long *outof;
   2.177 -register unsigned char *into;
   2.178 -{
   2.179 -	*into++ = (unsigned char)((*outof >> 24) & 0xffL);
   2.180 -	*into++ = (unsigned char)((*outof >> 16) & 0xffL);
   2.181 -	*into++ = (unsigned char)((*outof >>  8) & 0xffL);
   2.182 -	*into++ = (unsigned char)(*outof++	 & 0xffL);
   2.183 -	*into++ = (unsigned char)((*outof >> 24) & 0xffL);
   2.184 -	*into++ = (unsigned char)((*outof >> 16) & 0xffL);
   2.185 -	*into++ = (unsigned char)((*outof >>  8) & 0xffL);
   2.186 -	*into	=  (unsigned char)(*outof	 & 0xffL);
   2.187 -	return;
   2.188 -	}
   2.189 -
   2.190 -static unsigned long SP1[64] = {
   2.191 -	0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
   2.192 -	0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
   2.193 -	0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
   2.194 -	0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L,
   2.195 -	0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L,
   2.196 -	0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L,
   2.197 -	0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L,
   2.198 -	0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
   2.199 -	0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L,
   2.200 -	0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L,
   2.201 -	0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L,
   2.202 -	0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L,
   2.203 -	0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
   2.204 -	0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
   2.205 -	0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
   2.206 -	0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L };
   2.207 -
   2.208 -static unsigned long SP2[64] = {
   2.209 -	0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
   2.210 -	0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
   2.211 -	0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
   2.212 -	0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L,
   2.213 -	0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L,
   2.214 -	0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L,
   2.215 -	0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L,
   2.216 -	0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
   2.217 -	0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L,
   2.218 -	0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L,
   2.219 -	0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L,
   2.220 -	0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L,
   2.221 -	0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
   2.222 -	0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
   2.223 -	0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
   2.224 -	0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L };
   2.225 -
   2.226 -static unsigned long SP3[64] = {
   2.227 -	0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
   2.228 -	0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
   2.229 -	0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
   2.230 -	0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L,
   2.231 -	0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L,
   2.232 -	0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L,
   2.233 -	0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L,
   2.234 -	0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
   2.235 -	0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L,
   2.236 -	0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L,
   2.237 -	0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L,
   2.238 -	0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L,
   2.239 -	0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
   2.240 -	0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
   2.241 -	0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
   2.242 -	0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L };
   2.243 -
   2.244 -static unsigned long SP4[64] = {
   2.245 -	0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
   2.246 -	0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
   2.247 -	0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
   2.248 -	0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L,
   2.249 -	0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L,
   2.250 -	0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L,
   2.251 -	0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L,
   2.252 -	0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
   2.253 -	0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L,
   2.254 -	0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L,
   2.255 -	0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L,
   2.256 -	0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
   2.257 -	0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
   2.258 -	0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
   2.259 -	0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
   2.260 -	0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L };
   2.261 -
   2.262 -static unsigned long SP5[64] = {
   2.263 -	0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
   2.264 -	0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
   2.265 -	0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
   2.266 -	0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L,
   2.267 -	0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L,
   2.268 -	0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L,
   2.269 -	0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L,
   2.270 -	0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
   2.271 -	0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L,
   2.272 -	0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L,
   2.273 -	0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L,
   2.274 -	0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L,
   2.275 -	0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
   2.276 -	0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
   2.277 -	0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
   2.278 -	0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L };
   2.279 -
   2.280 -static unsigned long SP6[64] = {
   2.281 -	0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
   2.282 -	0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
   2.283 -	0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
   2.284 -	0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L,
   2.285 -	0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L,
   2.286 -	0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L,
   2.287 -	0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L,
   2.288 -	0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
   2.289 -	0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L,
   2.290 -	0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L,
   2.291 -	0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L,
   2.292 -	0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L,
   2.293 -	0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
   2.294 -	0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
   2.295 -	0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
   2.296 -	0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L };
   2.297 -
   2.298 -static unsigned long SP7[64] = {
   2.299 -	0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
   2.300 -	0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
   2.301 -	0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
   2.302 -	0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L,
   2.303 -	0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L,
   2.304 -	0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L,
   2.305 -	0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L,
   2.306 -	0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
   2.307 -	0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L,
   2.308 -	0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L,
   2.309 -	0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L,
   2.310 -	0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L,
   2.311 -	0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
   2.312 -	0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
   2.313 -	0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
   2.314 -	0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L };
   2.315 -
   2.316 -static unsigned long SP8[64] = {
   2.317 -	0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
   2.318 -	0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
   2.319 -	0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
   2.320 -	0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L,
   2.321 -	0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L,
   2.322 -	0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L,
   2.323 -	0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L,
   2.324 -	0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
   2.325 -	0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L,
   2.326 -	0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L,
   2.327 -	0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L,
   2.328 -	0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L,
   2.329 -	0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
   2.330 -	0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
   2.331 -	0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
   2.332 -	0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
   2.333 -
   2.334 -static void desfunc(block, keys)
   2.335 -register unsigned long *block, *keys;
   2.336 -{
   2.337 -	register unsigned long fval, work, right, leftt;
   2.338 -	register int round;
   2.339 -
   2.340 -	leftt = block[0];
   2.341 -	right = block[1];
   2.342 -	work = ((leftt >> 4) ^ right) & 0x0f0f0f0fL;
   2.343 -	right ^= work;
   2.344 -	leftt ^= (work << 4);
   2.345 -	work = ((leftt >> 16) ^ right) & 0x0000ffffL;
   2.346 -	right ^= work;
   2.347 -	leftt ^= (work << 16);
   2.348 -	work = ((right >> 2) ^ leftt) & 0x33333333L;
   2.349 -	leftt ^= work;
   2.350 -	right ^= (work << 2);
   2.351 -	work = ((right >> 8) ^ leftt) & 0x00ff00ffL;
   2.352 -	leftt ^= work;
   2.353 -	right ^= (work << 8);
   2.354 -	right = ((right << 1) | ((right >> 31) & 1L)) & 0xffffffffL;
   2.355 -	work = (leftt ^ right) & 0xaaaaaaaaL;
   2.356 -	leftt ^= work;
   2.357 -	right ^= work;
   2.358 -	leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL;
   2.359 -
   2.360 -	for( round = 0; round < 8; round++ ) {
   2.361 -		work  = (right << 28) | (right >> 4);
   2.362 -		work ^= *keys++;
   2.363 -		fval  = SP7[ work		 & 0x3fL];
   2.364 -		fval |= SP5[(work >>  8) & 0x3fL];
   2.365 -		fval |= SP3[(work >> 16) & 0x3fL];
   2.366 -		fval |= SP1[(work >> 24) & 0x3fL];
   2.367 -		work  = right ^ *keys++;
   2.368 -		fval |= SP8[ work		 & 0x3fL];
   2.369 -		fval |= SP6[(work >>  8) & 0x3fL];
   2.370 -		fval |= SP4[(work >> 16) & 0x3fL];
   2.371 -		fval |= SP2[(work >> 24) & 0x3fL];
   2.372 -		leftt ^= fval;
   2.373 -		work  = (leftt << 28) | (leftt >> 4);
   2.374 -		work ^= *keys++;
   2.375 -		fval  = SP7[ work		 & 0x3fL];
   2.376 -		fval |= SP5[(work >>  8) & 0x3fL];
   2.377 -		fval |= SP3[(work >> 16) & 0x3fL];
   2.378 -		fval |= SP1[(work >> 24) & 0x3fL];
   2.379 -		work  = leftt ^ *keys++;
   2.380 -		fval |= SP8[ work		 & 0x3fL];
   2.381 -		fval |= SP6[(work >>  8) & 0x3fL];
   2.382 -		fval |= SP4[(work >> 16) & 0x3fL];
   2.383 -		fval |= SP2[(work >> 24) & 0x3fL];
   2.384 -		right ^= fval;
   2.385 -		}
   2.386 -
   2.387 -	right = (right << 31) | (right >> 1);
   2.388 -	work = (leftt ^ right) & 0xaaaaaaaaL;
   2.389 -	leftt ^= work;
   2.390 -	right ^= work;
   2.391 -	leftt = (leftt << 31) | (leftt >> 1);
   2.392 -	work = ((leftt >> 8) ^ right) & 0x00ff00ffL;
   2.393 -	right ^= work;
   2.394 -	leftt ^= (work << 8);
   2.395 -	work = ((leftt >> 2) ^ right) & 0x33333333L;
   2.396 -	right ^= work;
   2.397 -	leftt ^= (work << 2);
   2.398 -	work = ((right >> 16) ^ leftt) & 0x0000ffffL;
   2.399 -	leftt ^= work;
   2.400 -	right ^= (work << 16);
   2.401 -	work = ((right >> 4) ^ leftt) & 0x0f0f0f0fL;
   2.402 -	leftt ^= work;
   2.403 -	right ^= (work << 4);
   2.404 -	*block++ = right;
   2.405 -	*block = leftt;
   2.406 -	return;
   2.407 -	}
   2.408 -
   2.409 -/* Validation sets:
   2.410 - *
   2.411 - * Single-length key, single-length plaintext -
   2.412 - * Key	  : 0123 4567 89ab cdef
   2.413 - * Plain  : 0123 4567 89ab cde7
   2.414 - * Cipher : c957 4425 6a5e d31d
   2.415 - *
   2.416 - * Double-length key, single-length plaintext -
   2.417 - * Key	  : 0123 4567 89ab cdef fedc ba98 7654 3210
   2.418 - * Plain  : 0123 4567 89ab cde7
   2.419 - * Cipher : 7f1d 0a77 826b 8aff
   2.420 - *
   2.421 - * Double-length key, double-length plaintext -
   2.422 - * Key	  : 0123 4567 89ab cdef fedc ba98 7654 3210
   2.423 - * Plain  : 0123 4567 89ab cdef 0123 4567 89ab cdff
   2.424 - * Cipher : 27a0 8440 406a df60 278f 47cf 42d6 15d7
   2.425 - *
   2.426 - * Triple-length key, single-length plaintext -
   2.427 - * Key	  : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567
   2.428 - * Plain  : 0123 4567 89ab cde7
   2.429 - * Cipher : de0b 7c06 ae5e 0ed5
   2.430 - *
   2.431 - * Triple-length key, double-length plaintext -
   2.432 - * Key	  : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567
   2.433 - * Plain  : 0123 4567 89ab cdef 0123 4567 89ab cdff
   2.434 - * Cipher : ad0d 1b30 ac17 cf07 0ed1 1c63 81e4 4de5
   2.435 - *
   2.436 - * d3des V5.0a rwo 9208.07 18:44 Graven Imagery
   2.437 - **********************************************************************/
     3.1 --- a/tools/ioemu/d3des.h	Tue Oct 30 09:22:27 2007 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,51 +0,0 @@
     3.4 -/*
     3.5 - * This is D3DES (V5.09) by Richard Outerbridge with the double and
     3.6 - * triple-length support removed for use in VNC.
     3.7 - *
     3.8 - * These changes are:
     3.9 - *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
    3.10 - *
    3.11 - * This software is distributed in the hope that it will be useful,
    3.12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    3.14 - */
    3.15 -
    3.16 -/* d3des.h -
    3.17 - *
    3.18 - *	Headers and defines for d3des.c
    3.19 - *	Graven Imagery, 1992.
    3.20 - *
    3.21 - * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
    3.22 - *	(GEnie : OUTER; CIS : [71755,204])
    3.23 - */
    3.24 -
    3.25 -#define EN0	0	/* MODE == encrypt */
    3.26 -#define DE1	1	/* MODE == decrypt */
    3.27 -
    3.28 -extern void deskey(unsigned char *, int);
    3.29 -/*		      hexkey[8]     MODE
    3.30 - * Sets the internal key register according to the hexadecimal
    3.31 - * key contained in the 8 bytes of hexkey, according to the DES,
    3.32 - * for encryption or decryption according to MODE.
    3.33 - */
    3.34 -
    3.35 -extern void usekey(unsigned long *);
    3.36 -/*		    cookedkey[32]
    3.37 - * Loads the internal key register with the data in cookedkey.
    3.38 - */
    3.39 -
    3.40 -extern void cpkey(unsigned long *);
    3.41 -/*		   cookedkey[32]
    3.42 - * Copies the contents of the internal key register into the storage
    3.43 - * located at &cookedkey[0].
    3.44 - */
    3.45 -
    3.46 -extern void des(unsigned char *, unsigned char *);
    3.47 -/*		    from[8]	      to[8]
    3.48 - * Encrypts/Decrypts (according to the key currently loaded in the
    3.49 - * internal key register) one block of eight bytes at address 'from'
    3.50 - * into the block at address 'to'.  They can be the same.
    3.51 - */
    3.52 -
    3.53 -/* d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery
    3.54 - ********************************************************************/
     4.1 --- a/tools/ioemu/vl.c	Tue Oct 30 09:22:27 2007 +0000
     4.2 +++ b/tools/ioemu/vl.c	Tue Oct 30 09:24:17 2007 +0000
     4.3 @@ -196,9 +196,6 @@ int xc_handle;
     4.4  char domain_name[64] = "Xen-no-name";
     4.5  extern int domid;
     4.6  
     4.7 -char vncpasswd[64];
     4.8 -unsigned char challenge[AUTHCHALLENGESIZE];
     4.9 -
    4.10  /***********************************************************/
    4.11  /* x86 ISA bus support */
    4.12  
    4.13 @@ -7037,7 +7034,6 @@ int main(int argc, char **argv)
    4.14      vncunused = 0;
    4.15      kernel_filename = NULL;
    4.16      kernel_cmdline = "";
    4.17 -    *vncpasswd = '\0';
    4.18  #ifndef CONFIG_DM
    4.19  #ifdef TARGET_PPC
    4.20      cdrom_index = 1;
    4.21 @@ -7682,10 +7678,6 @@ int main(int argc, char **argv)
    4.22  
    4.23      init_ioports();
    4.24  
    4.25 -    /* read vncpasswd from xenstore */
    4.26 -    if (0 > xenstore_read_vncpasswd(domid))
    4.27 -        exit(1);
    4.28 -
    4.29      /* terminal init */
    4.30      if (nographic) {
    4.31          dumb_display_init(ds);
     5.1 --- a/tools/ioemu/vl.h	Tue Oct 30 09:22:27 2007 +0000
     5.2 +++ b/tools/ioemu/vl.h	Tue Oct 30 09:24:17 2007 +0000
     5.3 @@ -1453,7 +1453,7 @@ void xenstore_process_event(void *opaque
     5.4  void xenstore_record_dm_state(char *state);
     5.5  void xenstore_check_new_media_present(int timeout);
     5.6  void xenstore_write_vncport(int vnc_display);
     5.7 -int xenstore_read_vncpasswd(int domid);
     5.8 +int xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen);
     5.9  
    5.10  int xenstore_domain_has_devtype(struct xs_handle *handle,
    5.11                                  const char *devtype);
    5.12 @@ -1490,9 +1490,6 @@ extern char domain_name[];
    5.13  
    5.14  void destroy_hvm_domain(void);
    5.15  
    5.16 -/* VNC Authentication */
    5.17 -#define AUTHCHALLENGESIZE 16
    5.18 -
    5.19  #ifdef __ia64__
    5.20  static inline void xc_domain_shutdown_hook(int xc_handle, uint32_t domid)
    5.21  {
     6.1 --- a/tools/ioemu/vnc.c	Tue Oct 30 09:22:27 2007 +0000
     6.2 +++ b/tools/ioemu/vnc.c	Tue Oct 30 09:24:17 2007 +0000
     6.3 @@ -47,7 +47,6 @@
     6.4  
     6.5  #include "vnc_keysym.h"
     6.6  #include "keymaps.c"
     6.7 -#include "d3des.h"
     6.8  
     6.9  typedef struct Buffer
    6.10  {
    6.11 @@ -164,9 +163,6 @@ static void _vnc_update_client(void *opa
    6.12  static void vnc_update_client(void *opaque);
    6.13  static void vnc_client_read(void *opaque);
    6.14  static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h);
    6.15 -static int make_challenge(unsigned char *random, int size);
    6.16 -static void set_seed(unsigned int *seedp);
    6.17 -static void get_random(int len, unsigned char *buf);
    6.18  
    6.19  #if 0
    6.20  static inline void vnc_set_bit(uint32_t *d, int k)
    6.21 @@ -1387,96 +1383,28 @@ static int protocol_client_init(VncState
    6.22      return 0;
    6.23  }
    6.24  
    6.25 -static int protocol_response(VncState *vs, uint8_t *client_response, size_t len)
    6.26 -{
    6.27 -    extern char vncpasswd[64];
    6.28 -    extern unsigned char challenge[AUTHCHALLENGESIZE];
    6.29 -    unsigned char cryptchallenge[AUTHCHALLENGESIZE];
    6.30 -    unsigned char key[8];
    6.31 -    int passwdlen, i, j;
    6.32 -
    6.33 -    memcpy(cryptchallenge, challenge, AUTHCHALLENGESIZE);
    6.34  
    6.35 -    /* Calculate the sent challenge */
    6.36 -    passwdlen = strlen(vncpasswd);
    6.37 -    for (i=0; i<8; i++)
    6.38 -	key[i] = i<passwdlen ? vncpasswd[i] : 0;
    6.39 -    deskey(key, EN0);
    6.40 -    for (j = 0; j < AUTHCHALLENGESIZE; j += 8)
    6.41 -	des(cryptchallenge+j, cryptchallenge+j);
    6.42 +static int protocol_version(VncState *vs, uint8_t *version, size_t len)
    6.43 +{
    6.44 +    char local[13];
    6.45 +    int maj, min;
    6.46  
    6.47 -    /* Check the actual response */
    6.48 -    if (memcmp(cryptchallenge, client_response, AUTHCHALLENGESIZE) != 0) {
    6.49 -	/* password error */
    6.50 -	vnc_write_u32(vs, 1);
    6.51 -	vnc_write_u32(vs, 22);
    6.52 -	vnc_write(vs, "Authentication failure", 22);
    6.53 -	vnc_flush(vs);
    6.54 -	fprintf(stderr, "VNC Password error.\n");
    6.55 +    memcpy(local, version, 12);
    6.56 +    local[12] = 0;
    6.57 +
    6.58 +    if (sscanf(local, "RFB %03d.%03d\n", &maj, &min) != 2) {
    6.59  	vnc_client_error(vs);
    6.60  	return 0;
    6.61      }
    6.62  
    6.63 -    vnc_write_u32(vs, 0);
    6.64 +    vnc_write_u32(vs, 1); /* None */
    6.65      vnc_flush(vs);
    6.66 -
    6.67 +  
    6.68      vnc_read_when(vs, protocol_client_init, 1);
    6.69  
    6.70      return 0;
    6.71  }
    6.72  
    6.73 -static int protocol_version(VncState *vs, uint8_t *version, size_t len)
    6.74 -{
    6.75 -    extern char vncpasswd[64];
    6.76 -    extern unsigned char challenge[AUTHCHALLENGESIZE];
    6.77 -    char local[13];
    6.78 -    int  support, maj, min;
    6.79 -
    6.80 -    memcpy(local, version, 12);
    6.81 -    local[12] = 0;
    6.82 -
    6.83 -    /* protocol version check */
    6.84 -    if (sscanf(local, "RFB %03d.%03d\n", &maj, &min) != 2) {
    6.85 -	fprintf(stderr, "Protocol version error.\n");
    6.86 -	vnc_client_error(vs);
    6.87 -	return 0;
    6.88 -    }
    6.89 -
    6.90 -
    6.91 -    support = 0;
    6.92 -    if (maj == 3) {
    6.93 -	if (min == 3 || min ==4) {
    6.94 -	    support = 1;
    6.95 -	}
    6.96 -    }
    6.97 -
    6.98 -    if (! support) {
    6.99 -	fprintf(stderr, "Client uses unsupported protocol version %d.%d.\n",
   6.100 -		maj, min);
   6.101 -	vnc_client_error(vs);
   6.102 -	return 0;
   6.103 -    }
   6.104 -
   6.105 -    if (*vncpasswd == '\0') {
   6.106 -	/* AuthType is None */
   6.107 -	vnc_write_u32(vs, 1);
   6.108 -	vnc_flush(vs);
   6.109 -	vnc_read_when(vs, protocol_client_init, 1);
   6.110 -    } else {
   6.111 -	/* AuthType is VncAuth */
   6.112 -	vnc_write_u32(vs, 2);
   6.113 -
   6.114 -	/* Challenge-Responce authentication */
   6.115 -	/* Send Challenge */
   6.116 -	make_challenge(challenge, AUTHCHALLENGESIZE);
   6.117 -	vnc_write(vs, challenge, AUTHCHALLENGESIZE);
   6.118 -	vnc_flush(vs);
   6.119 -	vnc_read_when(vs, protocol_response, AUTHCHALLENGESIZE);
   6.120 -    }
   6.121 -
   6.122 -    return 0;
   6.123 -}
   6.124 -
   6.125  static void vnc_listen_read(void *opaque)
   6.126  {
   6.127      VncState *vs = opaque;
   6.128 @@ -1640,31 +1568,3 @@ int vnc_start_viewer(int port)
   6.129      }
   6.130  }
   6.131  
   6.132 -unsigned int seed;
   6.133 -
   6.134 -static int make_challenge(unsigned char *random, int size)
   6.135 -{
   6.136 - 
   6.137 -    set_seed(&seed);
   6.138 -    get_random(size, random);
   6.139 -
   6.140 -    return 0;
   6.141 -}
   6.142 -
   6.143 -static void set_seed(unsigned int *seedp)
   6.144 -{
   6.145 -    *seedp += (unsigned int)(time(NULL)+getpid()+getpid()*987654+rand());
   6.146 -    srand(*seedp);
   6.147 -
   6.148 -    return;
   6.149 -}
   6.150 -
   6.151 -static void get_random(int len, unsigned char *buf)
   6.152 -{
   6.153 -    int i;
   6.154 -
   6.155 -    for (i=0; i<len; i++)
   6.156 -	buf[i] = (int) (256.0*rand()/(RAND_MAX+1.0));
   6.157 -
   6.158 -    return;
   6.159 -}
     7.1 --- a/tools/ioemu/xenstore.c	Tue Oct 30 09:22:27 2007 +0000
     7.2 +++ b/tools/ioemu/xenstore.c	Tue Oct 30 09:24:17 2007 +0000
     7.3 @@ -488,9 +488,8 @@ void xenstore_write_vncport(int display)
     7.4      free(buf);
     7.5  }
     7.6  
     7.7 -int xenstore_read_vncpasswd(int domid)
     7.8 +int xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen)
     7.9  {
    7.10 -    extern char vncpasswd[64];
    7.11      char *buf = NULL, *path, *uuid = NULL, *passwd = NULL;
    7.12      unsigned int i, len, rc = 0;
    7.13  
    7.14 @@ -521,11 +520,11 @@ int xenstore_read_vncpasswd(int domid)
    7.15          return rc;
    7.16      }
    7.17  
    7.18 -    for (i=0; i<len && i<63; i++) {
    7.19 -        vncpasswd[i] = passwd[i];
    7.20 -        passwd[i] = '\0';
    7.21 +    for (i=0; i<len && i<pwbuflen; i++) {
    7.22 +        pwbuf[i] = passwd[i];
    7.23      }
    7.24 -    vncpasswd[len] = '\0';
    7.25 +    pwbuf[len < (pwbuflen-1) ? len : (pwbuflen-1)] = '\0';
    7.26 +    passwd[0] = '\0';
    7.27      pasprintf(&buf, "%s/vncpasswd", uuid);
    7.28      if (xs_write(xsh, XBT_NULL, buf, passwd, len) == 0) {
    7.29          fprintf(logfile, "xs_write() vncpasswd failed.\n");