Skip to main content

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 package
  • examples/ — small example usage scripts
  • test - 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 by request(...).

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 invoking curl.
    • data: request payload (string or object; passed to curl -d)
    • headers: dict of headers to send
    • verify: boolean. When False, -k is passed to curl to skip TLS verification.
    • cacert: path to CA bundle file. When provided and verify is True, the curl --cacert option 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 curl CLI and parses verbose stderr output to find the negotiated KEM/group. The parsing is brittle and depends on the curl/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 -> curve mappings are heuristic. Confirm the strings your local curl/OpenSSL accepts.

Testing with the bundled dummy server

  1. Start the dummy HTTPS server (it will generate a self-signed cert if none exists):
python requests_pqc/server.py
  1. Run the pytest integration tests (they are written to accept the self-signed certs by setting verify=False where 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests_pqc-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

requests_pqc-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

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

Hashes for requests_pqc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 25a880fea81e56d0c9f7488793dae1fd2d7275b49d487174c8522ee38027cd34
MD5 a2babdaea69d82fe21b55bb5812985c3
BLAKE2b-256 c6fe1866d79da06d0541a77346d1bd19f03ff1eb338691ffd7baf2a345485390

See more details on using hashes here.

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

Hashes for requests_pqc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cbc9a86bbf268d9c88af188de4e8993c55f880711c63f18750fd037e11371454
MD5 c95c1440c4dfed4998f29df60e37f070
BLAKE2b-256 4e0351ae77e5d437525a6044c8001285507648833aff50b260e48b4e45e7a249

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page