Encrypted Patterns is a single client to server demo written in C that transmits encrypted pattern data from a client to a server. It demonstrates symmetric encryption, message signing, TCP sockets, and command-line interface handling with getopt.
- Client connects to server and reads in user input.
- The client encrypts messages and includes a pre-generated signature that authenticates the client to the server.
- Server recieves packet and checks the signature.
- On a bad signature, it disconnects the client and shuts down.
- With a good signature, the server checks if the client requested to close the connection.
- If the client requested to close the conneciton, it disconnects the client and shuts down.
- Server decrypts the message from the client, and sends "ACK" if the message was recieved sucessfully.
- On ACK, client sends a new message. On NACK, the client retries three times then disconnects.
- Run on a Linux machine or VM with
gcc&cmakeinstalled. - Install the latest version of OpenSSL:
sudo apt install openssl- Clone the repository.
- In this directory, run
make - In the
keysfolder, runbash keygen.sh - In one terminal, run the server using the instructions in Server Usage.
- In another terminal, run the client using the instructions in Client Usage. An example file,
pattern1.txt, is provided for the-foption.
./server -t PORT
Recieve an encrypted 8 byte value.
| Arg | Opt | Desc |
|---|---|---|
| -t | PORT | set the port for TCP |
./server -t 8001./client [-h] [-v] -t PORT (-f FILE | -p VALUE,TIME)
Send encrypted 8 byte values in a pattern to a server.
| Arg | Opt | Description |
|---|---|---|
| -t | PORT | set the port for TCP |
| -h | show this help message and exit | |
| -v | enable verbose output | |
| -p | VALUE(hex),TIME(ms) | specify pattern, can repeat for a sequence. |
| -f | FILE | specify a text file with <VALUE> <TIME> lines |
./client -v -f assets/pattern1.txt -t 8001
./client -p 0x01,200 -p 0xff,500 -p 0x32,200 -t 8001- Language: C
- Tools Getopt, OpenSSL