[EMAIL PROTECTED] wrote:
Hi everyone,

I wonder if anyone here could point me in the right direction. My question isn't directly Crypto++ related, but I may end up using it to solve my problem. I'm not a cryptography expert.
A good resource would be "Practical Cryptography" by Neils Ferguson & Bruce Schneier.
I'd like to implement a secure communication over TCP/IP or UDP between two of my applications within a local network. I got the client/server part all written and working, talking back and forth. However, I need to encrypt the contents of these messages to make them tamper-proof. Typically these are just a few bytes every few minutes. Setting up an SSL connection is not an option, so I need to encrypt them at the source level.
Encryption does not make your messages tamper-proof. Encryption makes the message unreadable to a third party. If you are only interested in making the messages tamper proof, then what you need is a MAC (which stands for Message Authentication Code) of the data so that you can verify the integrity of the message. If you also want the messages to be encrypted, you can do both -- generate a MAC (or HMAC) of the data, then encrypt the data along with the MAC so that after decryption, the MAC can be verified and data integrity ensured.
I'm willing to read up on this, but before I choose an algorithm and 
implementation, can you comment on how to do this in a secure and effective way?
Thanks in advance,
A good start would be to use Google to read about MACs and HMACs. They are for verifying data integrity. Then read about symmetric encryption if you need to keep your messages secret. The algorithm you choose will depend greatly on the amount of security you need. AES would be one obvious (and standard) choice. Once you've settled on an encryption algorithm, you'll need to decide whether you need to worry about replay attacks (where an attacker injects previously sent packets into the data stream) and if so, decide how you will handle them. One way would be a simple serial number on each message that is incremented each time a message is sent. You can probably think of others that would be more appropriate for your particular situation. Another attack would be if an attacker is able to remove a message from the stream, how will you handle the case where an expected packet never arrives? The next thing to look into would be Diffie-Hellman key negotiation to help you establish an encryption key for either AES or your HMAC algorithm (or both.) While you're reading about that, pay special attention to Man-in-the-middle attacks and decide whether it is something that you need to concern yourself with. If it is, then you'll need to research methods for preventing that kind of attack. Of course there are also alternatives to Diffie-Hellman, it is just one of many different ways to establish a key.

At any rate, doing all of these things again will depend on the kinds of threats you wish to plan for and how thorough you want to be. Some of the things I've mentioned here may not even be necessary for what you are trying to accomplish. I also may have left things out. I do not consider myself an expert, but I do have experience with setting up encrypted communications between nodes on a network, so I hope that what I've written here will be of some assistance.

   Good luck.

--
Michael Monsen
There are two rules for success in life:
1.  Don't tell people everything you know.

Reply via email to