unfortunately sending cannot be made transparent for the derived class, because of WSA_WOULDBLOCK together with the fact that each byte must pass the keystream only once
| 182 | // unfortunately sending cannot be made transparent for the derived class, because of WSA_WOULDBLOCK |
| 183 | // together with the fact that each byte must pass the keystream only once |
| 184 | int CEncryptedStreamSocket::Write(const void* lpBuf, uint32_t nBufLen) |
| 185 | { |
| 186 | //printf("Starting write for %s\n", (const char*) unicode2char(GetPeer())); |
| 187 | if (!IsEncryptionLayerReady()) { |
| 188 | wxFAIL; |
| 189 | return 0; |
| 190 | } else if (m_bServerCrypt && m_StreamCryptState == ECS_ENCRYPTING && !m_pfiSendBuffer.IsEmpty()) { |
| 191 | wxASSERT( m_NegotiatingState == ONS_BASIC_SERVER_DELAYEDSENDING ); |
| 192 | // handshakedata was delayed to put it into one frame with the first paypload to the server |
| 193 | // do so now with the payload attached |
| 194 | int nRes = SendNegotiatingData(lpBuf, nBufLen, nBufLen); |
| 195 | wxASSERT( nRes != SOCKET_ERROR ); |
| 196 | (void)nRes; |
| 197 | return nBufLen; // report a full send, even if we didn't for some reason - the data is now in our buffer and will be handled later |
| 198 | } else if (m_NegotiatingState == ONS_BASIC_SERVER_DELAYEDSENDING) { |
| 199 | wxFAIL; |
| 200 | } |
| 201 | |
| 202 | if (m_StreamCryptState == ECS_UNKNOWN) { |
| 203 | //this happens when the encryption option was not set on an outgoing connection |
| 204 | //or if we try to send before receiving on an incoming connection - both shouldn't happen |
| 205 | m_StreamCryptState = ECS_NONE; |
| 206 | //DebugLogError(_T("CEncryptedStreamSocket: Overwriting State ECS_UNKNOWN with ECS_NONE because of premature Send() (%s)"), GetPeer()); |
| 207 | } |
| 208 | |
| 209 | //printf("Writing %i bytes of data\n", nBufLen); |
| 210 | return CSocketClientProxy::Write(lpBuf, nBufLen); |
| 211 | } |
| 212 | |
| 213 | int CEncryptedStreamSocket::Read(void* lpBuf, uint32_t nBufLen) |
| 214 | { |
no test coverage detected