USMP - Unified Secure Multi-transport Protocol. Secure, encrypted device communication for ESP32, Arduino and IoT.
Project description
USMP - Unified Secure Multi-transport Protocol
Secure, encrypted communication for ESP32, Arduino, and IoT devices.
USMP sits between raw TCP (no security) and full TLS (too heavy for microcontrollers) - giving any constrained device a fully encrypted, mutually authenticated session in three function calls.
pip install usmp
What it gives you
- Mutual authentication - both device and server verify each other via HMAC-SHA256 + PSK
- Forward secrecy - X25519 ephemeral key exchange, new keys every session
- Encryption - AES-256-GCM, mandatory, no plaintext mode
- Replay protection - monotonic sequence numbers
Quickstart
Server
import asyncio
from usmp import USMPServer, USMPSession, ConnectionClosedError
server = USMPServer(host="0.0.0.0", port=9000, psk=b"your-psk-here")
@server.on_session
async def handle(session: USMPSession):
print(f"Device connected: {session.device_id}")
try:
while True:
data = await session.recv()
print(f"RX: {data}")
await session.send(b"got it")
except ConnectionClosedError:
print(f"Device disconnected: {session.device_id}")
asyncio.run(server.serve())
Client (Python)
import asyncio
from usmp import USMPClient, ConnectionClosedError
async def main():
client = USMPClient(host="127.0.0.1", port=9000, psk=b"your-psk-here")
async with client.connect() as session:
await session.send(b"hello")
reply = await session.recv()
print(f"RX: {reply}")
asyncio.run(main())
Client (ESP32 / Arduino)
#include <USMP.h>
USMPClient usmp("your-psk-here");
void setup() {
usmp.begin(USMP::TCP("192.168.1.100").wifi("SSID", "password"));
usmp.send("hello from esp32");
}
void loop() {
usmp.maintain(); // keepalive + reconnect
if (usmp.available()) {
Serial.println(usmp.read());
}
}
Protocol overview
Device Server
| |
|-- HELLO (device_id, pub_C) -->|
|<- CHALLENGE (nonce, pub_S) ---|
|-- HELLO_ACK (HMAC) ---------->|
|<- SESSION_OK (session_id) ----|
| |
|== AES-256-GCM encrypted ======|
4-step handshake, then every frame is AES-256-GCM encrypted with a session key derived via X25519 + HKDF-SHA256.
Installation
pip install usmp
Requires Python 3.11+.
ESP32 / Arduino library
The Arduino library and ESP-IDF component are available at github.com/metaloomlabs/usmp.
USMP™ • Developed by Metaloom
Copyright © 2026 Akhil B Xavier (winterx64)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file usmp-0.3.0.tar.gz.
File metadata
- Download URL: usmp-0.3.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91c6c1d2172532422e988498be79310308a726cb8db488f781bb1d5b396e6fcb
|
|
| MD5 |
020041deca875dbe7bbfe05efe408489
|
|
| BLAKE2b-256 |
da7b914a01fd63c49a5cd6338e7077ea43f4e4c218f9978b548191aab9807882
|
File details
Details for the file usmp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: usmp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7ee82cf4b0e69c86ff3591a631a737e74be54d30182fc97cf8bc43d1793313e
|
|
| MD5 |
82cba8c2de5e03da485968d3455b4bf6
|
|
| BLAKE2b-256 |
bf3d54ff246987ca779c8b57a589ea04085289b2999f70b5b411a86b8ff556b2
|