char* LoginMgr::SIPCSignInStep2(char *response) { if(!response) return NULL; char* szCnonce = GetNonce(response); if(!szCnonce) return NULL; // // 计算认证的值,参考移动接口规范中规定的计算方法 // ComputeAuthResponse* Response = new ComputeAuthResponse( m_User->GetSid(), m_User->GetHashPwd(), m_User->GetDomain(), szCnonce, true); char* computeResponse = Response->GetResponse(); //Need to be delete char* cNonce = Response->GetCNonce(); char salt[8] = {0}; memcpy(salt, m_User->GetHashPwd(), 8); char* ssic = m_User->GetPortInfo()->GetSSIC(); FetionTemplate ft; char* SendData = ft.RegisterSIPCStep2(m_User->GetSid(), computeResponse, cNonce, salt, ssic); return SendData; //发送数据,接收返回 ... TO DO // // /* char* Result = NULL; if(strstr(Result, "SIP-C/2.0 200 OK") != NULL) { DebugWriter::WriteLine("step2:Login To SIPC Server Successful!"); return 0; } else { //Login failed DebugWriter::WriteLine("step2:Login To SIPC Server Successful!"); return -1; } delete[] computeResponse; delete[] SendData; */ }
void TestASIC(u8 n) { u8 nonce[4] = {0, 0, 0, 0}; u8 work[44]; u8 i; u8 stat; u8 case_n = 1; u32 tick; UARTWriteLine("Test Chip:"); UARTWriteInt(n,2); CloseASIC(); OpenASIC(n); UARTWriteLine("Set Clock To "); UARTWriteInt(10 * (CHIP_CLOCK + 1), 3); SetPll(CHIP_CLOCK); UARTWriteLine("Check Status: "); stat = GetASIC(); UARTWriteOneHex(stat); UARTWriteLine("Sending work: "); for (i = 0; i < 44; i++) { UARTWriteOneHex(cases[case_n].work[i]); } SendWork(cases[case_n].work); UARTWriteLine("Checking work: "); ReadWork(work); for (i = 0; i < 44; i++) { UARTWriteOneHex(work[i]); } tick=GetTime(); while(GetTime()-tick<700); GetNonce(&nonce, TRUE); UARTWriteLine("Get Nonce:"); UARTWriteHex(nonce); UARTWriteLine(" Expected:"); UARTWriteHex(cases[case_n].nonce); UARTGotoNewLine(); }
char* LoginMgr::SIPCReg(char* response) { if(!response) return NULL; char* szNonce = GetNonce(response); if(!szNonce) return NULL; ComputeRobotResponse* Response = new ComputeRobotResponse( m_User->GetSalt(), m_User->GetDomain(), m_User->GetPassword(), m_User->GetCnounce(), szNonce, m_User->GetSid()); char* robotResponse = Response->GetResponse(); FetionTemplate ft; char* SendData = ft.SIPCReg(m_User->GetSid(), robotResponse, m_User->GetCnounce(), m_User->GetSalt(), m_User->GetDomain()); return SendData; //发送数据,接收返回 /* char* Result = conn->SendAndReceive(SendData); if(!Result) return -1; if(strstr(Result, "SIP-C/2.0 200 OK") != NULL) { DebugWriter::WriteLine("登录成功!"); //解析失效时间 //SIP-C/2.0 200 Ok //X: expires-time //I: call-id-value //Q: cseq-value R //L: content-length-value if(strstr(Result, "X:") != NULL) { int ex_time = atoi(strstr(Result, "X:") + 3); printf("Login Info : expires-time is %d\n", ex_time); } return 0; } else { DebugWriter::WriteLine("登录失败!"); return -1; } delete Response; delete[] SendData; delete[] Result; */ }
/** * Returns the string representation of the round */ inline virtual QString ToString() const { return "CSDCNetRound: " + GetNonce().toBase64() + " Phase: " + QString::number(_state_machine.GetPhase()); }