> Agent-ready spec from Diff of the Day (2026-12-04, idea 1). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Post-quantum crypto inventory for one repository and its endpoints

## Problem Statement
The NSA advisory of Dec 2 asks owners to first inventory where cryptography is used, and to flag elliptic curves other than P-384 and P-521, EdDSA, DSA and old Diffie-Hellman groups. Cloudflare moved its own deadline to 2027. A small team rarely knows which keys, certificates, TLS settings and libraries in its code and servers use those algorithms.

## Goals
- List every place in one repository that names a flagged algorithm, key type or curve.
- Report the TLS version and key exchange group that each listed host negotiates.
- Rank findings so that internet-facing and long-lived items come first.
- Produce one Markdown report in under 2 minutes for a medium repository.

## Non-Goals
- Fixing the findings: the owner decides on each change and its rollout.
- Proving an algorithm is broken: the tool only reports use, not risk.
- Scanning hosts you do not own: that needs permission and is out of scope.

## User Stories
- As a solo maintainer, I want a list of the keys and curves my code uses so that I know what to replace first.
- As an ops engineer, I want the TLS version and group for each of my hosts so that I can see which still lack hybrid key exchange.
- Edge case: when a host does not answer or refuses TLS 1.3, the report marks it as unknown and moves on.

## Requirements
### P0
- [ ] Search source and config files for flagged names (for example P-256, secp256r1, prime256v1, X25519, Ed25519, ECDSA, DSA). Accept: each hit lists file, line and the matched name.
- [ ] Read PEM certificates and public keys found in the repository and report key type and size. Accept: a test certificate with a P-256 key is flagged.
- [ ] Connect to a list of hosts given in a file and record TLS version and negotiated group. Accept: the report shows one line per host.
### P1
- [ ] Mark each finding as internet-facing, internal or unknown from a small config file. Accept: the report is sorted by that mark.
- [ ] Read lockfiles and list crypto libraries with versions. Accept: the list appears in its own report section.
### P2
- [ ] Compare two reports and show what changed. Accept: a removed finding shows as fixed.

## Success Metrics
- The first report lists every flagged item that a manual review of the repository finds.
- Fewer than 10% of findings are false alarms on a sample review.
- The team fixes the top 3 items within one week.

## Open Questions
- Which hosts are in scope, and who owns each?
- Should RSA keys under 3072 bits be flagged as a warning?

## Timeline
- Saturday: source search, certificate parsing and the report.
- Sunday: TLS checks for listed hosts, ranking and the diff mode.

## Agent Instructions
- Stack: Python 3 with the cryptography package and the standard ssl module.
- Build order: file search, certificate parsing, report, host checks, ranking.
- Safety: read-only; never print private key material, only key type and size; only contact hosts listed in the input file.
- Done when: all P0 acceptance checks pass on a sample repository with known test keys.

## Sources
- NSA press release, https://www.nsa.gov/Press-Room/Press-Releases-Statements/Press-Release-View/Article/4662430/nsa-advises-immediate-transition-to-post-quantum-cryptography-to-protect-nation/
- Cloudflare, Project Quantum Leap, https://blog.cloudflare.com/project-quantum-leap/
- Filippo Valsorda, What to Make of the NSA Advisory, https://words.filippo.io/nsa-advisory/
