From 302cfb332b0ebf5aa8f0c958796366de87ed52fd Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 24 Nov 2003 16:08:41 +0000 Subject: [PATCH] The decrypting of messages based on IP moved to decrypt_message(). --- server.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/server.c b/server.c index 96ce68d..00d07a2 100644 --- a/server.c +++ b/server.c @@ -807,6 +807,25 @@ static int init() /*************************************************************************/ +static void +decrypt_message(char *buf, char *newbuf, char *iphashbuf) +{ + int j, c, l = strlen(iphashbuf); + + c = xtoi(buf); + for (j = 2; buf[j] && buf[j+1]; j += 2) { + int temp, d; + + temp = d = xtoi(buf+j); + d ^= iphashbuf[((j/2)-1) % l]; + d += 255 - c; + d %= 255; + newbuf[j/2-1] = d; + c = temp; + } + newbuf[j/2-1] = 0; +} + static void check_sockets() { fd_set fds; @@ -896,7 +915,6 @@ static void check_sockets() #else int hashval; #endif - int j, c, d; if (strlen(buf) < 2*13) { /* "tetrisstart " + initial byte */ close(fd); @@ -915,17 +933,7 @@ static void check_sockets() for (hashval = 0; hashval < 35956; hashval++) { sprintf(iphashbuf, "%d", hashval); #endif - c = xtoi(buf); - for (j = 2; buf[j] && buf[j+1]; j += 2) { - int temp; - temp = d = xtoi(buf+j); - d ^= iphashbuf[((j/2)-1) % strlen(iphashbuf)]; - d += 255 - c; - d %= 255; - newbuf[j/2-1] = d; - c = temp; - } - newbuf[j/2-1] = 0; + decrypt_message(buf, newbuf, iphashbuf); #ifndef NO_BRUTE_FORCE_DECRYPTION if(strncmp(newbuf,"tetrisstart ",12) == 0) break; -- 2.11.4.GIT