For my CS428 secure protocols course at NIT Warangal, I built a system where two drones that have never met can authenticate each other and set up an encrypted channel, all without calling home to any server while they're in the air. The whole thing is in Python, split across four files: `gcs.py`, `drone.py`, `session.py`, and `attacks.py`.
How the protocol works
Before takeoff, a Ground Control Station (GCS) registers each drone and signs a certificate binding the drone's ID to its Ed25519 public key, with an expiry date. Think of it as the GCS handing each drone a passport before it leaves the ground.
Once two drones meet in the air, they run a three-message handshake. Drone A sends its certificate, an ephemeral X25519 key, a 128-bit nonce, a timestamp, and a signature over all of it. Drone B replies with the same things plus a signature that covers both messages. Then A sends an HMAC confirmation. After that, both sides run HKDF-SHA256 over the X25519 shared secret, using the two nonces as salt, to get a pair of keys: one for encryption and one for MAC. All actual traffic after that goes through AES-256-GCM with a nonce built from the sender's role and a counter.
The nonces and timestamps together handle replay attacks. The ephemeral keys mean that even if a long-term key leaks later, past sessions stay private. That's the forward secrecy property, and it comes essentially for free once you commit to ephemeral Diffie-Hellman.
What each file does
I split the code so that four people could each present one piece, about three minutes each. `gcs.py` handles registration, certificate signing, and revocation. It imports nothing from the other files, so it's the natural starting point. `drone.py` runs the M1, M2, M3 handshake and does all the signature and certificate checks. `session.py` has the key derivation with HKDF, the HMAC key confirmation, and the AES-GCM session layer. `attacks.py` pulls everything together and runs 14 security checks, things like replayed messages, tampered nonces, expired certificates, and captured drones that got revoked. All 14 pass.
The only external dependency is the `cryptography` package at version 42 or above, which gives you Ed25519, X25519, HKDF, HMAC, and AES-GCM in one place without having to wire together separate libraries.
Where this could run on AWS
Right now this is a local simulation, but the GCS piece maps pretty naturally onto cloud infrastructure. I'd use AWS IoT Core to handle drone registration and certificate management, since it already has a certificate authority model and a device registry. The revocation list that `gcs.py` maintains could live in DynamoDB, which would let multiple ground stations read and update it without stepping on each other. For the actual key material and GCS signing key, AWS KMS would be a safer home than a file on disk. If I wanted to log handshake events or flag anomalies, I'd pipe the data through Amazon Kinesis into CloudWatch. The in-flight peer-to-peer handshake itself would still run on the drones directly, since the whole point is that it works without server contact mid-flight, but the ground infrastructure around it has a clear AWS shape.
Loading article