Generating an RSA key involves selecting two large
randomly-generated prime numbers, a process that can be time-consuming, particularly on small devices, such as smart cards. In addition to being primes, the numbers should have certain other properties for best security. The vulnerable
RSALib selection process quickly creates primes of the desired type by only considering numbers of the form k \times M + (65537^a \bmod M), where M is the product of the first
n successive primes (2, 3, 5, 7, 11, 13, ...), and
n is a constant that only depends on the desired key size. The security is based on the secret constants k and a. The ROCA attack exploits this particular format for primes using a variation of the
Coppersmith method. In addition, public keys generated this way have a distinctive fingerprint that can be quickly recognized by attempting to compute the
discrete logarithm of the public key mod M to base
65537. Computing discrete logarithms in a large group is usually extremely difficult, but in this case it can be done efficiently using the
Pohlig–Hellman algorithm because M is a
smooth number. A test site is available on the Internet. In short, keys that fit this format have significantly lower entropy and can be attacked relatively efficiently (weeks to months), and the format can be confirmed ("fingerprinted") by the attacker very quickly (microseconds). Multiple implementations of the attack are publicly available. ==Mitigation==