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.0.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.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file requests_pqc-0.1.0.tar.gz.

File metadata

  • Download URL: requests_pqc-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 5246db6943ebda0f8b72a695b0d06dd76c666f473f1016565c6c817d69013bdc
MD5 7718e1386ab30923d4e40aee2daf6665
BLAKE2b-256 e68dc229a8c999153b629655c4a720ea27ed2399ac0fae36c2aed63f96eb1f31

See more details on using hashes here.

File details

Details for the file requests_pqc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: requests_pqc-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 831ecf26a28f51dc188aa5378c15280e3a70c3c3e394d616de1c69a8ec05c1d1
MD5 766415fc8050f228189b195206e44717
BLAKE2b-256 f8d393b46881cc4778f1c4ea35f0e3d4ef8e8fe2a533791492f6b99feae1b7fc

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