What is RSA?
RSA is an asymmetric cryptographic algorithm. It uses a key pair consisting of a public and a private key and covers two use cases: encryption and digital signatures. The private key decrypts or signs data, the public key encrypts it or verifies signatures. The private key remains secret and cannot be derived from the public key with any realistic effort. The algorithm was developed in 1977 by Ronald Rivest, Adi Shamir and Leonard Adleman at MIT; its name is made up of the initials of their three surnames. It was the first published asymmetric encryption algorithm. A similar scheme had already been devised at the British GCHQ in the early 1970s, but was never published for reasons of secrecy.
How does RSA work?
Key generation
Two large prime numbers are chosen at random and multiplied. The public key is derived from this product and one further number, the private key from the two primes. Its security rests on an asymmetry of effort: multiplying primes takes a fraction of a second, whereas factoring a large product back into its prime factors is, as far as we know today, extremely costly.
Encryption
The sender encrypts using the recipient's public key. The message can only be decrypted with the recipient's private key. Even if someone intercepts the transmission, all they see is a meaningless string of characters.
Digital signatures for authentication
When signing, the direction is reversed. The sender signs their data with the private key, and anyone with the matching public key can verify the signature. If verification succeeds, the data comes from the holder of the private key and has arrived unaltered. Any subsequent change to the content invalidates the verification.
Why RSA is never used on its own
In its pure textbook form, RSA is suitable neither for encryption nor for signatures, because it is seriously insecure in both cases. The algorithm is deterministic: an attacker can guess a plaintext, encrypt it with the public key and compare it with the intercepted ciphertext. For short messages such as "yes" or "no", this is highly effective. Padding schemes solve this problem by adding a randomly chosen string to the plaintext or hash value before encryption, thereby randomising the result. Common schemes today are OAEP for encryption and PSS for signatures.
Hybrid encryption
RSA is at least 100 times slower than algorithms such as AES or 3DES. In practice, it is therefore mostly used only to exchange a key. The actual data is then encrypted with a symmetric algorithm. The session key is generated randomly, encrypted with RSA and transmitted together with the message.
How long does the key need to be?
RSA security requires prime numbers with several hundred decimal digits. The longer the key, the more costly an attack. 1024 bits are considered obsolete. 2048 bits are widespread, but too short for data requiring long-term protection. Germany's Federal Office for Information Security (BSI) recommends at least 3000 bits in its Technical Guideline TR-02102-1; in practice, 3072 or 4096 bits are used. Longer keys cost computing time, which becomes noticeable on servers with many simultaneous connections.
Where RSA is used
RSA secures internet and telephony infrastructure such as X.509 certificates, transport protocols such as TLS, SSH and IPsec, and email encryption via S/MIME and OpenPGP. Card payments based on EMV, the RFID chip in the German passport and online banking via HBCI also rely on it. Since TLS 1.3, RSA is used only for authentication when establishing encrypted web connections, no longer for key exchange.
