/* * msnp11.c * * New-style challenge * * (c) 2002-2005 Thomas White * Part of TuxMessenger - GTK+-based MSN Messenger client * * This package 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; version 2 dated June, 1991. * * This package 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 package; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * * Special Notice for the MSNP11 Challenge Module * ---------------------------------------------- * The author(s) of this software performed no * reverse-engineering of any Microsoft software * in order to create this module. Information * on the MSNP11-style challenge can be freely * found on the Web. * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "msnp11chl.h" #undef MSNP11CHL_DEBUG uint32_t msnp11chl_tolittle(uint32_t val) { return GINT32_TO_LE(val); } char *msnp11chl_response(const char *challenge) { char *flobbadob; unsigned char *md5; uint64_t words_1[4]; uint64_t words_1_orig[4]; uint32_t *words_2; int nw2; int i; uint64_t low = 0; uint64_t high = 0; uint64_t key; uint64_t hash1; uint64_t hash2; char *response; md5 = malloc(MD5_DIGEST_LENGTH); /* =16 */ flobbadob = malloc(strlen(challenge)+strlen(CLIENT_CODE)+1); strcpy(flobbadob, challenge); strcat(flobbadob, CLIENT_CODE); MD5(flobbadob, strlen(flobbadob), md5); free(flobbadob); /* Split into four-byte words. */ words_1_orig[0] = msnp11chl_tolittle((uint32_t)*(uint32_t *)(md5)); words_1_orig[1] = msnp11chl_tolittle((uint32_t)*(uint32_t *)(md5+4)); words_1_orig[2] = msnp11chl_tolittle((uint32_t)*(uint32_t *)(md5+8)); words_1_orig[3] = msnp11chl_tolittle((uint32_t)*(uint32_t *)(md5+12)); free(md5); for (i=0; i<4; i++) { words_1[i] = words_1_orig[i] & 0x7FFFFFFF; } #ifdef MSNP11CHL_DEBUG printf("words_1[0] = 0x%08lx\n", words_1[0]); printf("words_1[1] = 0x%08lx\n", words_1[1]); printf("words_1[2] = 0x%08lx\n", words_1[2]); printf("words_1[3] = 0x%08lx\n", words_1[3]); #endif /* MSNP11CHL_DEBUG */ flobbadob = malloc(strlen(challenge)+strlen(CLIENT_ID)+9); strcpy(flobbadob, challenge); strcat(flobbadob, CLIENT_ID); while ( strlen(flobbadob) % 8 != 0 ) { strcat(flobbadob, "0"); } /* Split into four-byte words. */ words_2 = malloc(strlen(flobbadob)); memcpy(words_2, flobbadob, strlen(flobbadob)); /* Not including terminator. */ nw2 = strlen(flobbadob)/4; /* = number of members in words_2[] */ free(flobbadob); for (i=0; i