On 5/1/2011 1:34 AM, derleader mail wrote:

I'm going to use stream protocol - TCP/IP. Here is the template source
code of the server without the encryption part

We mean application protocol.

while (1) {
sock = accept(listensock, NULL, NULL);
printf("client connected to child thread %i with pid %i.\n",
pthread_self(), getpid());
nread = recv(sock, buffer, 25, 0);
buffer[nread] = '\0';
printf("%s\n", buffer);
send(sock, buffer, nread, 0);
close(sock);
printf("client disconnected from child thread %i with pid %i.\n",
pthread_self(), getpid());
}
}

This code isn't very helpful. It just reads and writes the very same data. Nothing in this code tells us, for example, how to identify a complete message.

You could interpose an encryption protocol that also imposed no such requirements. You would need to work out your own padding though. Blowfish is a block encryption algorithm and cannot encrypt just a single byte. So if you only read one byte, you'd need to pad it before encryption and then you'd need some way to remove the padding on the other end.

I would strongly urge you to just use SSL. It is designed for *exactly* this purpose.

DS

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to