本文整理汇总了C++中WriteBuffer::data方法的典型用法代码示例。如果您正苦于以下问题:C++ WriteBuffer::data方法的具体用法?C++ WriteBuffer::data怎么用?C++ WriteBuffer::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WriteBuffer
的用法示例。
在下文中一共展示了WriteBuffer::data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: aChallenge
WONStatus PeerAuthServer::GetChallenge1(ByteBufferPtr &theChallenge)
{
WriteBuffer aChallenge(mLengthFieldSize);
aChallenge.AppendLong(203); // Auth peer to peer service
aChallenge.AppendLong(51); // Challenge1
mSecretB.Create(8);
WriteBuffer aChallengeSecret;
aChallengeSecret.AppendShort(mSecretB.GetKeyLen());
aChallengeSecret.AppendBytes(mSecretB.GetKey(),mSecretB.GetKeyLen());
ByteBufferPtr anEncrypt = mClientCertificate->GetPubKey().Encrypt(aChallengeSecret.data(),aChallengeSecret.length());
if(anEncrypt.get()==NULL)
return WS_PeerAuthServer_FailedToEncryptWithClientPubKey;
aChallenge.AppendShort(anEncrypt->length());
aChallenge.AppendBytes(anEncrypt->data(),anEncrypt->length());
if(mUseAuth2)
aChallenge.AppendBuffer(mPeerData->GetCertificate2()->GetRawBuf(),2);
else
aChallenge.AppendBuffer(mPeerData->GetCertificate()->GetRawBuf(),2);
theChallenge = aChallenge.ToByteBuffer();
return WS_Success;
}
示例2: GetComplete
WONStatus PeerAuthServer::GetComplete(WONStatus theStatus, ByteBufferPtr &theComplete)
{
mState = STATE_NOT_STARTED; // reset state now
WriteBuffer aComplete(mLengthFieldSize);
aComplete.AppendLong(203); // Auth peer to peer service
aComplete.AppendLong(53); // Complete
if(theStatus!=WS_Success)
{
aComplete.AppendShort(WS_CommServ_InvalidParameters); // failure status
aComplete.AppendShort(1); // num errors
aComplete.AppendString(WONStatusToString(theStatus));
}
else
{
aComplete.AppendShort(WS_Success);
WriteBuffer anEncryptBuf;
anEncryptBuf.AppendShort(mSecretA.GetKeyLen());
anEncryptBuf.AppendBytes(mSecretA.GetKey(),mSecretA.GetKeyLen());
ByteBufferPtr anEncrypt = mClientCertificate->GetPubKey().Encrypt(anEncryptBuf.data(),anEncryptBuf.length());
if(anEncrypt.get()==NULL)
return WS_PeerAuthServer_FailedToEncryptWithClientPubKey;
aComplete.AppendShort(anEncrypt->length());
aComplete.AppendBytes(anEncrypt->data(),anEncrypt->length());
mSession = new AuthSession(mAuthType, 0, mSecretB, mLengthFieldSize);
}
theComplete = aComplete.ToByteBuffer();
return WS_Success;
}
示例3: Encrypt
WONStatus AuthSession::Encrypt(ByteBufferPtr &theMsg)
{
mLastUseTime = time(NULL);
if(mAuthType==AUTH_TYPE_NONE || mAuthType==AUTH_TYPE_PERSISTENT_NOCRYPT)
return WS_Success;
WriteBuffer aMsg(mLengthFieldSize);
aMsg.AppendByte(12); // encrypted message
WriteBuffer aSeqBuf;
const char *aBuf = theMsg->data() + mLengthFieldSize;
unsigned short aLen = theMsg->length() - mLengthFieldSize;
if(mAuthType==AUTH_TYPE_SESSION)
{
aMsg.AppendShort(mId);
aSeqBuf.AppendShort(++mOutSeq);
aSeqBuf.AppendBytes(aBuf,aLen);
aBuf = aSeqBuf.data();
aLen = aSeqBuf.length();
}
ByteBufferPtr anEncrypt = mKey.Encrypt(aBuf,aLen);
if(anEncrypt.get()==NULL)
return WS_AuthSession_EncryptFailure;
aMsg.AppendBytes(anEncrypt->data(),anEncrypt->length());
theMsg = aMsg.ToByteBuffer();
return WS_Success;
}
示例4: time
SPAuthCheckPrv::SPAuthCheckPrv(const char *theProduct)
{
mAPI = NULL;
mStatus = WS_None;
mStartedChecking = false;
mOnlyForceCheck = false;
mStartTime = time(NULL);
mGameSecondsBeforeNextCheck = 1;
WriteBuffer aBuf;
aBuf.Reserve(8);
aBuf.AppendLong(0x87ab3215);
aBuf.AppendLong(CDKey::GetMachineId());
mEncryptKey.SetKey(aBuf.data(),aBuf.length());
mAuthContext = new AuthContext;
mCommunity = StringToWString(theProduct);
mProductDir = L"/" + mCommunity;
mCDKey.SetProductString(theProduct);
mCDKey.LoadFromRegistry();
if(!mCDKey.IsValid())
{
mStatus = WS_AuthServ_InvalidCDKey;
return;
}
if(!AsyncSocket::HasInternetConnection())
{
mStatus = WS_NoInternetConnection;
return;
}
if(WONAPICoreEx::GetInstance()==NULL)
{
mAPI = new WONAPICoreEx;
mAPI->SetDoPumpThread(true);
mAPI->Startup();
}
ReadCheckFile();
}
示例5: aMsg
WONStatus PeerAuthClient::GetChallenge2(ByteBufferPtr &challenge2)
{
mState = STATE_AWAITING_COMPLETE;
WriteBuffer aMsg(mLengthFieldSize);
aMsg.AppendLong(203); // Auth1 Peer To Peer
aMsg.AppendLong(52); // Auth1 Challenge 2
WriteBuffer anEncryptBuf;
anEncryptBuf.AppendShort(mSecretB.GetKeyLen());
anEncryptBuf.AppendBytes(mSecretB.GetKey(), mSecretB.GetKeyLen());
anEncryptBuf.AppendBytes(mSecretA.GetKey(), mSecretA.GetKeyLen());
ByteBufferPtr anEncrypt = mServerCertificate->GetPubKey().Encrypt(anEncryptBuf.data(),anEncryptBuf.length());
if(anEncrypt.get()==NULL)
return WS_PeerAuthClient_Challenge2EncryptFailure;
aMsg.AppendShort(anEncrypt->length());
aMsg.AppendBytes(anEncrypt->data(),anEncrypt->length());
challenge2 = aMsg.ToByteBuffer();
return WS_Success;
}
示例6: ProcessCrossPromotionDoc
void InitLogic::ProcessCrossPromotionDoc(const ByteBuffer* theMsg)
{
WriteBuffer aNewBuffer;
aNewBuffer.AppendBytes(theMsg->data(), theMsg->length());
aNewBuffer.AppendByte(0);
char* aData = aNewBuffer.data();
char aSeparator[] = " \t\n=";
std::string anImageRef("");
mPromotionLink = "";
char* aToken = strtok(aData,aSeparator);
while(aToken!=NULL)
{
if(stricmp(aToken,"link")==0)
{
aToken = strtok(NULL,"\n"); // the rest of the line
if(aToken!=NULL)
mPromotionLink = aToken;
}
else if(stricmp(aToken,"image")==0)
{
aToken = strtok(NULL,"\n"); // the rest of the line
if(aToken!=NULL)
anImageRef = aToken;
}
if(aToken)
aToken = strtok(NULL,aSeparator);
}
if(anImageRef.length())
{
HTTPGetOpPtr anImageOp = new HTTPGetOp(anImageRef);
anImageOp->SetHTTPCache(HTTPCache::GetGlobalCache());
anImageOp->SetCompletion(new InitLogicCompletion(GetCrossPromotionCompletion,this));
mHTTPSession->AddOp(anImageOp);
}
}
示例7: WriteCheckFile
void SPAuthCheckPrv::WriteCheckFile()
{
if(mGameSecondsBeforeNextCheck==1) // Remove file to force check next time
{
WONFile aFile(gSPAuthCheck_FileName);
aFile.Remove();
return;
}
// Write new file
try
{
FileWriter aWriter;
if(!aWriter.Open(gSPAuthCheck_FileName))
return;
WONFile aFile(gSPAuthCheck_FileName);
WriteBuffer anEncrypt;
anEncrypt.AppendString("magic");
anEncrypt.AppendLong(aFile.GetCreateTime()); // file creation time
anEncrypt.AppendLong(mGameSecondsBeforeNextCheck);
ByteBufferPtr aBuf = mEncryptKey.Encrypt(anEncrypt.data(),anEncrypt.length());
if(aBuf.get()==NULL)
return;
aWriter.WriteShort(aBuf->length());
aWriter.WriteBytes(aBuf->data(),aBuf->length());
}
catch(FileWriterException&)
{
}
}