I build the computer appliance system that consist of software server and multiple controllers. The system I want to build must be pluggable in the sense that when I connect a controller C to the network, the server S will immediately finds it after initial message exchange(Step 1). After an initiation phase both C and S start TCP servers and able to send and receive messages to each other during multiple sessions (Step 2) without need for repeating Step 1 between sessions.
And now several challenges that I should to resolve
- Prevent spoofing of C and/or S on Step 1
- Prevent spoofing of C and/or S on Step 2
- Prevent replay attack on Step 2
- Ensure message confidentiality on Step 2
And here are some thougts about it:
- I should authenticate both sides on Step 1 to solve the first problem.
- I should perform the key exchange on Step 1
- I should encrypt all messages on Step 2 with symmetric key that have been received while Step 1 key exchange to solve the fourth problem.
- I should use nonces or timestamps on Step 2 to solve the second and third problems
Finally I want to ask some questions:
- Are my thoughts about solving the problems right?
- What is the best protocol for performing both authentication and key exchange at the same-time?
EDIT: The messages sended infrequently, so I need a lightweight protocol on Step 2. The protocol must be stateful of course to store symmetric key and possibly other auth info between sessions.