qguard
Find the cryptography a quantum computer will break, get a prioritised plan to replace it, and replace it with post-quantum wrappers.
qguard audits source code, dependencies, servers (VPS), websites, SSH,
VPNs, keys, certificates and software signatures, then writes a detailed
quantum-safe analysis with recommendations. Its wrap module puts ML-KEM,
ML-DSA, hybrids and every Open Quantum Safe
(liboqs) algorithm behind one small API.
Contents: Install · Run it from a phone · Scan a project · Check a website · Check a server · Check signatures · Reports · Read the results · CI · False positives · Migrate with the wrappers · Python API · Troubleshooting · Reference
1. Install
Needs Python 3.9 or newer.
pip install qguard # scanner + ML-KEM / ML-DSA wrappers
pip install "qguard[oqs]" # + liboqs: HQC, Falcon, SLH-DSA, FrodoKEM, McEliece...
# straight from GitHub (before a PyPI release, or for the latest code)
pip install "git+https://github.com/700799/qguard"
Check it works:
qguard --version
qguard backends # which post-quantum backends are usable here
The command is qguard; python -m qguard works too.
2. Run it without a terminal
This repository ships a ready-made GitHub Actions workflow, so you can scan from a browser or the GitHub mobile app.
- Open the repository on GitHub and go to Actions.
- Pick Quantum-safe scan, then Run workflow.
- In targets, type what to scan, separated by spaces. For example:
. https://example.com ssh://example.com - Press Run workflow. When it finishes, open the run: the full report is on
the Summary page, and an HTML copy is attached as the
quantum-reportartifact.
To scan a different repository this way, copy .github/workflows/scan.yml into
it and change pip install . to pip install qguard.
3. Scan a project
cd my-project
qguard scan .
You get a score, a verdict, and findings grouped in the order to fix them:
Score 83/100 (grade B)
Verdict Not quantum-ready: confidentiality depends on key exchange or encryption that a
quantum computer breaks.
Found 0 critical 1 high 1 medium 0 low 2 info
== Protect confidentiality: harvest now, decrypt later (1) ==
[HIGH] X25519 key exchange
at app/session.py:14
What to do:
- Move key establishment to ML-KEM-768 (FIPS 203), ideally as a hybrid with X25519 ...
Useful options:
| You want | Command |
|---|---|
| The reason and fix under every finding | qguard scan . -v |
| Only the serious ones | qguard scan . --min-severity high |
| Skip a folder | qguard scan . --exclude "legacy/*" |
Include .md / .txt docs |
qguard scan . --include-docs |
| One file | qguard scan path/to/file.py |
| Several things at once | qguard scan ./api ./web https://example.com |
4. Check a website
qguard web example.com
qguard web example.com:8443 api.example.com
It reports whether the server accepts post-quantum key exchange
(X25519MLKEM768 and friends), whether TLS 1.3 is on, and what the
certificate chain is signed with.
[OK] Post-quantum TLS key exchange supported: sessions from current browsers are protected against record-now-decrypt-later.[HIGH] TLS key exchange is classical only: fix it on the server, see step 5.- A certificate finding is normal today: public CAs do not issue post-quantum certificates yet. A short-lived certificate is rated low.
Only probe hosts you are authorised to test. The probe sends a few ordinary TLS hellos; it never logs in or sends data.
5. Check a server (VPS)
From outside, see what the server actually offers:
qguard ssh my-vps.example.com # SSH key exchange, host keys, ciphers
qguard web my-vps.example.com # TLS on 443
On the server, audit its configuration in place (read-only; use sudo so
it can read everything):
sudo qguard host
That reads the usual locations: sshd, nginx, Apache, HAProxy, Caddy, OpenSSL, WireGuard, OpenVPN, strongSwan, Postfix, Dovecot, host keys, Let's Encrypt certificates, and the installed OpenSSL / OpenSSH / GnuPG versions.
Fix the two things that matter most, then re-check:
-
SSH key exchange (OpenSSH 9.9 or newer). In
/etc/ssh/sshd_config:KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,curve25519-sha256
Then
sudo sshd -t && sudo systemctl reload ssh. Keep your current session open until a new login works. -
TLS key exchange (needs OpenSSL 3.5 or newer;
qguard hosttells you). In nginx:ssl_protocols TLSv1.2 TLSv1.3; ssl_ecdh_curve X25519MLKEM768:X25519:secp384r1;
Then
sudo nginx -t && sudo systemctl reload nginx. The report prints the equivalent line for Apache, HAProxy and Caddy. -
Confirm from outside:
qguard ssh my-vps.example.comandqguard web my-vps.example.comshould now show[OK]for key exchange.
Config files you keep in a repository (an nginx.conf, sshd_config,
wg0.conf, Ansible templates) are checked by plain qguard scan . too.
6. Check software signatures, keys and certificates
qguard sig release.tar.gz.asc # OpenPGP signature
qguard sig app.exe installer.dll # Authenticode
qguard sig app.jar app.apk # JAR / APK v1 signing
qguard sig artifact.sigstore.json # Sigstore / cosign bundle
qguard sig server.crt chain.pem id_ed25519.pub
It tells you which algorithm signed the thing and how urgent that is. Supported:
OpenPGP keys and signatures, SSH signatures (git commit signing), minisign,
Sigstore bundles, PKCS#7, signed JAR/APK, Authenticode, X.509 certificates and
CSRs, PEM / DER / OpenSSH keys, authorized_keys, known_hosts. Private keys
are read only to identify the algorithm; their contents are never printed.
For a token:
qguard jwt eyJhbGciOiJFUzI1NiJ9.eyJzdWIiOiJ4In0.c2ln
7. Make a report to share
qguard scan . -o quantum-report.html # mobile-friendly page
qguard scan . -o quantum-report.md # paste into an issue, PR or wiki
qguard scan . -o findings.json # machine-readable
qguard scan . -o qguard.sarif # GitHub code scanning
qguard scan . -o crypto.cbom.json # CycloneDX 1.6 cryptographic BOM
The format follows the file extension (or pass -f text|md|html|json|sarif|cbom).
Combine targets to get one report for a whole system:
qguard scan ./src https://example.com ssh://example.com -o report.html
The Markdown and HTML reports contain: the score and verdict, what is at risk and why, what is already quantum-safe, recommendations in priority order with the files each one fixes, and ready-to-paste server settings and wrapper code for what was found.
8. Read the results
| Severity | Meaning | When to act |
|---|---|---|
| critical | Broken today, no quantum computer needed: RSA < 2048, RC4, DES, NULL ciphers | Now |
| high | Quantum-vulnerable key exchange or encryption. Data captured today can be decrypted later ("harvest now, decrypt later") | Now, for anything that must stay secret for years |
| medium | Quantum-vulnerable signatures and certificates. Cannot be attacked retroactively, but must be replaced before forgery is possible | Plan it; NIST deprecates these after 2030 |
| low | Pre-standard PQC (Kyber, Dilithium), short-lived classical certificates, unpinned defaults | Tidy up |
| info | Inventory, and quantum-safe crypto already in use ([OK]) |
Nothing |
The report sections follow the same order: Fix now, Protect confidentiality, Plan the signature and certificate migration, Hygiene, Already quantum-safe.
Certificates are rated by how long they will be trusted. NIST IR 8547 deprecates RSA, ECDSA, EdDSA and (EC)DH after 2030 and disallows them after 2035, so a certificate expiring next year is low and one valid past 2035 is high.
The score starts at 100. Each distinct rule costs its weight (critical 25, high 12, medium 5, low 1); repeats of the same rule cost 1/2, 1/3, ... of it, so one systemic issue does not hide everything else. Grades: A 90+, B 75+, C 60+, D 40+, F below.
Look anything up with qguard algs (the whole knowledge base) or
qguard algs kyber768 (one entry).
9. Gate CI on it
# .github/workflows/qguard.yml
name: qguard
on: [push, pull_request]
jobs:
qguard:
runs-on: ubuntu-latest
permissions: { contents: read, security-events: write }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: "3.13" }
- run: pip install qguard
- run: qguard scan . -o qguard.sarif --fail-on high
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: qguard.sarif }
--fail-on high makes the command exit 1 when any high or critical finding
exists. Exit codes: 0 clean (or no --fail-on), 1 threshold reached, 2
bad arguments. Start with --fail-on critical on an existing codebase and
tighten later.
10. Silence false positives
digest = hashlib.md5(data).hexdigest() # qguard: ignore (cache key, not security)
# qguard: ignoreon the line (any comment style)qguard: ignore-fileanywhere in a file's first five lines--exclude GLOB, repeatable- a
.qguardignorefile in the scanned folder, one glob per line
Skipped by default: .git, node_modules, virtualenvs, dist, build,
vendor, and .md / .rst / .txt files.
11. Migrate code with the wrappers
All keys, ciphertexts and signatures are plain bytes; store them however you
store bytes today (base64 in JSON, a BLOB column, a file).
Replace RSA-OAEP / ECIES / sealed boxes
from qguard.wrap import HybridKEM, seal, open_sealed
keys = HybridKEM().keygen() # do once; publish keys.public
blob = seal(keys.public, b"card=4242", aad=b"order-17")
plain = open_sealed(keys.secret, blob, aad=b"order-17")
seal is hybrid: X25519 + ML-KEM-768, then ChaCha20-Poly1305. It stays secure
if either half holds. aad is optional context that must match on both sides.
A tampered or mis-addressed blob raises DecryptionError.
Replace ECDH / X25519 key agreement
from qguard.wrap import HybridKEM
kem = HybridKEM()
server = kem.keygen() # server: publish server.public
ciphertext, client_secret = kem.encapsulate(server.public) # client: send ciphertext
server_secret = kem.decapsulate(server.secret, ciphertext) # server
assert client_secret == server_secret # 32 bytes: feed your KDF / AEAD
Unlike Diffie-Hellman, a KEM is one-directional: one side has a key pair, the other encapsulates to it and sends the ciphertext.
Replace RSA / ECDSA / Ed25519 signatures
from qguard.wrap import HybridSignature
signer = HybridSignature() # Ed25519 + ML-DSA-65
keys = signer.keygen()
sig = signer.sign(keys.secret, b"release-1.0.tar.gz sha256=...")
ok = signer.verify(keys.public, b"release-1.0.tar.gz sha256=...", sig) # True / False
A hybrid signature verifies only if both halves verify. verify returns
False for anything wrong; it does not raise.
Use one algorithm directly
from qguard.wrap import KEM, Signature
kem = KEM("ML-KEM-768") # or "ML-KEM-1024"
kp = kem.keygen()
ct, shared = kem.encapsulate(kp.public)
assert kem.decapsulate(kp.secret, ct) == shared
sig = Signature("ML-DSA-65") # or "ML-DSA-44", "ML-DSA-87"
kp = sig.keygen()
assert sig.verify(kp.public, b"msg", sig.sign(kp.secret, b"msg"))
Use any liboqs algorithm
Same classes, after pip install "qguard[oqs]":
from qguard.wrap import KEM, Signature
Signature("Falcon-512")
Signature("SLH_DSA_PURE_SHA2_128S")
KEM("HQC-3")
KEM("FrodoKEM-976-AES")
Names are liboqs mechanism names. List them with
python -c "import oqs; print(oqs.get_enabled_kem_mechanisms(), oqs.get_enabled_sig_mechanisms())".
Pick a backend
backend= |
Uses | Provides |
|---|---|---|
"auto" (default) |
pyca/cryptography when it has the algorithm, liboqs otherwise | everything installed |
"pyca" |
pyca/cryptography >= 48 | ML-KEM-768/1024, ML-DSA-44/65/87 |
"oqs" |
liboqs-python | every mechanism liboqs enables |
Public keys, ciphertexts and signatures are interchangeable between backends.
Secret keys are not (pyca stores the 32/64-byte FIPS seed, liboqs the
expanded key), so use a secret key with the backend that generated it;
KeyPair.backend records which that was.
Sizes to plan for
| Public key | Secret key | Ciphertext / signature | |
|---|---|---|---|
HybridKEM (X-Wing) |
1216 B | 32 B | 1120 B |
KEM("ML-KEM-768") |
1184 B | 64 B (pyca) | 1088 B |
Signature("ML-DSA-65") |
1952 B | 32 B (pyca) | 3309 B |
HybridSignature() |
1984 B | 64 B (pyca) | 3373 B |
These are far larger than X25519 (32 B) or Ed25519 (64 B signatures): check database column sizes, HTTP header limits and QR codes before switching.
TLS from Python
from qguard.wrap import pq_ssl_context
ctx = pq_ssl_context() # prefers X25519MLKEM768 where the runtime can
print(ctx.qguard_pq) # True if the hybrid group was applied
Pass strict=True to raise instead of silently staying classical. Applying
the group needs Python 3.15+ (SSLContext.set_groups) built against OpenSSL 3.5+.
12. Use it from Python
from qguard import scan, to_markdown, to_html, Severity
result = scan(["./src", "https://example.com", "ssh://example.com"])
for f in result.filtered(Severity.HIGH):
print(f.location, "|", f.title, "->", f.recommendation)
open("report.md", "w").write(to_markdown(result))
open("report.html", "w").write(to_html(result))
Each finding has rule_id, title, severity, status, algorithm, usage,
target, line, message, recommendation and metadata. to_json,
to_sarif, to_cbom and analyze(result) (score, verdict, phases) are
exported too.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
Score n/a, "Scan incomplete" |
Nothing could be reached or read. The Notes section says why (DNS, refused connection, timeout, missing path). |
| A web or SSH probe times out | Firewall or wrong port. Give the port (qguard web host:8443) or raise --timeout 20. |
qguard host reports "not readable" |
Run it with sudo. |
BackendUnavailable: No backend provides ... |
That algorithm needs liboqs: pip install "qguard[oqs]". |
First use of the oqs backend takes minutes |
liboqs is being compiled (once). It needs git, cmake and a C compiler: sudo apt install git cmake build-essential. |
... is not available in this cryptography build |
Your cryptography is linked against an OpenSSL older than 3.5. pip install -U cryptography (the PyPI wheels bundle a new OpenSSL), or use backend="oqs". |
ValueError: pyca ... secret keys are 64-byte seeds |
You passed a key generated by the oqs backend to the pyca backend. Use backend="oqs" for that key. |
| It flags the X25519 inside my own hybrid | It cannot tell a classical primitive is half of a hybrid. Mark the line # qguard: ignore. |
| Too much noise from tests or vendored code | --exclude "tests/*" or a .qguardignore file. |
Reference
What is scanned
| Target | What is checked |
|---|---|
| Python | AST-based and import-aware: cryptography, PyCryptodome, PyNaCl, rsa, ecdsa, Paramiko, pyOpenSSL, hashlib, ssl, PyJWT algorithms, RSA key sizes, liboqs / pqcrypto mechanisms |
| JS/TS, Go, Java/Kotlin, C/C++, Rust, C#, PHP, Ruby, Swift | Crypto API calls, WebCrypto algorithm names, imports, key generation |
| Scripts, Dockerfiles, CI | openssl, ssh-keygen, certbot, cosign command lines |
| Dependencies | requirements*.txt, pyproject.toml, package.json, go.mod, Cargo.toml, pom.xml, Gradle, Gemfile |
| Web servers | nginx, Apache, HAProxy, Caddy, OpenSSL, Postfix, Dovecot: TLS versions, key-exchange groups, cipher suites |
| SSH | sshd_config / ssh_config: KexAlgorithms, host-key and public-key algorithms, ciphers |
| VPNs | WireGuard (pre-shared keys), OpenVPN, strongSwan / IKEv2 proposals |
| Live TLS | Post-quantum groups accepted (X25519MLKEM768, SecP256r1MLKEM768, SecP384r1MLKEM1024, MLKEM768, draft Kyber), TLS 1.3 support, certificate chain |
| Live SSH | Advertised key exchange, host-key algorithms, ciphers |
| Keys and certificates | X.509 (PEM/DER), CSRs, PKCS#7, PEM and OpenSSH keys, authorized_keys, known_hosts |
| Software signatures | OpenPGP, SSH signatures, minisign/signify, Sigstore/cosign bundles, signed JAR/APK, Authenticode |
| Tokens | JWT / JWS / JWE alg headers, including tokens embedded in files |
Commands
| Command | Does |
|---|---|
qguard scan [TARGET...] |
Scan paths, https://host, tls://host:port, ssh://host, local:, jwt:<token>. Default target: . |
qguard web HOST[:PORT]... |
TLS probe |
qguard ssh HOST[:PORT]... |
SSH probe |
qguard host [--root DIR] |
Audit this machine |
qguard sig FILE... |
Signatures, certificates, keys |
qguard jwt TOKEN |
Token algorithm |
qguard algs [NAME] |
Algorithm knowledge base |
qguard backends |
Wrapper backends available here |
Shared options: -f/--format, -o/--output, --fail-on, --min-severity,
--exclude, --include-docs, --timeout, -v, --no-color.
How the TLS probe works
It needs no post-quantum TLS library. For each group it sends a TLS 1.3 ClientHello that offers only that group with an empty key share. A server that supports the group must answer with a HelloRetryRequest naming it (RFC 8446); one that does not answers with a handshake failure. No keys are exchanged.
Wrapper formats
HybridKEMis X-Wing (draft-connolly-cfrg-xwing-kem) and is tested against the draft's vectors on both backends, so it interoperates with other X-Wing implementations.HybridSignature(Ed25519 signature || ML-DSA signature, domain-separated) andseal(QGD1|| X-Wing ciphertext || ChaCha20-Poly1305) are this library's own encodings. Use them between systems you control.
Limits
- Source scanning outside Python is lexical: it also matches inside comments and
strings (those findings carry
confidence: medium) and cannot follow data flow. - A clean scan is not proof. Crypto reached through wrappers, native code, cloud KMS or hardware is invisible to it. Treat the output as an inventory to verify.
- The wrappers rely on pyca/cryptography and liboqs for the primitives. The liboqs
project recommends hybrid cryptography for anyone using it in production, which
is what
HybridKEMandHybridSignaturedo. - Not parsed yet: APK signature scheme v2+ blocks, RPM/deb signatures, STARTTLS services.
Development
git clone https://github.com/700799/qguard && cd qguard
pip install -e ".[dev]"
pytest
Publish a release
Publishing uses PyPI trusted publishing, so no token is stored anywhere.
One-time setup (browser only):
- Sign in at pypi.org, open Your account → Publishing, and under
"Add a new pending publisher" choose GitHub with:
- PyPI project name:
qguard - Owner:
700799 - Repository name:
qguard - Workflow name:
publish.yml - Environment name:
pypi
- PyPI project name:
- In the GitHub repository, open Settings → Environments and create an
environment called
pypi.
Each release:
- Bump
versioninpyproject.tomland__version__insrc/qguard/__init__.py. - Open Actions → Publish to PyPI → Run workflow (or publish a GitHub release). It lints, tests, builds, and uploads.
The first successful run registers the name qguard on PyPI. If the
repository is renamed, update the repository name in the PyPI publisher
settings to match.
MIT licensed.
Metadata
Release files for qguard 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qguard-0.1.0.tar.gz | 88.3 kB | With provenance | Details for qguard-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qguard-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for qguard-0.1.0-py3-none-any.whl |
Total release size: 164.7 kB
Release files / qguard-0.1.0.tar.gz
| Download URL | qguard-0.1.0.tar.gz |
|---|---|
| Size | 88.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
43aaeb2bb0c001a1b0dc5274615ad4bdf127e75fb8242bb23ec6d7c1ff815b49
|
|
BLAKE2b-256 checksum How to use checksums |
cf92258128c70b126e470fc2a63727c83b06919b590edb4ed6bbf26c10844fb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logRelease files / qguard-0.1.0-py3-none-any.whl
| Download URL | qguard-0.1.0-py3-none-any.whl |
|---|---|
| Size | 76.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
673a3915614507916f20d4fbd36ba07734c3fcc34af2056310be33b9d044c354
|
|
BLAKE2b-256 checksum How to use checksums |
21d8b466c2d495a73eca56fb41e2966e155cbe3d8aaa33fc4ae1ef2c07fd9e69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logSecurity for qguard 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for qguard-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.