Security

How to scan a codebase for RSA and ECC

Capy team

Scan a codebase for RSA and elliptic curve cryptography in four layers: run ripgrep across application code and infrastructure configs, inspect dependency lockfiles for transitive crypto libraries, probe live TLS and SSH endpoints with OpenSSL 3.5 or newer, and export cloud load balancer and certificate inventories. Record each finding with its repository or endpoint, algorithm and key size, purpose (key establishment, signature, or certificate), data lifetime, exposure, owner, and upgrade path in a CycloneDX 1.6 CBOM or JSON inventory. Prioritize internet-facing key exchange protecting long-lived data first, followed by shared internal infrastructure, then certificates, signing keys, and roots of trust.

After a cryptography advisory lands, many engineering teams cannot list which services, libraries, load balancers, and signing scripts rely on RSA or 256-bit elliptic curves. Following the December 2 joint statement from ONCD, NSA and CISA and NSA's advisory, Immediate Actions to Push Toward Post-Quantum (PP-26-4956), building a cryptographic inventory is the first engineering task before changing a TLS listener or rotating a signing key.

The agencies assessed that recent discoveries disclosed by frontier AI companies "do not present an immediate and widespread threat" to deployed cryptography, while calling on industry and government to "expeditiously upgrade our digital infrastructure". NSA's advisory turns that into an accelerated move to post-quantum cryptography (PQC). In his analysis of the NSA advisory, cryptographer Filippo Valsorda wrote that 256-bit elliptic curves (P-256 and Curve25519/X25519/Ed25519) "are likely broken or significantly weaker than we thought", that RSA and P-384 are stopgaps at best, and that teams should move to ML-KEM (FIPS 203) and ML-DSA (FIPS 204) promptly. Either way, every migration starts by locating every asymmetric algorithm in your code, configs, dependencies, and live endpoints.

What NSA Step 1 requires in a cryptographic inventory

NSA's advisory (PP-26-4956) targets National Security Systems, and its six actions (Step 1 through Step 6) give any engineering team a clear order of operations. Step 1 is inventorying where cryptography runs so you know what each service negotiates and which team owns it before touching TLS configs, certificate authorities, or signing pipelines.

Step 1 requires enumerating internet-facing and internal systems that use TLS, IPsec, SSH, PKI and certificates, code signing, Wi-Fi, or identity credentials. For each system, record three distinct roles: the algorithm used for key establishment, signatures, and certificates, along with the product name, version or patch level, owner, and exact location. Separating those three roles matters because key exchange and authentication have different risk timelines and replacement paths.

Check first for algorithms excluded from CNSA 2.0 and CNSA 1.0:

  • Elliptic curves other than P-384 or P-521 for ECDH or ECDSA, which rules out P-256 (secp256r1 and prime256v1) and plain X25519.
  • EdDSA, which in practice means Ed25519 in SSH keys, JWT signing, and application code.
  • DSA and deprecated Diffie-Hellman groups, including legacy IKE groups and DH parameters under 3072 bits.
  • Pairing-based cryptography, such as BLS signatures over BLS12-381, whose group order is 255 bits despite the name.
  • RSA under 3072 bits, because CNSA 1.0 sets RSA-3072 and P-384 as interim minimums while CNSA 2.0 targets ML-KEM and ML-DSA.

Align that list with NIST IR 8547, which deprecates every quantum-vulnerable public-key algorithm across all key sizes after 2030 and disallows them under NIST standards after 2035. Treat P-384 and RSA-3072 as interim stopgaps where PQC support is missing, never as quantum-resistant targets.

Step 1 also defines four priority flags to attach to every row: systems protecting long-lived data, mission-critical systems, internet-facing endpoints, and shared infrastructure that many services depend on.

Where RSA and ECC hide across a stack

Asymmetric cryptography rarely stays inside one crypto/ directory. Map your scan across all nine places where RSA and ECC live in application code, infrastructure configs, and managed services.

LayerWhere it hidesWhat to search for
TLS endpointsnginx, Envoy, HAProxy, Go, Node, Java serversssl_ecdh_curve, ssl_protocols, ecdh_curves, ssl-default-bind-curves, CurvePreferences, tlsmlkem=0
SSHsshd_config, ssh_config, host and deploy keysKexAlgorithms, HostKey, id_rsa, id_ecdsa, id_ed25519, ssh-rsa, ssh-ed25519, ecdsa-sha2-nistp256
JWT and JWSAuth services, API gateways, verifiers, JWKSES256, RS256, PS256, EdDSA, SigningMethodES256, jose, jsonwebtoken, PyJWT
X.509 and PKIACME clients, cert-manager, internal CAs, PEM bundlesBEGIN RSA PRIVATE KEY, BEGIN EC PRIVATE KEY, ECDSAWithSHA256, spec.privateKey.algorithm
Code signingRelease pipelines, container and firmware scriptsopenssl dgst, openssl req -newkey, genrsa, ecparam, signing key ARNs
Cloud KMS and LBsAWS ALB, CloudFront, KMS keys, managed TLS policiesELBSecurityPolicy, ssl_policy, KMS specs (RSA_2048, ECC_NIST_P256), CDN profiles
IaC and KubernetesTerraform, Helm charts, cert-manager CRDs, Ansibletls_private_key, ecdsa_curve, rsa_bits, Certificate privateKey blocks
Language cryptoGo, Node/TypeScript, Python, Rust, Java app codeKeygen APIs, P256/prime256v1/secp256r1, ed25519-dalek, JCA KeyPairGenerator
Pairing curvesBlockchain, consensus, threshold signing, zk codebls12-381, bls12_381, blst, ark-bls12-381, bn254

For TLS listener remediation details, see how to enable post-quantum TLS 1.3 with X25519MLKEM768. For rotating JWTs, SSH keys, internal CAs, and code signing off 256-bit curves, see moving JWT, SSH, certificates and code signing off 256-bit ECC.

Ripgrep patterns to scan code and config

Run rg with file globs to get a fast first pass across application code, separating each ecosystem so hits map straight to language owners.

# Go: stdlib crypto, P-256, JWT signing, and TLS overrides that drop ML-KEM defaults
rg -n \
  -e 'crypto/(rsa|ecdsa|ed25519)' \
  -e 'elliptic\.P256' \
  -e 'ECDSAWithSHA256' \
  -e 'CurvePreferences' \
  -e 'tls(secp)?mlkem=0' \
  -e 'SigningMethod(ES256|RS256|EdDSA)' \
  --glob '*.go' --glob 'go.mod' --glob 'Dockerfile*' --glob '*.env*'

# Node and TypeScript: crypto keygen, P-256 curves, TLS options, and JWT algorithms
rg -n \
  -e 'generateKeyPair(Sync)?\s*\(\s*["\x27](rsa|ec|ed25519)' \
  -e 'prime256v1|secp256r1' \
  -e 'ecdhCurve' \
  -e '["\x27](ES256|RS256|PS256|EdDSA)["\x27]' \
  --glob '*.{js,cjs,mjs,ts,tsx}'

# Python: cryptography library calls and PyJWT algorithm lists
rg -n \
  -e 'rsa\.generate_private_key' \
  -e 'ec\.SECP256R1' \
  -e 'Ed25519PrivateKey' \
  -e 'algorithms\s*=\s*\[[^\]]*(RS256|ES256|EdDSA)' \
  --glob '*.py'

# Rust and Java: RSA, P-256, and Ed25519 crates and JCA calls
rg -n \
  -e 'ed25519[_-]dalek|ECDSA_P256_SHA256|\bp256::|RsaPrivateKey' \
  --glob '*.rs' --glob 'Cargo.toml'

rg -n \
  -e 'KeyPairGenerator\.getInstance\(\s*"(RSA|EC|Ed25519)"' \
  -e 'ECGenParameterSpec\(\s*"secp256r1"' \
  -e 'Signature\.getInstance\(\s*"SHA256with(ECDSA|RSA)"' \
  --glob '*.java'

Inspect Go TLS matches carefully. Since Go 1.24, default CurvePreferences include X25519MLKEM768, and Go 1.26 adds SecP256r1MLKEM768 and SecP384r1MLKEM1024. Setting CurvePreferences explicitly to classical curves silently drops hybrid key exchange, and GODEBUG=tlsmlkem=0 or tlssecpmlkem=0 in Dockerfiles, env files, or go.mod disables it at runtime.

Run a second sweep across reverse proxies, IaC, cert-manager manifests, OpenSSL scripts, SSH files, PEM headers, JWT strings, and pairing curves:

# nginx, Envoy, and HAProxy TLS configuration
rg -n -i \
  -e 'ssl_ecdh_curve|ssl_protocols|ecdh_curves|ssl-default-bind-curves' \
  --glob '*.{conf,cfg,yaml,yml,tmpl,tpl}'

# Terraform, Helm, and cert-manager private key and load balancer policies
rg -n -i \
  -e 'tls_private_key|ecdsa_curve|rsa_bits|ssl_policy|ELBSecurityPolicy' \
  -e 'privateKey:' \
  --glob '*.{tf,hcl,yaml,yml}'

# OpenSSL scripts, SSH configs/keys, PEM headers, JWT algs, and pairing curves
rg -n -i \
  -e 'openssl\s+(genrsa|ecparam|req\s+-newkey)' \
  -e 'KexAlgorithms|ssh-rsa|ssh-ed25519|ecdsa-sha2-nistp256' \
  -e 'BEGIN (RSA|EC|OPENSSH) PRIVATE KEY' \
  -e '["\x27](ES256|RS256|PS256|EdDSA)["\x27]' \
  -e 'bls12[_-]?381'

# Committed SSH or PEM key files by filename
rg --files --glob '*id_rsa*' --glob '*id_ecdsa*' --glob '*id_ed25519*' --glob '*ssh_host_*_key*' --glob '*.pem'

Both Terraform's tls_private_key resource and cert-manager Certificate specs default RSA keys to 2048 bits when the size field is omitted. Read the full resource block on every match instead of assuming an absent size parameter means a 3072-bit or larger key.

Closing the gaps static search misses

Ripgrep only finds explicit strings checked into Git. Four sources of RSA and ECC sit outside static source files and require companion checks.

Transitive dependencies. An authentication SDK, OIDC client, or service-mesh library can sign tokens with ES256 or verify RS256 internally without your application code naming the algorithm. Audit lockfiles (go.mod, package-lock.json, Cargo.lock, pom.xml, and Python lockfiles) for crypto packages such as rsa, p256, ed25519-dalek, ring, jose, jsonwebtoken, PyJWT, cryptography, and golang-jwt, then trace which direct dependencies pull them in.

Runtime TLS defaults. An unconfigured TLS stack negotiates whatever its runtime defaults allow. Non-FIPS Envoy builds default ecdh_curves to X25519 and P-256, and nginx or HAProxy linked against OpenSSL 3.0 cannot negotiate hybrid groups even with updated config lines. Stock OpenSSL 3.0 builds on older Linux distributions cannot test ML-KEM hybrids. Probe every live endpoint with OpenSSL 3.5 or newer to verify IETF RFC 10024 hybrid key exchange:

openssl s_client -connect api.example.com:443 -groups X25519MLKEM768 -brief </dev/null

A supporting listener prints Negotiated TLS1.3 group: X25519MLKEM768. Record any failure as missing hybrid key exchange and follow how to enable post-quantum TLS 1.3 with X25519MLKEM768 to upgrade the server. On SSH hosts, check ssh -Q kex and ssh -Q key and inventory host keys separately from key exchange; OpenSSH 10.6 enables hybrid ssh-mldsa44-ed25519 signatures and adds WarnWeakCrypto to sshd_config, detailed in moving JWT, SSH, certificates and code signing off 256-bit ECC.

Managed cloud services and load balancers. Console defaults and IaC defaults often diverge. On AWS Application Load Balancer, the console defaults new listeners to ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09, while the CLI, CloudFormation, and CDK still default to ELBSecurityPolicy-2016-08, which omits hybrid key exchange. Export active listener policies, KMS key specs, and CDN TLS profiles directly from your cloud APIs rather than trusting Terraform alone.

Externally issued certificates. WebPKI leaf certificates, intermediate chains, and ACME-managed certs rotate outside source control. Pull live certificates from ACME accounts, cloud certificate managers, Kubernetes secrets, and TLS probes so your inventory captures the actual deployed public key algorithm and expiry.

Structuring the inventory and CBOM

Raw grep logs go stale immediately because teams cannot sort them by exposure or ownership. Normalize every code hit, lockfile dependency, live probe, and cloud export into eight fields:

  • Repo or service. Repository name, cloud account, or cluster.
  • Location. Exact file:line for source and IaC, or host:port and ARN for live resources.
  • Algorithm and size. Specific algorithm and curve or modulus, such as ECDSA P-256, X25519, Ed25519, RSA-2048, or BLS12-381.
  • Purpose. key-establishment, signature, or certificate, matching NSA Step 1.
  • Data lifetime. Confidentiality or trust window, such as ephemeral session tokens vs multi-year customer records or device firmware.
  • Exposure. internet-facing, internal, or offline.
  • Owner. Team or service owner responsible for the fix.
  • Upgrade path. Direct PQC (X25519MLKEM768, ML-DSA-65, ssh-mldsa44-ed25519), interim CNSA 1.0 (P-384 or RSA-3072), or vendor-blocked.

Checking a small crypto-inventory.json file into each repository keeps the record diffable beside the code:

{
  "repo": "acme/edge-gateway",
  "location": "infra/terraform/alb.tf:42",
  "algorithm": "ECDHE P-256 / X25519 (no PQ hybrid)",
  "purpose": "key-establishment",
  "data_lifetime": "7-years",
  "exposure": "internet-facing",
  "owner": "platform-edge",
  "upgrade_path": "ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09 (X25519MLKEM768)"
}

When sharing the inventory with security, compliance, or SBOM tooling, export it as a CycloneDX 1.6 CBOM (cryptography bill of materials). CycloneDX 1.6 models cryptographic assets with algorithm, parameter set, cryptographic role, and usage inside the standard SBOM schema so every team reads one machine-readable file.

Turning findings into a prioritized remediation backlog

Sort the backlog by harvest-now, decrypt-later exposure rather than repository count. Both NSA and NIST IR 8547 emphasize that adversaries can record encrypted traffic today for future decryption, whereas signatures are vulnerable only at verification time or when embedded in long-lived roots of trust.

  1. Internet-facing key establishment protecting long-lived data. Upgrade public TLS 1.3 load balancers, proxies, API gateways, and SSH or VPN key exchange first. Enabling hybrid key exchange (X25519MLKEM768, SecP256r1MLKEM768, or SecP384r1MLKEM1024) protects recorded sessions immediately.
  2. Shared internal infrastructure. Fix internal proxies, service meshes, identity brokers, and shared SDKs next so one release clears downstream inventory rows across dependent services.
  3. Signatures, certificates, and roots of trust. Then move private CAs, code and firmware signing, SSH host and user keys, and JWT issuers. Authentication remains vulnerable until legacy trust anchors are removed, because leaving a weak anchor active alongside a new key still allows forged verification. Where ML-DSA or SLH-DSA support is unavailable, move to interim P-384 or RSA-3072 keys while tracking the PQC upgrade.
  4. Non-upgradable systems. Record hardware, legacy clients, or vendor appliances that cannot upgrade in a plan of action and milestones (POA&M) with network isolation and live traffic detection per NSA Step 6.

For the full rollout across NSA Steps 1 through 6 and the NIST 2030 to 2035 schedule, see how to migrate a codebase to post-quantum cryptography.

Running the scan across dozens of repositories with Capy

Manual ripgrep sweeps work on two repositories, then break down across forty repositories with different toolchains and drift-prone spreadsheets. For the broader multi-repo rollout pattern, see how to run a code migration across many repositories with coding agents.

Put the target repositories in one Capy project and start a Captain with one written scan specification. The Captain writes the scan rules, regexes, and output schema into CREW.md in its Drive so every thread follows the exact same checklist on every turn.

The Captain starts one thread per repository. Each thread runs on its own isolated cloud microVM with the repository cloned and your Setup applied, so it can run rg, inspect lockfiles and IaC, execute tests, or probe a local test server with openssl s_client before committing. Each thread opens a pull request adding crypto-inventory.json or a CycloneDX 1.6 CBOM file and follows CI and review comments on its branch. Filter the Pull requests page by Captain to review every inventory PR together; Capy never merges a pull request unless someone asks or a merge rule is committed in AGENTS.md.

As threads finish, the Captain combines findings into one prioritized backlog ordered by NSA Step 1 flags and files Capy Issues (with sub-issues) for non-upgradable systems and POA&M entries right beside the threads that will execute later fixes.

Two guardrails keep the inventory from drifting after the first sweep:

  • Weekly recurring scan. Configure a Capy automation on a weekly schedule to re-run the scan prompt and open a pull request whenever a dependency bump or config edit reintroduces RSA or 256-bit ECC.
  • Inline PR gate with Capy Review. Add a rule to each repository's AGENTS.md: "Flag any new use of P-256, Ed25519, ES256, RSA keys under 3072 bits, or TLS configs without X25519MLKEM768." Capy Review checks out the full repository and posts inline GitHub findings by severity whenever a pull request breaks that rule.

Capy handles code and config scanning, inventory pull requests, PR review enforcement, and issue tracking; live network traffic detection, certificate issuance, and KMS key management stay in your network sensors, certificate authority, and cloud IAM tooling.

Frequently Asked Questions

Why is grep alone not enough to find RSA and ECC in a codebase?+
Static text search misses transitive dependencies that sign or verify tokens internally, runtime TLS stacks that negotiate plain X25519 or P-256 by default when no groups are configured, cloud load balancer and KMS policies set outside Git, and certificates issued by external certificate authorities. A complete cryptographic inventory pairs code and config search with lockfile inspection, live TLS and SSH handshake probes, and cloud policy exports.
Which RSA and elliptic curve algorithms does NSA Step 1 flag first?+
NSA Step 1 directs operators to check first for algorithms not approved in CNSA 2.0 or CNSA 1.0. That includes DSA, elliptic curves other than P-384 or P-521 for ECDH or ECDSA, EdDSA, deprecated Diffie-Hellman groups, and pairing-based cryptography such as BLS signatures over BLS12-381. P-256, Ed25519, and RSA keys below 3072 bits all fall outside the CNSA 1.0 interim floor.
How do I test whether a live TLS endpoint supports X25519MLKEM768?+
Run openssl s_client with the -groups X25519MLKEM768 and -brief flags using OpenSSL 3.5 or newer. A server supporting the RFC 10024 hybrid group completes the handshake and prints Negotiated TLS1.3 group: X25519MLKEM768. Older OpenSSL 3.0 builds shipped on many Linux distributions do not support ML-KEM hybrid groups and cannot run this check.
What fields belong in a cryptographic inventory or CycloneDX 1.6 CBOM?+
Every entry should record the repository or service, exact file and line or live endpoint, algorithm and key size or curve, cryptographic purpose (key establishment, signature, or certificate), data lifetime, network exposure, owning team, and upgrade path. CycloneDX 1.6 extends the SBOM schema with a CBOM model that stores algorithm, parameter set, usage, and owning component in one machine-readable document.
Should a team remediate TLS key exchange or signing keys first?+
Fix internet-facing TLS key exchange protecting long-lived data first. Adversaries can record encrypted traffic today and decrypt it later once stronger capabilities arrive, whereas signatures and authentication keys are vulnerable only at verification time. After enabling hybrid key exchange on exposed listeners, move to internal shared infrastructure, private certificate authorities, code signing, SSH keys, and JWT issuers.
How can an engineering team scan dozens of repositories and keep the inventory current?+
Write one scan specification and run one coding agent per repository instead of maintaining a manual spreadsheet. In Capy, a Captain starts one thread per repository on its own cloud microVM to open a pull request with an inventory file or CycloneDX 1.6 CBOM, combines findings into a prioritized backlog, and pairs weekly automations with Capy Review rules in AGENTS.md so new P-256, Ed25519, or RSA-2048 calls are flagged on future pull requests.

Sources

  1. CISA: Joint statement from ONCD, NSA and CISA on recent advances in cryptographic and cybersecurity capabilities
  2. NSA: Immediate Actions to Push Toward Post-Quantum (PP-26-4956)
  3. NIST IR 8547: Transition to Post-Quantum Cryptography Standards
  4. Filippo Valsorda: What to Make of the NSA Advisory
  5. IETF RFC 10024: Post-Quantum Traditional (PQ/T) Hybrid Key Agreement Mechanisms for TLS 1.3
  6. AWS: Security policies for your Application Load Balancer
  7. CycloneDX: Cryptography Bill of Materials
  8. Capy docs: Captains
  9. Capy docs: Reviews
  10. Capy docs: Pull requests

Spotted something out of date? Tell us at support@capy.ai.