#include "includes.h" #include "nwy_sim.h" #include "nwy_sms.h" #define AUTH_FILE "n58_info" #define ID_VALID_BYTE 12 char *modemImei=NULL; char id_imei[ID_VALID_BYTE+1]={0}; /* saveAuth 保存授权? */ void saveAuth(char *imei){ unsigned char writebuf[64],tmp[10]; unsigned short length,i; char tempImei[IMEI_SIZE]; memcpy(tempImei, imei,IMEI_SIZE ); DecodeImeiBytes(tempImei); length=0; for(i=0;iID_VALID_BYTE){ w=(len-ID_VALID_BYTE)*2; for(i=0;i>8; //4-5 sendbuf[i++]=liushui; for(k=0;k=10){ if(handshake==false) authSendCmd(PRO_AUTH_RESPONS,0,0); cnt=0; } nwy_sleep(100); } if(showFlag) guiShowMessageBox("Ȩͨ"); sutApp.authReady=1; } #define FACTORY_NAME "AMST" //#define FACTORY_NAME "RTL" void EncodeKeyWithFactorAndMode(unsigned char *code) { int i,j; char *FN=FACTORY_NAME; char *MN=OHPOC_APP_NAME; j=strlen(FACTORY_NAME); for(i=0;iSlaveNum=*dataPtr; //write new auth authInfo->authCode=codeData; //make lier data for(i=0;inoUseStart);i++){ authInfo->noUseStart[i]=*dataPtr++^data[6]; if(dataPtr>=&data[len]) dataPtr=data; } for(i=0;inoUseEnd);i++){ authInfo->noUseEnd[i]=*dataPtr++^data[4]; if(dataPtr>=&data[len]) dataPtr=data; } #endif if(codeData == encodeWithImei(id_imei, ID_VALID_BYTE)){ saveAuth(modemImei); sutApp.authReady=1; return 0; }else return 4; } char authRecvPro(const char *data, unsigned int length){ unsigned char senddata[ID_VALID_BYTE+16+16]; char ret=authDataPro(data, length); switch(ret){ case 0: authSendCmd(PRO_AUTH_OK,id_imei,ID_VALID_BYTE); break; case 4://鉴权吗不正确 authSendCmd(PRO_AUTH_FAI, id_imei, ID_VALID_BYTE); break; case 5://握手成功 handshake=true; break; case 6://请求基本数据 memset(senddata, 0, sizeof(senddata)); memcpy(senddata, id_imei, ID_VALID_BYTE); strcpy(senddata+ID_VALID_BYTE, FACTORY_NAME); strcpy(senddata+ID_VALID_BYTE+16, OHPOC_APP_NAME); authSendCmd(PRO_AUTH_REQ,senddata,ID_VALID_BYTE+16+16); break; } return ret; }