Try it: KeyGuard on Hugging Face · Product page · Hugging Face article

Short answer

To check whether an RSA public key is structurally weak, test it for four things: a prime shared with another key, two primes that are too close together, the ROCA fingerprint, and a dangerous length or exponent. KeyGuard, a free tool from VIDRAFT, runs all four in your browser. On its built-in benchmark of 145 keys it found 65 of 65 weak keys with 0 false alarms on 80 healthy keys.

Key facts

  • What it is: a self-check for RSA public keys, free, MIT, no sign-in, in English, Korean and Chinese
  • Close primes: a 2048-bit sample key recovered in 1.4 ms in a normal browser tab
  • ROCA: 12 of 12 ROCA-structured keys flagged, 0 of 40 ordinary keys flagged
  • Privacy: 0 network requests after the page loads, measured. Private keys are not accepted
  • Scale: a batch-GCD engine from the same family processed 220,713 keys in 122.5 seconds, made of 220,707 real RSA public keys from Certificate Transparency logs plus 6 planted weak keys. It found 6 of 6 planted keys with 0 false alarms on the real ones

Why a 2048-bit key can still fail

An RSA public key is the product of two secret primes, N = p x q. A 2048-bit key with well chosen primes is out of reach for today's factoring methods. The weak spot is the moment of birth. Routers, cameras and other embedded devices often create a key right after first boot, when there is little randomness to draw from, and two different devices can land on the same prime.

This has been measured at internet scale. A USENIX Security 2012 study obtained private keys for about 0.50% of TLS hosts because their public keys shared factors. Keyfactor in 2019 broke 249,553 distinct keys, about 1 in 172 of the RSA certificates it collected from the internet.

from math import gcd g = gcd(N1, N2) # both values are public if g not in (1, N1, N2): p, q1, q2 = g, N1 // g, N2 // g # both keys are now factored 

No supercomputer and no quantum computer is needed.

Two 2048-bit RSA keys broken by a shared prime in KeyGuard

The four checks

Check What goes wrong How it is found
Shared primes Two devices use the same prime, so both private keys are recoverable Pairwise GCD over the keys you paste together
Close primes p and q are nearly equal, so N factors almost at once Fermat factorization with bounded steps
ROCA (CVE-2017-15361) Keys from a flawed chip library follow a fixed pattern Subgroup test over 38 odd primes
Length and exponent Short keys or an abnormal public exponent Direct inspection

Why combine them

Each method sees one kind of defect. This is the built-in benchmark, 145 keys (80 healthy, 65 weak, fixed seed 20262025), every detector on the same machine.

Detector Weak keys found False alarms on 80 healthy keys Time for 145 keys
KeyGuard (combined) 65 / 65 (100%) 0 73 ms
Size and exponent check 25 / 65 (38.5%) 0 under 1 ms
GCD only 20 / 65 (30.8%) 0 9 ms
Fermat only 20 / 65 (30.8%) 0 95 ms

KeyGuard weak key detection benchmark

How to check your own devices

  1. Get the public key of a device you own or are authorized to test.
openssl s_client -connect 192.0.2.10:443 </dev/null 2>/dev/null | openssl x509 cat ~/.ssh/id_rsa.pub 
  1. Paste the keys of several devices together. A shared prime shows up only when keys are compared with each other.
  2. Read the result: Safe, Caution or Danger, with the reason for each key.

FAQ

Can a 2048-bit RSA key be broken?

With well chosen primes, it is out of reach for today's factoring methods. If two devices share a prime, one GCD opens both keys. If the primes are too close, Fermat factorization opens the key almost at once.

Is my public key uploaded?

No. Every check runs in JavaScript in your browser. We recorded the network during the checks and saw 0 requests after the page loaded.

Which formats work?

BEGIN PUBLIC KEY, BEGIN RSA PUBLIC KEY, BEGIN CERTIFICATE, an ssh-rsa line, a hex modulus, a decimal N, or N:e. All 18 tested combinations across 2048, 3072 and 4096 bits were read correctly.

Who should run it?

Device makers before shipping a batch, network and IoT operators with self-signed certificates, security teams as a first triage step, and teachers who want a classic lesson visible in one click.

What if a key is marked Danger?

Retire it, update the device firmware and generate a new key. If it belongs to someone else's product, report it privately to the vendor or your national CERT.

Links