diff --git a/vnc/Makefile b/vnc/Makefile index b94673e2..82b126f9 100644 --- a/vnc/Makefile +++ b/vnc/Makefile @@ -1,6 +1,7 @@ -VNCOBJ = ../common/os_calls.o vnc.o ../common/d3des.o vncauth.o +VNCOBJ = vnc.o os_calls.o d3des.o CFLAGS = -Wall -O2 -I../common +C_OS_FLAGS = $(CFLAGS) -c LDFLAGS = -shared LIBS = -ldl CC = gcc @@ -12,3 +13,9 @@ vnc: $(VNCOBJ) clean: rm -f $(VNCOBJ) libvnc.so + +os_calls.o: + $(CC) $(C_OS_FLAGS) ../common/os_calls.c + +d3des.o: + $(CC) $(C_OS_FLAGS) ../common/d3des.c diff --git a/vnc/vnc.c b/vnc/vnc.c index 2a62ba5e..375c8c11 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -22,6 +22,20 @@ #include "vnc.h" +/******************************************************************************/ +/* taken from vncauth.c */ +void rfbEncryptBytes(char* bytes, char* passwd) +{ + char key[12]; + + /* key is simply password padded with nulls */ + g_memset(key, 0, sizeof(key)); + g_strncpy(key, passwd, 8); + rfbDesKey((unsigned char*)key, EN0); /* 0, encrypt */ + rfbDes((unsigned char*)bytes, (unsigned char*)bytes); + rfbDes((unsigned char*)(bytes + 8), (unsigned char*)(bytes + 8)); +} + /******************************************************************************/ /* returns error */ int lib_recv(struct vnc* v, char* data, int len) @@ -849,7 +863,7 @@ int lib_mod_connect(struct vnc* v) error = lib_recv(v, s->data, 16); if (error == 0) { - rfbEncryptBytes((unsigned char*)s->data, v->password); + rfbEncryptBytes(s->data, v->password); error = lib_send(v, s->data, 16); } } diff --git a/vnc/vnc.h b/vnc/vnc.h index cd7a1aa5..e7ea0ba1 100644 --- a/vnc/vnc.h +++ b/vnc/vnc.h @@ -24,8 +24,7 @@ #include "arch.h" #include "parse.h" #include "os_calls.h" - -void rfbEncryptBytes(unsigned char *bytes, char *passwd); +#include "d3des.h" struct vnc { diff --git a/vnc/vncauth.c b/vnc/vncauth.c deleted file mode 100644 index e2d4b97c..00000000 --- a/vnc/vncauth.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. - * - * This is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -/* - * vncauth.c - Functions for VNC password management and authentication. - */ - -/* - stripped down Jay Sorg for xrdp -*/ - -#include -#include -#include -#include "d3des.h" -#include -#include - - -void rfbEncryptBytes(unsigned char *bytes, char *passwd) -{ - unsigned char key[8]; - unsigned int i; - - /* key is simply password padded with nulls */ - - for (i = 0; i < 8; i++) { - if (i < strlen(passwd)) { - key[i] = passwd[i]; - } else { - key[i] = 0; - } - } - - rfbDesKey(key, EN0); - - for (i = 0; i < 16; i += 8) { - rfbDes(bytes+i, bytes+i); - } -}