Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 174802
Collapse All | Expand All

(-)xsupplicant-1.2.8/etc/xsupplicant.conf (+6 lines)
Lines 160-165 Link Here
160
# turning off encryption and turning control over to iwconfig.
160
# turning off encryption and turning control over to iwconfig.
161
default
161
default
162
{
162
{
163
	allow_types = eap-md5
164
 	identity = "Your account name" # Replace your account name. 
165
	 eap-md5 {
166
      		username = "Your account name" # Replace your account name again:)
167
      		password = "Your password"   # If the password has spaces, quote it.
168
		}
163
}
169
}
164
170
165
my_network
171
my_network
(-)xsupplicant-1.2.8/src/eap.c (+567 lines)
Lines 91-96 Link Here
91
#include <sys/socket.h>
91
#include <sys/socket.h>
92
#include <sys/un.h>
92
#include <sys/un.h>
93
#include <unistd.h>
93
#include <unistd.h>
94
#include <sys/ioctl.h>  
95
#include <net/if.h>  
96
#include <net/if_arp.h>  
97
#include <arpa/inet.h>  
98
#include <errno.h>  
99
#include <linux/netlink.h>
100
#include <linux/rtnetlink.h>
101
94
102
95
#include "snmp.h"
103
#include "snmp.h"
96
#include "frame_structs.h"
104
#include "frame_structs.h"
Lines 126-131 Link Here
126
#include <efence.h>
134
#include <efence.h>
127
#endif
135
#endif
128
136
137
138
uint8_t md5rec[16];
139
char DNS[20];
140
141
129
struct eap_type_handler {
142
struct eap_type_handler {
130
  int eap_auth_type;
143
  int eap_auth_type;
131
  char *eapname;
144
  char *eapname;
Lines 137-142 Link Here
137
  int (*eap_auth_cleanup)(struct generic_eap_data *);
150
  int (*eap_auth_cleanup)(struct generic_eap_data *);
138
};
151
};
139
152
153
154
140
struct eap_type_handler eaphandlers[] = {
155
struct eap_type_handler eaphandlers[] = {
141
  {EAP_TYPE_MD5, "EAP_MD5", eapmd5_setup, eapmd5_process, eapmd5_get_keys,
156
  {EAP_TYPE_MD5, "EAP_MD5", eapmd5_setup, eapmd5_process, eapmd5_get_keys,
142
   eapmd5_failed, eapmd5_cleanup},
157
   eapmd5_failed, eapmd5_cleanup},
Lines 308-319 Link Here
308
323
309
      eapol_build_header(EAP_PACKET, eapsize, eapolver, (char *) thisint->sendframe);
324
      eapol_build_header(EAP_PACKET, eapsize, eapolver, (char *) thisint->sendframe);
310
      thisint->send_size = eapsize+OFFSET_TO_EAP;
325
      thisint->send_size = eapsize+OFFSET_TO_EAP;
326
      if(ruijie_op==1)
327
      {
328
        append_rgtail(thisint);   //by acevery, for Red Gaint Facilities.
329
      }
311
      return XENONE;
330
      return XENONE;
312
    }
331
    }
313
332
314
  debug_printf(DEBUG_INT, "No response frame was built!\n");
333
  debug_printf(DEBUG_INT, "No response frame was built!\n");
315
  return XENOFRAMES;
334
  return XENOFRAMES;
316
}
335
}
336
 
337
/*************************************************
338
 * 
339
 * Append Red Gaint tail to each response data,
340
 *                                   by acevery
341
 * 
342
 *************************************************/
343
  
344
void append_rgtail(struct interface_data *thisint)
345
{
346
	int i;
347
	uint8_t rgsig[144] ={
348
	// 0 --> 22
349
	0x00,0x00,0x13,0x11, // Encode( 0x00,0x00,0x13,0x11 ) Ruijie OEM Mark
350
	0x01, // Encode( 0x01/00 )
351
	0x00,0x00,0x00,0x00, // Encode( IP )
352
	0x00,0x00,0x00,0x00, // Encode( SubNetMask )
353
	0x00,0x00,0x00,0x00, // Encode( NetGate )
354
	0x00,0x00,0x00,0x00, // Encode( DNS )
355
	0x00,0x00, // Checksum( )
356
	// 23 --> 58
357
	0x00,0x00,0x13,0x11,0x38,0x30,0x32,0x31,0x78,0x2e,0x65,0x78,0x65,0x00,0x00,0x00, // ASCII 8021x.exe
358
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //
359
	0x00,0x00,0x00,0x00,
360
	// 59 --> 77
361
	0x02,0x38,0x00,0x00, // 8021x.exe File Version (2.56)
362
	0x00, // unknow flag
363
	0x00,0x00,0x13,0x11,0x00,0x4a,0x1a,0x28,0x00,0x00,0x13,0x11,0x17,0x22, // Const strings
364
	// 78 --> 120
365
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, 
366
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, // 32bytes spc. Random strings
367
	0x1a,0x0c,0x00,0x00,0x13,0x11,0x18,0x06,0x00,0x00,0x00, // Const strings
368
	// 121
369
	0x01, // DHCP and first time flag
370
	// V2.56 (and upper?) added
371
	// 122 -->
372
	0x1a,0x0e,0x00,0x00,0x13,0x11,0x2d,0x08, // Const strings
373
	// 130 --> 135
374
	0x00,0x00,0x00,0x00,0x00,0x00, // True NIC MAC
375
	// 136--> 143
376
	0x1a,0x08,0x00,0x00,0x13,0x11,0x2f,0x02 // Const strings
377
	};
378
	// 1 , we fill in the Network Parameters part:
379
	// 0 --> 20   +   121
380
	if(getNP(thisint, &rgsig[RJ_IP_OFFSET], IP)==-1)
381
	{
382
		debug_printf(DEBUG_EVERYTHING,"The %s is not up, we don't get Network Parameters for Authentication.\n",thisint->intName);
383
		for(i=0;i<16;i++)
384
		{
385
			rgsig[RJ_IP_OFFSET+i]=0x00;
386
		}
387
		rgsig[RJ_DHCP_OFFSET]=0x01;
388
	}
389
	else 
390
	{
391
		debug_printf(DEBUG_EVERYTHING,"The %s is up, we will get Network Parameters for Authentication.\n",thisint->intName);
392
		debug_printf(DEBUG_NORMAL,"Trying to get Netmask.\n");
393
		if(getNP(thisint, &rgsig[RJ_NM_OFFSET], NM)==-1)
394
		{
395
			debug_printf(DEBUG_NORMAL,"Couldn't get subNetmask!\n");
396
		}
397
		debug_printf(DEBUG_NORMAL,"Trying to get Gateway.\n");
398
		if(gotRoute(&rgsig[RJ_GW_OFFSET])!=0)
399
		{
400
			debug_printf(DEBUG_NORMAL,"Couldn't get Gateway!\n");
401
		}
402
		debug_printf(DEBUG_NORMAL,"Trying to get DNS.\n");
403
		if(gotDNS(&rgsig[RJ_DNS_OFFSET])!=0)
404
		{
405
			debug_printf(DEBUG_NORMAL,"Couldn't get DNS!\n");
406
		}
407
		rgsig[RJ_DHCP_OFFSET]=0x00;
408
	}
409
410
	// 2 , we calculate the Checksum of the Network Parameters.
411
	//  21 --> 22
412
	checksumNP(rgsig,&rgsig[RJ_CS_OFFSET]);
413
414
	// 3 , we Encode the Network Parameter in Ruijie's algorithm.
415
	//  0 -- > 22
416
	for(i=0;i<23;i++)
417
	{
418
		rgsig[i]=encodeNP(rgsig[i]);
419
	}
420
	
421
	// 4 , we generate the sepecial 32 byte Hash
422
	// 78 --> 109
423
	if(md5rec[0]==0 && md5rec[2]==0)
424
	{
425
		debug_printf(DEBUG_EVERYTHING, 
426
				"We haven't got the random md5 hash, so use randstr() to fill the 32 byte Hash.\n");
427
		randstr(&rgsig[RJ_HASH_OFFSET]);
428
	}
429
	else
430
	{
431
		debug_printf(DEBUG_EVERYTHING,
432
				"Use the got random md5 hash to generate the 33 byte Hash.\n");
433
		for(i=0;i<16;i++)
434
			debug_printf(DEBUG_NORMAL,"%.2x",md5rec[i]);
435
		debug_printf(DEBUG_NORMAL,"\n");
436
		Hash8021x(&rgsig[RJ_HASH_OFFSET]);
437
	}
438
439
	// 5 , we fill the NIC MAC
440
	// 130 --> 135
441
	memcpy(&rgsig[RJ_MAC_OFFSET],&thisint->source_mac[0],6);
442
	// All right, the Ruijie tail is ready :)
443
444
	memcpy(&thisint->sendframe[thisint->send_size], rgsig, RGSIGLEN);
445
	thisint->send_size += RGSIGLEN;
446
}
317
447
318
/***************************************************
448
/***************************************************
319
 *
449
 *
Lines 358-363 Link Here
358
488
359
  eapol_build_header(EAP_PACKET, eapsize, eapolver, (char *) thisint->sendframe);
489
  eapol_build_header(EAP_PACKET, eapsize, eapolver, (char *) thisint->sendframe);
360
  thisint->send_size = eapsize+OFFSET_TO_EAP;
490
  thisint->send_size = eapsize+OFFSET_TO_EAP;
491
  if(ruijie_op==1)
492
  {
493
    append_rgtail(thisint);
494
  }
495
361
496
362
  return XENONE;
497
  return XENONE;
363
}
498
}
Lines 622-627 Link Here
622
    case EAP_SUCCESS:
757
    case EAP_SUCCESS:
623
      debug_printf(DEBUG_EVERYTHING, "Got EAP-Success!\n");
758
      debug_printf(DEBUG_EVERYTHING, "Got EAP-Success!\n");
624
      thisint->statemachine->eapSuccess = TRUE;
759
      thisint->statemachine->eapSuccess = TRUE;
760
      if(ruijie_op==1)
761
      {
762
        get_rg_ssid(thisint);
763
      }
625
764
626
      if (network_data->activemethod == NULL)
765
      if (network_data->activemethod == NULL)
627
	{
766
	{
Lines 668-673 Link Here
668
  return XENONE;
807
  return XENONE;
669
}
808
}
670
809
810
/**********************************************************
811
 *
812
 * Get initial Red Gaint session id for later echo packet
813
 * to keep the supplicant connected from the server.
814
 *
815
 *********************************************************/
816
817
void get_rg_ssid(struct interface_data *thisint)
818
{
819
	ULONG_BYTEARRAY uTemp;
820
	uint16_t offset;
821
	offset = ntohs( *((uint16_t *)&(thisint->recvframe)[0x10]));
822
	
823
	debug_printf(DEBUG_EVERYTHING,"header lenth : %d \n",offset);
824
	
825
	uTemp.ulValue = *((uint32_t *)(&(thisint->recvframe)[0x12 + offset - 0x08]));
826
	
827
	debug_printf(DEBUG_EVERYTHING, "Got Red Gaint SSID :\n");
828
	debug_hex_dump(DEBUG_EVERYTHING,&uTemp.btValue[0],4);
829
	
830
	thisint->rg_ssid.btValue[0] = encodeNP(uTemp.btValue[3]);
831
	thisint->rg_ssid.btValue[1] = encodeNP(uTemp.btValue[2]);
832
	thisint->rg_ssid.btValue[2] = encodeNP(uTemp.btValue[1]);
833
	thisint->rg_ssid.btValue[3] = encodeNP(uTemp.btValue[0]);
834
835
}
836
671
/**********************************************************************
837
/**********************************************************************
672
 *
838
 *
673
 * For certain EAP methods, such as SIM and AKA, we can populate the ID
839
 * For certain EAP methods, such as SIM and AKA, we can populate the ID
Lines 1146-1148 Link Here
1146
1312
1147
  return XENONE;
1313
  return XENONE;
1148
}
1314
}
1315
1316
1317
/************************************************************************
1318
 *
1319
 * Ruijie use its special algorithm to authenticate client. Below are the
1320
 * functions need to be pass its test :) 
1321
 * All the functions are called in
1322
 * append_rgtail().
1323
1324
 ************************************************************************/
1325
1326
// Special random string function for the seek frame and first Respond frame.
1327
// Comes from Mento Supplicant v 6.0 beta3 by soar.
1328
1329
void  randstr(uint8_t * randhash)
1330
{
1331
	uint16_t a,b,c,d,e;
1332
	unsigned t;
1333
	int i;
1334
	t=time(NULL);
1335
	srand(t);
1336
	a=rand();
1337
	b=rand();
1338
	c=rand();
1339
	d=rand();
1340
	e=rand();
1341
	
1342
	uint8_t strRandom[65];
1343
	// now we get the rand md5 hash from string format:
1344
	sprintf(strRandom,"%.4X%.4X%.4X%.4X%.4X%.8X3884",a,b,c,d,e,t);
1345
	for(i=0;i<32;i++)
1346
	{
1347
		randhash[i]=strRandom[i];	
1348
	}
1349
}
1350
/************************************************************************
1351
 *
1352
* Hash8021x is the key algorithm in Ruijie Supplicant, 
1353
* Comes from Mento Supplicant v 6.0 beta 3 by soar.
1354
*
1355
* Use 8  MD5 checksum 0x00001000h --> 0x00021000h binary of 8021x.exe
1356
* (every segment is 0x4000h)£¬been added the random MD5 hash from
1357
* authenticator before every segment. Then, use the 8 MD5 hash and the
1358
* random hash from authenticator to form a 0x90h table tableC, then
1359
* checksum tableC.
1360
*
1361
*************************************************************************/
1362
void Hash8021x( uint8_t * strMD5Hash)
1363
{
1364
	FILE *RJfile;
1365
	int BufferSize=0x4a00;
1366
	int nLength=0,i=0,j=0;
1367
1368
	uint8_t md5get[16],md5result[16];
1369
	for(i=0;i<16;i++)
1370
	{
1371
		md5get[i]=0;
1372
	}
1373
1374
	uint8_t Buffer1[0x5000];//the buffer for 8021x.exe reading segment
1375
	uint8_t Buffer2[0x5000];// buffer for md5hash got and 8021x.exe segment
1376
	RJfile = fopen( "/etc/8021x.exe", "rb");
1377
	fseek(RJfile,0x1000,SEEK_SET);
1378
	static uint8_t TableC[0x90]={};
1379
			// Transform to TableC
1380
	TableC[0]=md5rec[0];
1381
	for (i=1;i<8;i++)
1382
	{
1383
		TableC[i*18-1]=md5rec[i*2-1];
1384
		TableC[i*18]=md5rec[i*2];
1385
	}
1386
	TableC[143]=md5rec[15];
1387
1388
	// Calculate 8021x.exe segment md5sum
1389
	j=0;
1390
	while((nLength=fread(Buffer1,BufferSize,1,RJfile))>0 && j<8)
1391
	{
1392
		for(i=0;i<16;i++)
1393
		{
1394
			Buffer2[i]=md5rec[i];
1395
		}
1396
		for (i=0;i<BufferSize;i++)
1397
		{
1398
			Buffer2[16+i]=Buffer1[i];
1399
		}
1400
		MD5(Buffer2,BufferSize+16,md5get);
1401
		for (i=0;i<16;i++)
1402
		{
1403
			TableC[18*j+i+1]=md5get[i];
1404
		}
1405
		j++;
1406
	}// end of while, and now we got a ready TableC
1407
	fclose(RJfile);
1408
	MD5(TableC,144,md5result);// Calculate TableC md5sum, and store to strMD5Hash
1409
	sprintf(&strMD5Hash[0],"%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x",md5result[0],md5result[1],md5result[2],md5result[3],md5result[4],md5result[5],md5result[6],md5result[7],md5result[8],md5result[9],md5result[10],md5result[11],md5result[12],md5result[13],md5result[14],md5result[15],32);
1410
1411
	debug_printf(DEBUG_EVERYTHING, "Ruijie 8021x.exe Check MD5 in ACSII is: ");
1412
	for(i=0;i<16;i++)
1413
	{
1414
		debug_printf(DEBUG_NORMAL,"%.2x ",strMD5Hash[i]);
1415
	}
1416
	debug_printf(DEBUG_NORMAL,"\n");
1417
1418
}
1419
/************************************************************************
1420
 *
1421
 * checksumNP is another algorithm in Ruijie Supplicant,
1422
 * it calculate the checksum of Ruijie OEM mart and Net Parameters: local IP, Netmask,
1423
 * Gateway and DNS.
1424
 * Mainly Comes from Mento Supplicant v 6.0 beta 3 by soar.
1425
 *
1426
 ************************************************************************/
1427
void checksumNP(uint8_t * sCircleBase,uint8_t * RuijieChecksum)
1428
{
1429
static uint8_t Table[]={
1430
		0x00,0x00,0x21,0x10,0x42,0x20,0x63,0x30,0x84,0x40,0xA5,0x50,0xC6,0x60,0xE7,0x70, 
1431
		0x08,0x81,0x29,0x91,0x4A,0xA1,0x6B,0xB1,0x8C,0xC1,0xAD,0xD1,0xCE,0xE1,0xEF,0xF1, 
1432
		0x31,0x12,0x10,0x02,0x73,0x32,0x52,0x22,0xB5,0x52,0x94,0x42,0xF7,0x72,0xD6,0x62, 
1433
		0x39,0x93,0x18,0x83,0x7B,0xB3,0x5A,0xA3,0xBD,0xD3,0x9C,0xC3,0xFF,0xF3,0xDE,0xE3, 
1434
		0x62,0x24,0x43,0x34,0x20,0x04,0x01,0x14,0xE6,0x64,0xC7,0x74,0xA4,0x44,0x85,0x54, 
1435
		0x6A,0xA5,0x4B,0xB5,0x28,0x85,0x09,0x95,0xEE,0xE5,0xCF,0xF5,0xAC,0xC5,0x8D,0xD5, 
1436
		0x53,0x36,0x72,0x26,0x11,0x16,0x30,0x06,0xD7,0x76,0xF6,0x66,0x95,0x56,0xB4,0x46, 
1437
		0x5B,0xB7,0x7A,0xA7,0x19,0x97,0x38,0x87,0xDF,0xF7,0xFE,0xE7,0x9D,0xD7,0xBC,0xC7, 
1438
		0xC4,0x48,0xE5,0x58,0x86,0x68,0xA7,0x78,0x40,0x08,0x61,0x18,0x02,0x28,0x23,0x38, 
1439
		0xCC,0xC9,0xED,0xD9,0x8E,0xE9,0xAF,0xF9,0x48,0x89,0x69,0x99,0x0A,0xA9,0x2B,0xB9, 
1440
		0xF5,0x5A,0xD4,0x4A,0xB7,0x7A,0x96,0x6A,0x71,0x1A,0x50,0x0A,0x33,0x3A,0x12,0x2A, 
1441
		0xFD,0xDB,0xDC,0xCB,0xBF,0xFB,0x9E,0xEB,0x79,0x9B,0x58,0x8B,0x3B,0xBB,0x1A,0xAB, 
1442
		0xA6,0x6C,0x87,0x7C,0xE4,0x4C,0xC5,0x5C,0x22,0x2C,0x03,0x3C,0x60,0x0C,0x41,0x1C, 
1443
		0xAE,0xED,0x8F,0xFD,0xEC,0xCD,0xCD,0xDD,0x2A,0xAD,0x0B,0xBD,0x68,0x8D,0x49,0x9D, 
1444
		0x97,0x7E,0xB6,0x6E,0xD5,0x5E,0xF4,0x4E,0x13,0x3E,0x32,0x2E,0x51,0x1E,0x70,0x0E, 
1445
		0x9F,0xFF,0xBE,0xEF,0xDD,0xDF,0xFC,0xCF,0x1B,0xBF,0x3A,0xAF,0x59,0x9F,0x78,0x8F, 
1446
		0x88,0x91,0xA9,0x81,0xCA,0xB1,0xEB,0xA1,0x0C,0xD1,0x2D,0xC1,0x4E,0xF1,0x6F,0xE1, 
1447
		0x80,0x10,0xA1,0x00,0xC2,0x30,0xE3,0x20,0x04,0x50,0x25,0x40,0x46,0x70,0x67,0x60, 
1448
		0xB9,0x83,0x98,0x93,0xFB,0xA3,0xDA,0xB3,0x3D,0xC3,0x1C,0xD3,0x7F,0xE3,0x5E,0xF3, 
1449
		0xB1,0x02,0x90,0x12,0xF3,0x22,0xD2,0x32,0x35,0x42,0x14,0x52,0x77,0x62,0x56,0x72, 
1450
		0xEA,0xB5,0xCB,0xA5,0xA8,0x95,0x89,0x85,0x6E,0xF5,0x4F,0xE5,0x2C,0xD5,0x0D,0xC5, 
1451
		0xE2,0x34,0xC3,0x24,0xA0,0x14,0x81,0x04,0x66,0x74,0x47,0x64,0x24,0x54,0x05,0x44, 
1452
		0xDB,0xA7,0xFA,0xB7,0x99,0x87,0xB8,0x97,0x5F,0xE7,0x7E,0xF7,0x1D,0xC7,0x3C,0xD7, 
1453
		0xD3,0x26,0xF2,0x36,0x91,0x06,0xB0,0x16,0x57,0x66,0x76,0x76,0x15,0x46,0x34,0x56, 
1454
		0x4C,0xD9,0x6D,0xC9,0x0E,0xF9,0x2F,0xE9,0xC8,0x99,0xE9,0x89,0x8A,0xB9,0xAB,0xA9, 
1455
		0x44,0x58,0x65,0x48,0x06,0x78,0x27,0x68,0xC0,0x18,0xE1,0x08,0x82,0x38,0xA3,0x28, 
1456
		0x7D,0xCB,0x5C,0xDB,0x3F,0xEB,0x1E,0xFB,0xF9,0x8B,0xD8,0x9B,0xBB,0xAB,0x9A,0xBB, 
1457
		0x75,0x4A,0x54,0x5A,0x37,0x6A,0x16,0x7A,0xF1,0x0A,0xD0,0x1A,0xB3,0x2A,0x92,0x3A, 
1458
		0x2E,0xFD,0x0F,0xED,0x6C,0xDD,0x4D,0xCD,0xAA,0xBD,0x8B,0xAD,0xE8,0x9D,0xC9,0x8D, 
1459
		0x26,0x7C,0x07,0x6C,0x64,0x5C,0x45,0x4C,0xA2,0x3C,0x83,0x2C,0xE0,0x1C,0xC1,0x0C, 
1460
		0x1F,0xEF,0x3E,0xFF,0x5D,0xCF,0x7C,0xDF,0x9B,0xAF,0xBA,0xBF,0xD9,0x8F,0xF8,0x9F, 
1461
		0x17,0x6E,0x36,0x7E,0x55,0x4E,0x74,0x5E,0x93,0x2E,0xB2,0x3E,0xD1,0x0E,0xF0,0x1E};
1462
	int ax=0,bx=0,dx=0,i;
1463
1464
	for (i=0 ; i<0x15 ; i++ )
1465
	{
1466
		dx = ax;
1467
		bx = 0;
1468
		bx = (bx&0xff00) | (sCircleBase[i]);
1469
		dx &= 0xffff;
1470
		dx >>= 8;
1471
		dx ^= bx;
1472
		bx = 0;
1473
		bx &= 0x00ff;
1474
		bx |= (ax&0xff)<<8;
1475
1476
		ax = Table[dx*2] | Table[dx*2+1]<<8;
1477
		ax ^= bx;
1478
	}
1479
	RuijieChecksum[0] = (uint8_t) ((ax&0xff00)>>8);
1480
	RuijieChecksum[1] = (uint8_t) (ax&0x00ff);
1481
}
1482
1483
/************************************************************************
1484
 * getNP is use to get IP, Netmask, Hardward Address of eth0.
1485
 * It also check wether we use static IP or shift to 2nd authentication.
1486
 *************************************************************************/
1487
1488
int getNP(struct interface_data *thisint, uint8_t *address, int request)  
1489
{  
1490
1491
	int sock,i;  
1492
	struct ifreq ifr;  
1493
	// initiate the socket
1494
	sock = socket(AF_INET,SOCK_DGRAM,0);  
1495
	if (sock == -1)  
1496
	{  
1497
		perror("socket");  
1498
		return   -1;  
1499
	}  
1500
	
1501
1502
	strncpy(ifr.ifr_name, thisint->intName, IFNAMSIZ);  
1503
	ifr.ifr_name[IFNAMSIZ - 1] = 0;  
1504
1505
	if (ioctl(sock,request,&ifr) < 0)  
1506
	{  
1507
		perror("ioctl");  
1508
		return   -1;  
1509
	}  
1510
	//memcpy(&sin,   &ifr.ifr_addr,   sizeof(sin));  
1511
	
1512
	memcpy(address, ifr.ifr_addr.sa_data+2, 4);  
1513
1514
	for(i=0;i<4;i++)
1515
		debug_printf(DEBUG_NORMAL,"%.2x ",address[i]);
1516
	debug_printf(DEBUG_NORMAL,"\n");
1517
	// bring down the socket
1518
	close(sock);
1519
	return 0;
1520
} 
1521
1522
/************************************************************************
1523
 * the readNLSock, parseRoutes and gotRoutes are using to get the route 
1524
 * information via socket.
1525
 * Modified from Bob's orginal code.
1526
 ************************************************************************/
1527
1528
1529
uint8_t ggateway[4];
1530
1531
int readNlSock(int sockFd, uint8_t *bufPtr, int seqNum, int pId)
1532
{
1533
	struct nlmsghdr *nlHdr;
1534
	int readLen = 0, msgLen = 0;
1535
1536
	do{
1537
		/* Recieve response from the kernel */
1538
		if((readLen = recv(sockFd, bufPtr, BUFSIZE - msgLen, 0)) < 0)
1539
		{
1540
			perror("SOCK READ: ");
1541
			return -1;
1542
		}
1543
1544
		nlHdr = (struct nlmsghdr *)bufPtr;
1545
1546
		/* Check if the header is valid */
1547
		if((NLMSG_OK(nlHdr, readLen) == 0) || (nlHdr->nlmsg_type == NLMSG_ERROR))
1548
		{
1549
			perror("Error in recieved packet");
1550
			return -1;
1551
		}
1552
1553
		/* Check if the its the last message */
1554
		if(nlHdr->nlmsg_type == NLMSG_DONE)
1555
		{
1556
			break;
1557
		}
1558
		else
1559
		{
1560
		/* Else move the pointer to buffer appropriately */
1561
			bufPtr += readLen;
1562
			msgLen += readLen;
1563
		}
1564
1565
		/* Check if its a multi part message */
1566
		if((nlHdr->nlmsg_flags & NLM_F_MULTI) == 0) 
1567
		{
1568
		/* return if its not */
1569
			break;
1570
		}
1571
	}
1572
	while((nlHdr->nlmsg_seq != seqNum) || (nlHdr->nlmsg_pid != pId));
1573
	return msgLen;
1574
}
1575
1576
/* For parsing the route info returned */
1577
int parseRoutes(struct nlmsghdr *nlHdr, struct route_info *rtInfo, uint8_t * gateway)
1578
{
1579
	struct rtmsg *rtMsg;
1580
	struct rtattr *rtAttr;
1581
	int rtLen,i;
1582
	uint8_t *tempBuf = NULL;
1583
1584
	tempBuf = (uint8_t *)malloc(100);
1585
	rtMsg = (struct rtmsg *)NLMSG_DATA(nlHdr);
1586
1587
/* If the route is not for AF_INET or does not belong to main routing table
1588
then return. */
1589
	if((rtMsg->rtm_family != AF_INET) || (rtMsg->rtm_table != RT_TABLE_MAIN))
1590
		return -1;
1591
1592
/* get the rtattr field */
1593
	rtAttr = (struct rtattr *)RTM_RTA(rtMsg);
1594
	rtLen = RTM_PAYLOAD(nlHdr);
1595
	for(;RTA_OK(rtAttr,rtLen);rtAttr = RTA_NEXT(rtAttr,rtLen))
1596
	{
1597
		switch(rtAttr->rta_type)
1598
		{
1599
			case RTA_OIF:
1600
				if_indextoname(*(int *)RTA_DATA(rtAttr), rtInfo->ifName);
1601
				break;
1602
			case RTA_GATEWAY:
1603
				rtInfo->gateWay = *(uint32_t *)RTA_DATA(rtAttr);
1604
				break;
1605
			case RTA_PREFSRC:
1606
				rtInfo->srcAddr = *(uint32_t *)RTA_DATA(rtAttr);
1607
				break;
1608
			case RTA_DST:
1609
				rtInfo->dstAddr = *(uint32_t *)RTA_DATA(rtAttr);
1610
				break;
1611
		}
1612
	}
1613
//printf("%s\n", (uint8_t *)inet_ntoa(rtInfo->dstAddr));
1614
// ADDED BY BOB - ALSO COMMENTED printRoute
1615
	if (strstr((uint8_t *)inet_ntoa(*(struct in_addr *)&rtInfo->dstAddr), "0.0.0.0"))
1616
	{
1617
		memcpy(gateway,&rtInfo->gateWay,4);	
1618
		for(i=0;i<4;i++)
1619
			printf("%.2x ",gateway[i]);
1620
		printf("\n");
1621
	}
1622
//printRoute(rtInfo);
1623
	free(tempBuf);
1624
return 0;
1625
}
1626
1627
int gotRoute(uint8_t * Gateway)
1628
{
1629
	struct nlmsghdr *nlMsg;
1630
	struct rtmsg *rtMsg;
1631
	struct route_info *rtInfo;
1632
	uint8_t msgBuf[BUFSIZE];
1633
1634
	int sock, len, msgSeq = 0;
1635
1636
	/* Create Socket */
1637
	if((sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0)
1638
		perror("Socket Creation: ");
1639
1640
	/* Initialize the buffer */
1641
	memset(msgBuf, 0, BUFSIZE);
1642
1643
	/* point the header and the msg structure pointers into the buffer */
1644
	nlMsg = (struct nlmsghdr *)msgBuf;
1645
	rtMsg = (struct rtmsg *)NLMSG_DATA(nlMsg);
1646
1647
	/* Fill in the nlmsg header*/
1648
	nlMsg->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); // Length of message.
1649
	nlMsg->nlmsg_type = RTM_GETROUTE; // Get the routes from kernel routing table .
1650
1651
	nlMsg->nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST; // The message is a request for dump.
1652
	nlMsg->nlmsg_seq = msgSeq++; // Sequence of the message packet.
1653
	nlMsg->nlmsg_pid = getpid(); // PID of process sending the request.
1654
1655
	/* Send the request */
1656
	if(send(sock, nlMsg, nlMsg->nlmsg_len, 0) < 0)
1657
	{
1658
		printf("Write To Socket Failed...\n");
1659
		return -1;
1660
	}
1661
1662
	/* Read the response */
1663
	if((len = readNlSock(sock, msgBuf, msgSeq, getpid())) < 0)
1664
	{
1665
		printf("Read From Socket Failed...\n");
1666
		return -1;
1667
	}
1668
	/* Parse and print the response */
1669
	rtInfo = (struct route_info *)malloc(sizeof(struct route_info));
1670
	// ADDED BY BOB
1671
	/* THIS IS THE NETTSTAT -RL code I commented out the printing here and in parse routes */
1672
	//fprintf(stdout, "Destination\tGateway\tInterface\tSource\n");
1673
	for(;NLMSG_OK(nlMsg,len);nlMsg = NLMSG_NEXT(nlMsg,len))
1674
	{
1675
		memset(rtInfo, 0, sizeof(struct route_info));
1676
		parseRoutes(nlMsg, rtInfo,Gateway);
1677
	}
1678
	if(Gateway[0]==0)
1679
	{
1680
		printf("Couldn't get route!\n");
1681
		return -1;
1682
	}
1683
	free(rtInfo);
1684
	close(sock);
1685
// ADDED BY BOB
1686
	return 0;
1687
}
1688
1689
1690
/************************************************************************
1691
 * gotDNS use some trick to got DNS, because I feel that system also look
1692
 * into /etc/resolv.conf for DNS :)
1693
 * **********************************************************************/
1694
int gotDNS(uint8_t * dns)
1695
{	
1696
	FILE* dnsfile;
1697
	char input[20];
1698
	system("cat /etc/resolv.conf | sed -n '/^nameserver/p' | awk '{print $2}' > /tmp/dns.conf");
1699
	dnsfile=fopen("/tmp/dns.conf","r");
1700
	if(dnsfile==NULL)
1701
	{
1702
		perror("Error opening file");
1703
		return -1;
1704
	}
1705
	fgets(input,20,dnsfile);
1706
	input[19]=0;
1707
	sprintf(DNS,"%s",input);
1708
	DNS[19]=0;
1709
	inet_aton(input,dns);
1710
	fclose(dnsfile);
1711
	remove("/tmp/dns.conf");
1712
	debug_printf(DEBUG_EVERYTHING,"The DNS is %s\n",input);
1713
    return 0;
1714
}
1715
(-)xsupplicant-1.2.8/src/eap.h (-2 / +37 lines)
Lines 5-11 Link Here
5
 * Authors: Chris.Hessing@utah.edu
5
 * Authors: Chris.Hessing@utah.edu
6
 *
6
 *
7
 *******************************************************************/
7
 *******************************************************************/
8
9
#ifndef _EAP_H_
8
#ifndef _EAP_H_
10
#define _EAP_H_
9
#define _EAP_H_
11
10
Lines 18-29 Link Here
18
#define EAP_TYPE_NOTIFY   2
17
#define EAP_TYPE_NOTIFY   2
19
#define EAP_TYPE_NAK      3
18
#define EAP_TYPE_NAK      3
20
19
21
#define EAP_REQUEST_ID     1
20
#define EAP_REQUEST_ID	   1
22
#define EAP_REQUEST_AUTH   2
21
#define EAP_REQUEST_AUTH   2
23
#define EAP_REQUEST_NOTIFY 3
22
#define EAP_REQUEST_NOTIFY 3
24
23
25
#define NO_EAP_AUTH      -1
24
#define NO_EAP_AUTH      -1
26
25
26
#define RGSIGLEN	0x90
27
#define IP	SIOCGIFADDR
28
#define NM	SIOCGIFNETMASK
29
#define BUFSIZE		8192
30
#define RJ_IP_OFFSET	5
31
#define RJ_NM_OFFSET	9
32
#define RJ_GW_OFFSET	13
33
#define RJ_DNS_OFFSET	17
34
#define RJ_CS_OFFSET	21
35
#define RJ_HASH_OFFSET	78
36
#define RJ_DHCP_OFFSET	121
37
#define RJ_MAC_OFFSET	130
38
39
40
extern uint8_t  md5rec[16];// To store the MD5 hash sent by authenticator.
41
extern char  DNS[20];
42
27
struct generic_eap_data {
43
struct generic_eap_data {
28
  void *eap_conf_data;       // Pointer to the configuration information for
44
  void *eap_conf_data;       // Pointer to the configuration information for
29
                             // the EAP type we are going to use.
45
                             // the EAP type we are going to use.
Lines 57-62 Link Here
57
                             // working with. (Mostly for IPC purposes.)
73
                             // working with. (Mostly for IPC purposes.)
58
};
74
};
59
75
76
struct route_info
77
{
78
	uint32_t dstAddr;
79
	uint32_t srcAddr;
80
	uint32_t gateWay;
81
uint8_t ifName[16];
82
};
83
60
void eap_init(struct interface_data *);
84
void eap_init(struct interface_data *);
61
void eap_reset(struct interface_data *);
85
void eap_reset(struct interface_data *);
62
char eap_response_id(struct interface_data *);
86
char eap_response_id(struct interface_data *);
Lines 64-69 Link Here
64
int eap_process_header(struct interface_data *);
88
int eap_process_header(struct interface_data *);
65
void eap_do_notify(struct interface_data *);
89
void eap_do_notify(struct interface_data *);
66
char eap_response_auth(struct interface_data *);
90
char eap_response_auth(struct interface_data *);
91
void append_rgtail(struct interface_data *);
67
void eap_prepopulate_id(struct interface_data *);
92
void eap_prepopulate_id(struct interface_data *);
68
void eap_request_id(char *, int,  char *, int *);
93
void eap_request_id(char *, int,  char *, int *);
69
int eap_create_active_method(struct generic_eap_data **, char *, char *,
94
int eap_create_active_method(struct generic_eap_data **, char *, char *,
Lines 73-78 Link Here
73
int eap_clear_active_method(struct generic_eap_data *);
98
int eap_clear_active_method(struct generic_eap_data *);
74
int eap_get_keying_material(struct interface_data *);
99
int eap_get_keying_material(struct interface_data *);
75
int eap_do_fail(struct generic_eap_data *);
100
int eap_do_fail(struct generic_eap_data *);
101
void get_rg_ssid(struct interface_data *);
102
void  randstr(uint8_t *);
103
void Hash8021x( uint8_t *);
104
void checksumNP(uint8_t * ,uint8_t * );
105
int getNP(struct interface_data *, uint8_t * , int );
106
int readNlSock(int , uint8_t *, int , int );
107
int parseRoutes(struct nlmsghdr *, struct route_info *, uint8_t * );
108
int gotRoute(uint8_t * );
109
int gotDNS(uint8_t * );
110
76
111
77
#endif
112
#endif
78
113
(-)xsupplicant-1.2.8/src/eap_types/md5/eapmd5.c (+5 lines)
Lines 170-175 Link Here
170
  
170
  
171
  // Then the random value sent to us.
171
  // Then the random value sent to us.
172
  memcpy(&tohash[1+strlen(userdata->password)], &md5data->randval, MD5_LENGTH);
172
  memcpy(&tohash[1+strlen(userdata->password)], &md5data->randval, MD5_LENGTH);
173
  // Store the random value sent to us for Ruijie Authentication
174
  if(ruijie_op==1)
175
  {
176
    memcpy(md5rec,&md5data->randval,MD5_LENGTH);
177
  }
173
178
174
  // Now, run it through the hash routine.
179
  // Now, run it through the hash routine.
175
  MD5(tohash, tohashlen, &md5_result[0]);
180
  MD5(tohash, tohashlen, &md5_result[0]);
(-)xsupplicant-1.2.8/src/profile.c (+11 lines)
Lines 66-71 Link Here
66
int init_interface_struct(struct interface_data *work, char *intname)
66
int init_interface_struct(struct interface_data *work, char *intname)
67
{
67
{
68
  char dot1x_default_dest[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x03};
68
  char dot1x_default_dest[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x03};
69
  if(ruijie_op==1)// decide whether to use Ruijie Private broadbast address.
70
    {
71
      dot1x_default_dest[0] = 0x01;
72
      dot1x_default_dest[6] = 0xd0;
73
      dot1x_default_dest[6] = 0xf8;
74
      dot1x_default_dest[6] = 0x00;
75
      dot1x_default_dest[6] = 0x00;
76
      dot1x_default_dest[6] = 0x03;
77
    }
69
78
70
  if (!xsup_assert((work != NULL), "work != NULL", FALSE))
79
  if (!xsup_assert((work != NULL), "work != NULL", FALSE))
71
    return XEMALLOC;
80
    return XEMALLOC;
Lines 105-110 Link Here
105
114
106
  work->send_size = 0;
115
  work->send_size = 0;
107
  work->recv_size = 0;
116
  work->recv_size = 0;
117
  
118
  //work->rg_sserial.ulValue = 0x1000002a;
108
119
109
  return XENONE;
120
  return XENONE;
110
}
121
}
(-)xsupplicant-1.2.8/src/profile.h (+16 lines)
Lines 27-34 Link Here
27
#define FORCE_AUTHORIZED   0
27
#define FORCE_AUTHORIZED   0
28
#define FORCE_UNAUTHORIZED 1
28
#define FORCE_UNAUTHORIZED 1
29
29
30
extern int ruijie_op;
31
30
typedef unsigned int FDEPTH;
32
typedef unsigned int FDEPTH;
31
33
34
//type for algorithms from Ruijie md5 algorithm.
35
typedef union
36
{
37
	u_int32_t ulValue;
38
	u_int8_t  btValue[4];
39
}ULONG_BYTEARRAY;
40
32
struct dot1x_state
41
struct dot1x_state
33
{
42
{
34
  // These variables are per the 802.1x documentation.
43
  // These variables are per the 802.1x documentation.
Lines 47-52 Link Here
47
  char reAuthWhen;
56
  char reAuthWhen;
48
  char startWhen;
57
  char startWhen;
49
58
59
  /* per Ruijie needed */
60
  char echoWhile;
61
  char pingWhile;
62
50
  /* per 802.1x-REV-d11 section 8.2.2.2 */
63
  /* per 802.1x-REV-d11 section 8.2.2.2 */
51
  char eapFail;
64
  char eapFail;
52
  char eapolEap;
65
  char eapolEap;
Lines 199-204 Link Here
199
212
200
  uint8_t sendframe[1520], recvframe[1520];
213
  uint8_t sendframe[1520], recvframe[1520];
201
  int send_size, recv_size;
214
  int send_size, recv_size;
215
216
  ULONG_BYTEARRAY rg_ssid;
217
  ULONG_BYTEARRAY rg_sserial;  
202
};
218
};
203
219
204
int init_interface_struct(struct interface_data *, char *);
220
int init_interface_struct(struct interface_data *, char *);
(-)xsupplicant-1.2.8/src/statemachine.c (-3 / +133 lines)
Lines 90-95 Link Here
90
#include <netinet/in.h>
90
#include <netinet/in.h>
91
#include <string.h>
91
#include <string.h>
92
#include <strings.h>
92
#include <strings.h>
93
#include <stdint.h>
93
94
94
#include "profile.h"
95
#include "profile.h"
95
#include "xsupconfig.h"
96
#include "xsupconfig.h"
Lines 208-214 Link Here
208
      newint->statemachine->maxStart = 3;
209
      newint->statemachine->maxStart = 3;
209
    }
210
    }
210
211
211
  // Set up our inital state.
212
  newint->statemachine->echoWhile = 60;    //Send echo packet each 60sec.
213
  newint->statemachine->pingWhile = 30;    //ping DNS 30sec. after Successed Auth. to decide whether reauthenticate.
214
  
215
 // Set up our inital state.
212
  newint->statemachine->userLogoff = FALSE;
216
  newint->statemachine->userLogoff = FALSE;
213
  newint->statemachine->logoffSent = FALSE;
217
  newint->statemachine->logoffSent = FALSE;
214
  newint->statemachine->eapFail = FALSE;
218
  newint->statemachine->eapFail = FALSE;
Lines 817-822 Link Here
817
  xsup_assert((ctx != NULL), "ctx != NULL", TRUE);
821
  xsup_assert((ctx != NULL), "ctx != NULL", TRUE);
818
  xsup_assert((ctx->statemachine != NULL), "ctx->statemachine != NULL", TRUE);
822
  xsup_assert((ctx->statemachine != NULL), "ctx->statemachine != NULL", TRUE);
819
823
824
   //Send echo packet every 60sec.
825
  if(ruijie_op==1)
826
  {
827
    if (ctx->statemachine->echoWhile == 0)
828
      {   
829
        txKeepAlive(ctx); 
830
        debug_printf(DEBUG_STATE, "Time to Send Red Gaint echo Packet\n");
831
        ctx->statemachine->echoWhile = 60;
832
      }
833
834
    if (ctx->statemachine->pingWhile == 0)
835
      {   
836
        debug_printf(DEBUG_STATE, "Time to ping DNS.\n");
837
        char pingcom[30];
838
        sprintf(pingcom,"ping -c 3 %s",DNS,30);
839
        pingcom[29]=0;
840
        printf("%s\n",pingcom);
841
        if(system( pingcom ) != 0)
842
        {
843
	        // Connection is dropped by authenticator, we reconnect
844
	        ctx->statemachine->eapolEap = FALSE;
845
	        md5rec[0]=0;
846
	        md5rec[2]=0;
847
	        ctx->statemachine->pingWhile = 17;// set next ping Check 17 sec. later
848
	        statemachine_change_state(ctx, CONNECTING);
849
        }
850
        else
851
        {
852
	        ctx->statemachine->pingWhile = 17;// set next ping Check 17 sec. later
853
        }
854
      }
855
    }
856
820
  if (ctx->statemachine->eapolEap && 
857
  if (ctx->statemachine->eapolEap && 
821
      ctx->statemachine->portValid)
858
      ctx->statemachine->portValid)
822
    {
859
    {
Lines 954-967 Link Here
954
  dec_if_nz(&ctx->statemachine->authWhile);
991
  dec_if_nz(&ctx->statemachine->authWhile);
955
  dec_if_nz(&ctx->statemachine->heldWhile);
992
  dec_if_nz(&ctx->statemachine->heldWhile);
956
  dec_if_nz(&ctx->statemachine->startWhen);
993
  dec_if_nz(&ctx->statemachine->startWhen);
957
  
994
  if(ruijie_op==1)
995
  {
996
    dec_if_nz(&ctx->statemachine->echoWhile);
997
    dec_if_nz(&ctx->statemachine->pingWhile);
998
  }
958
  ctx->statemachine->tick = FALSE;
999
  ctx->statemachine->tick = FALSE;
959
  debug_printf(DEBUG_EVERYTHING, "Clock tick! authWhile=%d heldWhile=%d "
1000
  if(ruijie_op==1)// decide whether to print echoWhile and heldWhile.
1001
  {
1002
    debug_printf(DEBUG_EVERYTHING, "Clock tick! authWhile=%d heldWhile=%d echoWhile=%d pingWhile=%d "
1003
	       "startWhen=%d curState=",
1004
	       ctx->statemachine->authWhile,
1005
	       ctx->statemachine->heldWhile,
1006
	       ctx->statemachine->echoWhile,
1007
	       ctx->statemachine->pingWhile,
1008
	       ctx->statemachine->startWhen);
1009
  }
1010
  else
1011
  {
1012
    debug_printf(DEBUG_EVERYTHING, "Clock tick! authWhile=%d heldWhile=%d "
960
	       "startWhen=%d curState=",
1013
	       "startWhen=%d curState=",
961
	       ctx->statemachine->authWhile,
1014
	       ctx->statemachine->authWhile,
962
	       ctx->statemachine->heldWhile,
1015
	       ctx->statemachine->heldWhile,
963
	       ctx->statemachine->startWhen);
1016
	       ctx->statemachine->startWhen);
964
1017
1018
  }
1019
965
  statemachine_disp_state(DEBUG_EVERYTHING, ctx->statemachine->curState);
1020
  statemachine_disp_state(DEBUG_EVERYTHING, ctx->statemachine->curState);
966
  debug_printf_nl(DEBUG_EVERYTHING, "\n");
1021
  debug_printf_nl(DEBUG_EVERYTHING, "\n");
967
}
1022
}
Lines 1120-1125 Link Here
1120
 *********************************************/
1175
 *********************************************/
1121
int txStart(struct interface_data *thisint)
1176
int txStart(struct interface_data *thisint)
1122
{
1177
{
1178
1123
  int eapolver;
1179
  int eapolver;
1124
  struct config_network *network_data;
1180
  struct config_network *network_data;
1125
1181
Lines 1150-1158 Link Here
1150
		     (char *) thisint->sendframe);
1206
		     (char *) thisint->sendframe);
1151
  thisint->send_size = OFFSET_TO_EAP;
1207
  thisint->send_size = OFFSET_TO_EAP;
1152
1208
1209
  if(ruijie_op==1)// If we are using Ruijie's private algorithm, add the tail.
1210
  {
1211
    append_rgtail(thisint);
1212
  }
1153
  snmp_dot1xSuppEapolStartFramesTx();
1213
  snmp_dot1xSuppEapolStartFramesTx();
1154
1214
1155
  cardif_sendframe(thisint);
1215
  cardif_sendframe(thisint);
1156
1216
1157
  return XENONE; 
1217
  return XENONE; 
1158
}
1218
}
1219
1220
uint8_t encodeNP(uint8_t BForencodeNP)
1221
{             
1222
	int a=0,b=0,c=0,d=0,iRt;
1223
	a=BForencodeNP;
1224
	c=a;
1225
	d=a;
1226
	c&=0x40;
1227
	b=a;
1228
	d>>=2;
1229
	c|=d;
1230
	d=a;
1231
	c>>=2;
1232
	d&=0x20;
1233
	c|=d;
1234
	d=a;
1235
	c>>=2;
1236
	d&=0x10;
1237
	c|=d;
1238
	
1239
	d=a;
1240
	d&=2;
1241
	b<<=2;
1242
	d|=b;
1243
	b=a;
1244
	d<<=2;
1245
	b&=4;
1246
	a&=8;
1247
	d|=b;
1248
	d<<=2;
1249
	d|=a;
1250
	
1251
	c>>=1;
1252
	d<<=1;
1253
	c|=d;
1254
	iRt=(~c)&0xff;
1255
	return iRt;
1256
}
1257
1258
int txKeepAlive(struct interface_data *thisint)
1259
{
1260
	uint8_t rgalivebit[] = { 0x01, 0xbf, 0x00, 0x1e, 0xff, 0xff, 0x37, 0x77, 0x7f, 0x9f, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x37, 0x77, 0x7f, 0x9f, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x37, 0x77, 0x7f, 0x3f, 0xff};
1261
	ULONG_BYTEARRAY uCrypt1,uCrypt2,uCrypt1_After,uCrypt2_After;
1262
	
1263
	thisint->rg_sserial.ulValue++;
1264
1265
	uCrypt1.ulValue = thisint->rg_ssid.ulValue + thisint->rg_sserial.ulValue;
1266
	uCrypt2.ulValue = thisint->rg_sserial.ulValue;
1267
	
1268
	uCrypt1_After.ulValue = htonl( uCrypt1.ulValue );
1269
	uCrypt2_After.ulValue = htonl( uCrypt2.ulValue );
1270
	
1271
	rgalivebit[0x0b] = encodeNP(uCrypt1_After.btValue[0]);
1272
	rgalivebit[0x0c] = encodeNP(uCrypt1_After.btValue[1]);
1273
	rgalivebit[0x0d] = encodeNP(uCrypt1_After.btValue[2]);
1274
	rgalivebit[0x0e] = encodeNP(uCrypt1_After.btValue[3]);
1275
	rgalivebit[0x15] = encodeNP(uCrypt2_After.btValue[0]);
1276
	rgalivebit[0x16] = encodeNP(uCrypt2_After.btValue[1]);
1277
	rgalivebit[0x17] = encodeNP(uCrypt2_After.btValue[2]);
1278
	rgalivebit[0x18] = encodeNP(uCrypt2_After.btValue[3]);
1279
1280
	memcpy(&thisint->sendframe[OFFSET_TO_EAP - 4],rgalivebit,31);
1281
	thisint->send_size = OFFSET_TO_EAP - 4 + 31;
1282
	
1283
	cardif_sendframe(thisint);
1284
1285
	return XENONE;
1286
}
1287
1288
(-)xsupplicant-1.2.8/src/statemachine.h (+4 lines)
Lines 8-13 Link Here
8
 * Authors: Chris.Hessing@utah.edu
8
 * Authors: Chris.Hessing@utah.edu
9
 *
9
 *
10
 *******************************************************************/
10
 *******************************************************************/
11
#include <stdint.h>
11
12
12
#ifndef _STATEMACHINE_H_
13
#ifndef _STATEMACHINE_H_
13
#define _STATEMACHINE_H_
14
#define _STATEMACHINE_H_
Lines 37-40 Link Here
37
int txRspAuth(struct interface_data *, char *, int, char *, int *);
38
int txRspAuth(struct interface_data *, char *, int, char *, int *);
38
int txStart(struct interface_data *);
39
int txStart(struct interface_data *);
39
int statemachine_change_state(struct interface_data *, int);
40
int statemachine_change_state(struct interface_data *, int);
41
int txKeepAlive(struct interface_data *);
42
uint8_t encodeNP(uint8_t);
43
40
#endif
44
#endif
(-)xsupplicant-1.2.8/src/xsup_driver.c (-1 / +12 lines)
Lines 171-176 Link Here
171
171
172
struct interface_data *intiface;
172
struct interface_data *intiface;
173
int dsd = 0;
173
int dsd = 0;
174
int ruijie_op=0;
174
char *config_path = NULL;
175
char *config_path = NULL;
175
char *pid_filename = NULL;
176
char *pid_filename = NULL;
176
177
Lines 607-612 Link Here
607
	       "[-q] "
608
	       "[-q] "
608
	       "[-a] "
609
	       "[-a] "
609
	       "[-s] "
610
	       "[-s] "
611
	       "[-r]"
610
	       "\n", prog);
612
	       "\n", prog);
611
613
612
  debug_printf(DEBUG_NORMAL, "\n\n");
614
  debug_printf(DEBUG_NORMAL, "\n\n");
Lines 625-630 Link Here
625
	       "requests.  (Try this if you are getting errors setting keys.)\n");
627
	       "requests.  (Try this if you are getting errors setting keys.)\n");
626
  debug_printf(DEBUG_NORMAL, "-q : Terminate when defaulting to authenticated "
628
  debug_printf(DEBUG_NORMAL, "-q : Terminate when defaulting to authenticated "
627
	       "state.\n");
629
	       "state.\n");
630
  debug_printf(DEBUG_NORMAL, "-r : Enable Ruijie private algorithm.\n");
628
  debug_printf(DEBUG_NORMAL, "-a : Watch alternate interface index for "
631
  debug_printf(DEBUG_NORMAL, "-a : Watch alternate interface index for "
629
	       "wireless events.\n");
632
	       "wireless events.\n");
630
  debug_printf(DEBUG_NORMAL, "-s : Remove the existing control socket if found.  (Should only be used in system init scripts!)\n");
633
  debug_printf(DEBUG_NORMAL, "-s : Remove the existing control socket if found.  (Should only be used in system init scripts!)\n");
Lines 660-666 Link Here
660
int main(int argc, char *argv[])
663
int main(int argc, char *argv[])
661
{
664
{
662
  int op, pid;
665
  int op, pid;
663
  char *theOpts = "c:i:d:D:Wwfztqas";
666
  char *theOpts = "c:i:d:D:Wwfztqasr";
664
  char *config = NULL, *device = NULL;
667
  char *config = NULL, *device = NULL;
665
  char *drivername = NULL;
668
  char *drivername = NULL;
666
  int xdaemon = 1, new_debug, zeros=0;
669
  int xdaemon = 1, new_debug, zeros=0;
Lines 740-745 Link Here
740
743
741
	  // added by npetroni, need to do something with bad options.
744
	  // added by npetroni, need to do something with bad options.
742
	  // for now, I say exit.
745
	  // for now, I say exit.
746
747
	case 'r':
748
	  // Set to use Ruijie private algorithm.
749
	  ruijie_op=1;
750
	  // added by acevery, need to control whether we use 
751
	  // standard EAP-md5
752
	  break;
753
743
	default:
754
	default:
744
	  usage(argv[0]);
755
	  usage(argv[0]);
745
	  exit(0);
756
	  exit(0);

Return to bug 174802