A Windows C++ networking demo: discover a peer over UDP, establish a TCP connection, and exchange length-prefixed AES-CBC messages. The repository keeps discovery, transport and the educational AES implementation in separate modules.
Demo protocol, not a secure channel. The AES key is public in CryptoConfig.h. Discovery is unauthenticated, and CBC packets have no authentication tag or replay protection. A random IV and valid padding do not authenticate a sender or prevent message modification. Do not use this protocol for credentials or sensitive traffic; an application needing that property should use an established authenticated transport.
Windows, C++17 and CMake 3.16+. The build links Winsock and Windows BCrypt; Linux/macOS are not currently supported.
cmake -S . -B build
cmake --build build --config Release
ctest --test-dir build -C Release --output-on-failureOpen the root CMake project in Visual Studio or Qt Creator, or use the retained Visual Studio solution. The CMake build is tested with MinGW-w64. For Visual Studio generators, add Release/ below each executable directory in the examples.
Start the server, then the client in a second terminal:
& ".\build\EasyConnect Server\easyconnect_server.exe" --listen
& ".\build\EasyConnect Client\easyconnect_client.exe" --connect 127.0.0.1Enter a line to receive the same bytes back. An empty console line or EOF closes the client. The reusable packet API also supports empty and binary messages.
For LAN discovery, start both programs with --discover within about ten seconds of each other. The server opens TCP 9008 before broadcasting on UDP 9009, avoiding the earlier connection race. The client listens for discovery and replies with the received token. Direct mode can also bind a specified IPv4 address with --listen 192.168.1.10.
The demo handles one client and then exits. Discovery expires after approximately ten seconds, accepting a client after thirty seconds, and individual TCP send/receive operations after two minutes. TCP connection setup uses the operating system's connect timeout. These are blocking demo APIs, not a concurrent server.
| Layer | Wire format |
|---|---|
| Discovery | Exactly 16 bytes: little-endian magic 0x000B00B5, version 1, then a 64-bit random token |
| TCP header | Four-byte big-endian length of the following body |
| TCP body | 16-byte random IV followed by AES-CBC ciphertext with PKCS#7 padding |
| Message limit | 1 MiB plaintext; body must be 32–1,048,608 bytes and block-aligned after the IV |
IVs and discovery tokens use the Windows system random generator. Receivers validate lengths before allocating a body and check every padding byte. receivePacket distinguishes an empty message from EOF; the legacy recvPacket convenience wrapper cannot.
The wire layout remains compatible with the original Windows demo. The server now echoes payload bytes exactly instead of adding a greeting. Errors are reported with a nonzero exit status. Malformed packets close the session.
| Location | Responsibility |
|---|---|
| Common/Socket.h | Noncopyable socket/Winsock lifetimes, IPv4 endpoints and timeouts |
| Common/DiscoveryCommon.h | Explicit discovery encoding and validation |
| Common/NetUtils.cpp | Framing, bounded I/O and system-generated IVs |
| Common/AES.cpp | Educational AES/CBC implementation and padding |
| EasyConnect Server | Listening, announcement and one-client echo |
| EasyConnect Client | Discovery, connection and console interface |
| tests/protocol_tests.cpp | Independent cipher checks and loopback integrations |
Tests compare AES-128/192/256 output with Windows CNG, cover block and padding boundaries, reject malformed frame lengths, distinguish empty messages from EOF, and exercise discovery plus TCP exchange on loopback. No LAN broadcast or remote traffic is needed by the tests. This is functional verification, not a cryptographic audit.
No license file is currently included in this repository.