Skip to main content

USMP - Unified Secure Multi-transport Protocol

⚠️ Note: This repository is a read-only distribution mirror of the USMP monorepo. All development, pull requests, and issues should be submitted to metaloomlabs/usmp.

Secure, encrypted communication for ESP32, Arduino, and IoT devices.

USMP sits between raw sockets (no security) and full TLS/DTLS (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
  • Multiple Transports - Production-ready support for both TCP and UDP streams.

Quickstart

Server

import asyncio
from usmp import USMPServer, USMPSession, USMPProtocol, ConnectionClosedError

# Initialize server
server = USMPServer(host="0.0.0.0", port=9000, psk=b"your-psk-here", protocol=USMPProtocol.TCP)

@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}")

async def main():
    await server.serve()

if __name__ == "__main__":
    asyncio.run(main())

Client (Python)

import asyncio
from usmp import USMPClient, USMPProtocol

async def main():
    # Initialize client
    client = USMPClient(host="127.0.0.1", port=9000, psk=b"your-psk-here", protocol=USMPProtocol.TCP)
    await client.connect()
    
    await client.send(b"hello")
    reply = await client.recv()
    print(f"RX: {reply}")
    
    await client.disconnect()

if __name__ == "__main__":
    asyncio.run(main())

Client (Arduino ESP32)

#include <USMP.h>

USMPClient usmp("your-psk-here");

void setup() {
    // Connect using TCP or UDP
    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 directly through their respective package registries:

  • ESP-IDF Component: Add as a dependency by running idf.py add-dependency "metaloomlabs/usmp" in your project directory.
  • Arduino Library: Import the packaged release ZIP archive usmp-1.0.1-arduino.zip via Sketch ➔ Include Library ➔ Add .ZIP Library...

USMP™ • Developed by Metaloom

Release files for usmp 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for usmp 1.2.1
File Size Uploaded
usmp-1.2.1.tar.gz 25.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for usmp 1.2.1
File Interpreter ABI Platform
usmp-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 56.1 kB

Release files / usmp-1.2.1.tar.gz

Download URL usmp-1.2.1.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a1bde9855934ae0409f9188f2c7b3ca403eacbf644350c2887e8b66f5611f738
BLAKE2b-256 checksum
How to use checksums
6e18e40f3e3ed095ea31e515034187cbc88ac2882329b644472613244eb9d74f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.21

Release files / usmp-1.2.1-py3-none-any.whl

Download URL usmp-1.2.1-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e9846cac24223b48c4a98e4191cc5bf6341aeef099b382c77e7ed20b83fe2df
BLAKE2b-256 checksum
How to use checksums
a6d698628265daf41164f66a9b83a0a1d5e0cfdaf3de6bfce29e3566c1a28197
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.21

Release history Release notifications | RSS feed

1.2.2

2 release files

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.5.1

2 release files

0.4.7

2 release files

0.4.4

2 release files

0.4.2

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page