client send encrypted data to server
Hi networking experts,
I originally wrote client and server programs that keep transferring
data back and forth in plain text.
But now i need to encrypt data before send to/from between them.
What is the normal way to achive this ?
I don't think it's only need to ecrypt the data, send it
and assume the other end gets it, decrypt, and done. Do i need to
append a header or something for each block i send...or something that
i'm still not sure..
I'm using winsock api, blocking sockets.
Thanks for any ideas.
[591 byte] By [
kenn] at [2007-11-19 6:09:37]

# 1 Re: client send encrypted data to server
Hello,
I'm currently working with this replacement class someone wrote for CSocket - CSslSocket - that might help you out. But it's more complicated than it looks, so be ready for an involved project! :eek:
http://www.codeproject.com/internet/sslsocket.asp
mjxnjx at 2007-11-11 0:32:16 >

# 2 Re: client send encrypted data to server
Can you sum up some ways to handle the send/receive parts ?
It's kind of hard to go thru the code and figureout what in there...
Thanks
kenn at 2007-11-11 0:33:17 >

# 3 Re: client send encrypted data to server
Can you sum up some ways to handle the send/receive parts ?
Well, it's upto you how to encode and decode. One can use the simplest form, say, if you are sending ANSI strings, you could pack the whole stuff stripping out the high bit and sending out.
You could zip the whole data and send it..
You can use public/private key and stuff like that, use CryptoAPI ( Windows provides APIs for this ) etc.. and can do a whole lot of things.
It's kind of hard to go thru the code and figureout what in there...
That's our job , isn't it.. Learn and let learn.. ;)
# 4 Re: client send encrypted data to server
Hi Kirants,
I'm concerning about the receiver side, if i call receive() and got some data,
then should i go ahead to decode/decrypr that block right away ?
or have to call receive() multiple times ?
Thanks again....this is new stuff i need to learn...
kenn at 2007-11-11 0:35:26 >

# 5 Re: client send encrypted data to server
I beleive you are talking about recv() socket function, right ?
If that is so, yes, you need to keep calling recv() and check if you have received the proper frame. And how do you know that. That is specified by the protocol you use for communication. That is were some form of headers specifying the client ID, the lenght of data to follow etc will help.
So, the sender would send this header first. and continue with the data. Teh receiver will receive the data, check for the header , get the length of data to follow and shall know that it needs to call recv again..
# 6 Re: client send encrypted data to server
ah, thanks...i meant recv()...Your explaination really cleared up my confusion...
The sender must send the "length of the data" to the server. Is that the only
choice ? or people still have other ways ?
Thanks...
Appreciate that.
kenn at 2007-11-11 0:37:22 >

# 7 Re: client send encrypted data to server
To tell you frankly, I don't know. I have minimum exposure on sockets and stuff. But if one things logically, that makes sense, right ? if you do not define a protocol, how would you ever communicate.