CTCPSocketAsyncBlowFish Class Reference#include <TCPSocketAsyncBlowFish.h>
Inheritance diagram for CTCPSocketAsyncBlowFish:
![]()
Collaboration diagram for CTCPSocketAsyncBlowFish:
![]()
Detailed DescriptionDefinition at line 59 of file TCPSocketAsyncBlowFish.h. Constructor & Destructor Documentation
Definition at line 49 of file TCPSocketAsyncBlowFish.cpp. 00049 : m_aEncryptChain(0xC009F158,0x17EC17EC), 00050 m_aDecryptChain(0xC009F158,0x17EC17EC) 00051 { 00052 }
Member Function Documentation
Definition at line 232 of file TCPSocketAsyncBlowFish.cpp. 00233 { 00234 //Give this socket our key 00235 ((CTCPSocketAsyncBlowFish*)pNewSocket)->SetKey(m_sKey); 00236 00237 //Call upper layer accept 00238 return CTCPSocketAsync::Accept(pNewSocket); 00239 }
Definition at line 64 of file TCPSocketAsyncBlowFish.cpp. 00067 { 00068 //Call upper layer 00069 int iResult; 00070 iResult=BlowFishBaseClass::ReceiveMsg(pData, 00071 iSize, 00072 iMoreMessages); 00073 00074 //Did we get it? 00075 if (iResult<=0) 00076 return iResult; 00077 00078 //Try to decrypt the message 00079 if (!DecryptMemory(pData, 00080 iResult)) 00081 return -4; 00082 00083 //Get the original size 00084 int iOriginalSize; 00085 memcpy(&iOriginalSize, 00086 pData, 00087 sizeof(iOriginalSize)); 00088 00089 //Check size makes sense 00090 if (iOriginalSize>iResult || 00091 iOriginalSize<0) 00092 //Encryption problem 00093 return -4; 00094 00095 //Move the memory 00096 memcpy(pData, 00097 pData+sizeof(iOriginalSize), 00098 iOriginalSize); 00099 00100 //Done 00101 return iOriginalSize; 00102 }
Definition at line 146 of file TCPSocketAsyncBlowFish.cpp. 00149 { 00150 //Copy the data 00151 char* pNewData; 00152 pNewData=new char[iSize+256]; 00153 00154 //Save the size 00155 memcpy(pNewData, 00156 &iSize, 00157 sizeof(iSize)); 00158 00159 //Copy the data 00160 memcpy(pNewData+sizeof(iSize), 00161 pData, 00162 iSize); 00163 00164 //Backup the chain 00165 blowfish::Block aChain(m_aEncryptChain); 00166 00167 //Encrypt it 00168 unsigned long ulNewSize; 00169 ulNewSize=EncryptMemory(pNewData, 00170 iSize+sizeof(iSize)); 00171 00172 //Try to send it 00173 int iResult; 00174 iResult=BlowFishBaseClass::SendMsg(pNewData, 00175 ulNewSize, 00176 pStopEvent); 00177 00178 //Discard the data 00179 delete [] pNewData; 00180 00181 //Did we manage? 00182 if (iResult!=ulNewSize) 00183 //Revert the chain 00184 m_aEncryptChain=aChain; 00185 00186 //Done 00187 return iResult; 00188 }
Definition at line 104 of file TCPSocketAsyncBlowFish.cpp. 00106 { 00107 //Copy the data 00108 char* pNewData; 00109 pNewData=new char[iSize+256]; 00110 00111 //Save the size 00112 memcpy(pNewData, 00113 &iSize, 00114 sizeof(iSize)); 00115 00116 //Copy the data 00117 memcpy(pNewData+sizeof(iSize), 00118 pData, 00119 iSize); 00120 00121 //Backup the chain 00122 blowfish::Block aChain(m_aEncryptChain); 00123 00124 //Encrypt it 00125 unsigned long ulNewSize; 00126 ulNewSize=EncryptMemory(pNewData, 00127 iSize+sizeof(iSize)); 00128 00129 //Try to send it 00130 int iResult; 00131 iResult=BlowFishBaseClass::SendMsg(pNewData, 00132 ulNewSize); 00133 00134 //Discard the data 00135 delete [] pNewData; 00136 00137 //Did we manage? 00138 if (iResult!=ulNewSize) 00139 //Revert the chain 00140 m_aEncryptChain=aChain; 00141 00142 //Done 00143 return iResult; 00144 }
The documentation for this class was generated from the following files: |