comparison src/proxy.c @ 10684:72a5babfa8b4

[gaim-migrate @ 12231] the cipher api that grim has been working on for ages is finally done!! big congrats and thanks to him!! lots of modified files in this commit. it builds here. moved the md5 files to src/protocols/oscar so that it continues to depend on nothing in gaim. everything else uses the new centralized cipher api. I'm not sure if src/md5.* needs to be removed or not, so I left it there. someone let me know or do it directly. someone check if these need to be added to potfiles.in and let there be much rejoicing! committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 11 Mar 2005 13:05:31 +0000
parents 06f5cc17cddc
children b256ce6b85b8
comparison
equal deleted inserted replaced
10683:e11f3e1599d4 10684:72a5babfa8b4
28 /* it is intended to : 1st handle http proxy, using the CONNECT command 28 /* it is intended to : 1st handle http proxy, using the CONNECT command
29 , 2nd provide an easy way to add socks support 29 , 2nd provide an easy way to add socks support
30 , 3rd draw women to it like flies to honey */ 30 , 3rd draw women to it like flies to honey */
31 31
32 #include "internal.h" 32 #include "internal.h"
33 #include "cipher.h"
33 #include "debug.h" 34 #include "debug.h"
34 #include "notify.h" 35 #include "notify.h"
35 #include "prefs.h" 36 #include "prefs.h"
36 #include "proxy.h" 37 #include "proxy.h"
37 #include "util.h" 38 #include "util.h"
38 #include "md5.h"
39 39
40 static GaimProxyInfo *global_proxy_info = NULL; 40 static GaimProxyInfo *global_proxy_info = NULL;
41 41
42 struct PHB { 42 struct PHB {
43 GaimInputFunction func; 43 GaimInputFunction func;
1359 s5_sendconnect(phb, source); 1359 s5_sendconnect(phb, source);
1360 } 1360 }
1361 1361
1362 static void hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) 1362 static void hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response)
1363 { 1363 {
1364 GaimCipher *cipher;
1365 GaimCipherContext *ctx;
1364 int i; 1366 int i;
1365 unsigned char Kxoripad[65]; 1367 unsigned char Kxoripad[65];
1366 unsigned char Kxoropad[65]; 1368 unsigned char Kxoropad[65];
1367 md5_state_t ctx;
1368 int pwlen; 1369 int pwlen;
1369 char * pwinput; 1370 char * pwinput;
1370 char md5buf[16]; 1371 char md5buf[16];
1371 1372
1373 cipher = gaim_ciphers_find_cipher("md5");
1374 ctx = gaim_cipher_context_new(cipher, NULL);
1375
1372 pwinput=(char *)passwd; 1376 pwinput=(char *)passwd;
1373 pwlen=strlen(passwd); 1377 pwlen=strlen(passwd);
1374 if (pwlen>64) { 1378 if (pwlen>64) {
1375 md5_init(&ctx); 1379 gaim_cipher_context_append(ctx, passwd, strlen(passwd));
1376 md5_append(&ctx, (unsigned char *)passwd, strlen(passwd)); 1380 gaim_cipher_context_digest(ctx, NULL, md5buf);
1377 md5_finish(&ctx, (unsigned char *)md5buf);
1378 pwinput=(char *)md5buf; 1381 pwinput=(char *)md5buf;
1379 pwlen=16; 1382 pwlen=16;
1380 } 1383 }
1381 1384
1382 memset(Kxoripad,0,sizeof(Kxoripad)); 1385 memset(Kxoripad,0,sizeof(Kxoripad));
1385 memcpy(Kxoropad,pwinput,pwlen); 1388 memcpy(Kxoropad,pwinput,pwlen);
1386 for (i=0;i<64;i++) { 1389 for (i=0;i<64;i++) {
1387 Kxoripad[i]^=0x36; 1390 Kxoripad[i]^=0x36;
1388 Kxoropad[i]^=0x5c; 1391 Kxoropad[i]^=0x5c;
1389 } 1392 }
1390 md5_init(&ctx); 1393
1391 md5_append(&ctx, Kxoripad, 64); 1394 gaim_cipher_context_reset(ctx, NULL);
1392 md5_append(&ctx, challenge, challen); 1395 gaim_cipher_context_append(ctx, Kxoripad, 64);
1393 md5_finish(&ctx, (unsigned char *)Kxoripad); 1396 gaim_cipher_context_append(ctx, challenge, challen);
1394 1397 gaim_cipher_context_digest(ctx, NULL, Kxoripad);
1395 md5_init(&ctx); 1398
1396 md5_append(&ctx, Kxoropad, 64); 1399 gaim_cipher_context_reset(ctx, NULL);
1397 md5_append(&ctx, Kxoripad, 16); 1400 gaim_cipher_context_append(ctx, Kxoropad, 64);
1398 md5_finish(&ctx, response); 1401 gaim_cipher_context_append(ctx, Kxoripad, 16);
1402 gaim_cipher_context_digest(ctx, NULL, response);
1403
1404 gaim_cipher_context_destroy(ctx);
1399 } 1405 }
1400 1406
1401 static void 1407 static void
1402 s5_readchap(gpointer data, gint source, GaimInputCondition cond) 1408 s5_readchap(gpointer data, gint source, GaimInputCondition cond)
1403 { 1409 {