The [Public-key cryptography|]ROCA vulnerability is a cryptographic weakness that allows the private key of a key pair to be recovered from the public key in keys generated by devices with the vulnerability. "ROCA" is an acronym for "Return of Coppersmith's attack". The vulnerability has been given the identifier. The vulnerability arises from a problem with an approach to RSA key generation used in a software library, RSALib, provided by Infineon Technologies, and incorporated into many smart cards, Trusted Platform Module, and Hardware Security Modules implementations, including YubiKey 4 tokens, often used to generate PGP keys. Keys of lengths 512, 1024, and 2048 bits generated using the Infineon library are vulnerable to a practical ROCA attack. The research team that discovered the attack estimate that it affects around one-quarter of all current TPM devices globally. Millions of smart cards are believed to be affected. The team informed Infineon of the RSALib problem in February 2017, but withheld public notice until mid-October, citing responsible disclosure. At that time they announced the attack and provided a tool to test public keys for vulnerability. They published the details of the attack in November.
Technical details
Generating an RSA key involves selecting two large randomly-generatedprime 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 RSALibselection process quickly creates primes of the desired type by only testing for primality numbers of the form: where is the product of the first n successive primes, and n is a constant that only depends on the desired key size. The security is based on the secret constants and. 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 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 is a smooth number. A test site is available on the Internet. In short, keys that fit this format have significantly low entropy and can be attacked relatively efficiently, and the format can be confirmed by the attacker very quickly. Multiples implementation of the attack are publicly available.
Mitigation
The ROCA authors consider public keys of length 512, 1024 and 2048-bits generated by RSALib to be vulnerable. Because the details of key generation differ for different key lengths, shorter keys are not necessarily more vulnerable than longer keys. For example a 1952-bit RSAlib key is stronger than a 2048-bit key and a 4096-bit key is weaker than a 3072-bit key. The best mitigation, according to the authors, is to generate RSA keys using a stronger method, such as by OpenSSL. If that is not possible, the ROCA authors suggest using key lengths that are less susceptible to ROCA such as 3936-bit, 3072-bit or, if there is a 2048-bit key size maximum, 1952-bits.