A requests-like wrapper for PQC-enabled curl supporting ML-KEM
Project description
A small scaffold for PQC-aware request tooling.
Contents:
requests_pqc.py— the Python packageexamples/— small example usage scriptstest- contains sample server to test the implementation
# requests_pqc
Lightweight helpers for making HTTP requests with a focus on experimenting with
post-quantum-capable TLS handshakes. This package is intentionally minimal and
depends on the system `curl` CLI (the current implementation invokes `curl` via
subprocess).
Important: the implementation shipped in `requests_pqc.py` uses the `curl` binary
and parses its verbose output to infer the negotiated KEM/group. Make sure `curl`
is installed and available on PATH.
Contents
- `requests_pqc.py` — module exposing `request(...)` and convenience helpers
(`get`, `post`, `put`, `patch`, `delete`). The module returns a `PQCResponse`
object containing `status_code`, `text`, and `kem_algo` (the parsed negotiated
KEM/group when available).
- `server.py` — a small dummy HTTP(S) server useful for local testing.
- `examples/` — runnable example scripts demonstrating usage.
- `tests/` — pytest-based integration tests that exercise the library against
the dummy server.
Requirements
- Python 3.8+
- Curl 8.0+
- OpenSSL 3.5+
Quick install (dev editable install into a venv):
```bash
#From PyPI org
pip install requests_python
# activate your venv first, then from the package root:
python -m pip install -e .
python -m pip install pytest
API
Class
PQCResponse(status_code, text, kem_algo)— simple container returned byrequest(...).
Top-level function
request(method, url, mode='classical', data=None, headers=None, verify=True, cacert=None, **kwargs)- method: HTTP verb as a string (e.g. 'GET', 'POST')
- url: target URL
- mode: one of
classical,hybrid,pure. The implementation maps these to curl-compatible curve/KEM strings when invokingcurl. - data: request payload (string or object; passed to curl
-d) - headers: dict of headers to send
- verify: boolean. When False,
-kis passed to curl to skip TLS verification. - cacert: path to CA bundle file. When provided and
verifyis True, the curl--cacertoption will be used to verify the server cert.
Convenience helpers: get, post, put, patch, delete map to request.
Examples
Basic GET (allow self-signed certs):
import requests_pqc
r = requests_pqc.get('https://127.0.0.1:8443/items', verify=False)
print(r.status_code, r.kem_algo)
print(r.text)
POST with JSON-like payload and verification disabled:
payload = {'name': 'alice'}
r = requests_pqc.post('https://127.0.0.1:8443/items', data=payload, verify=False)
print(r.status_code, r.kem_algo)
Verify using a CA bundle file (positive verification):
r = requests_pqc.get('https://secure.example', verify=True, cacert='/path/to/ca.pem')
Notes and limitations
- This implementation shells out to the
curlCLI and parses verbose stderr output to find the negotiated KEM/group. The parsing is brittle and depends on thecurl/OpenSSL versions and their debug message format. - For production or reliable behavior, consider using a proper HTTP/TLS client
library (e.g.,
requests+ a TLS backend) or a pycurl binding that exposes the needed libcurl APIs directly. - The
mode -> curvemappings are heuristic. Confirm the strings your local curl/OpenSSL accepts.
Testing with the bundled dummy server
- Start the dummy HTTPS server (it will generate a self-signed cert if none exists):
python requests_pqc/server.py
- Run the pytest integration tests (they are written to accept the
self-signed certs by setting
verify=Falsewhere appropriate):
python -m pytest -q
Contributing
- Feel free to open issues or PRs. If you want more robust TLS handling I recommend proposing a pycurl-based or native Python TLS implementation and adding tests that cover verification behavior.
License
- MIT (or whatever license you choose — include a LICENSE file if needed)
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 requests_pqc-0.1.1.tar.gz.
File metadata
- Download URL: requests_pqc-0.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25a880fea81e56d0c9f7488793dae1fd2d7275b49d487174c8522ee38027cd34
|
|
| MD5 |
a2babdaea69d82fe21b55bb5812985c3
|
|
| BLAKE2b-256 |
c6fe1866d79da06d0541a77346d1bd19f03ff1eb338691ffd7baf2a345485390
|
File details
Details for the file requests_pqc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: requests_pqc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbc9a86bbf268d9c88af188de4e8993c55f880711c63f18750fd037e11371454
|
|
| MD5 |
c95c1440c4dfed4998f29df60e37f070
|
|
| BLAKE2b-256 |
4e0351ae77e5d437525a6044c8001285507648833aff50b260e48b4e45e7a249
|