RSA Cryptosystem

Research
Introduced by
Ronald Rivest
Year
1978
Type
asymmetric encryption algorithm
Family
Public-key cryptography

What does it do?

RSA is a public-key cryptosystem introduced by Rivest, Shamir, and Adleman in 1978.

It supports encryption and digital signatures with a pair of linked keys: a public key that can be shared openly and a private key that stays secret. Its security rests in part on the difficulty of factoring the large modulus n into its prime factors.

The intuition behind the method

RSA depends on an asymmetry: multiplying two large primes is easy, but recovering those primes from their product is believed to be hard for classical computers. Each user derives a key pair from two large secret primes. The public key is shared and used to encrypt messages or check signatures, while the private key stays secret and is used to decrypt or sign. An attacker who knows only the public key would need the private exponent, and deriving it is widely believed to be computationally linked to factoring n, although this link is not proven.

History

RSA was published in 1978 by Rivest, Shamir, and Adleman in Communications of the ACM. The paper described a public-key encryption method in which the encryption key could be revealed without revealing the decryption key, and it showed how the same key structure supports digital signatures. Subsequent work has added padding schemes and guidance on key sizes in response to attacks, while the core arithmetic has remained the same.

When to use it

Choose RSA when you need public-key operations on existing infrastructure: transporting a short symmetric key, verifying certificates or signatures in protocols such as TLS, or signing documents with a standard RSA signature scheme. The data encrypted directly with RSA must be shorter than the modulus, and standard padding (OAEP for encryption, PSS for signatures) is required; unpadded textbook RSA should not be used. RSA is a poor choice for encrypting bulk data, which is normally done with a symmetric cipher such as AES. For new systems that must remain secure against future quantum attacks, RSA is not a suitable long-term choice, and post-quantum alternatives should be considered. Current guidance commonly treats 2048-bit keys as a minimum for classical security. Such minimums are revised over time, so check current standards for the size you choose and for when that size is no longer recommended. In practice a standard public exponent is used rather than a small one chosen by hand, because small exponents are unsafe when combined with unpadded messages.

Limitations and considerations

  • Encryption and decryption use modular exponentiation with very large numbers, so RSA is considerably slower than symmetric ciphers and is normally used to protect a short key rather than bulk data.
  • Security depends on the modulus n being large enough that factoring is infeasible; key sizes must be increased as attacks improve, which raises computational cost.
  • A sufficiently large quantum computer could factor n efficiently and so break the scheme, which makes RSA unsuitable where long-term post-quantum resistance is required.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Public keys can be published openly, so two parties can communicate securely without first exchanging a shared secret, which is the central idea of the 1978 paper.
  • A single key pair supports both encryption and digital signatures, although separate pairs are recommended for each purpose (see pitfalls).
  • Its security rests in part on the difficulty of factoring the modulus n, a long-studied problem whose hardness is assumed rather than proven. The security claim is therefore conditional on that assumption and on correct padding.
  • Support is widespread across cryptographic libraries, certificate infrastructure and existing protocols, which eases interoperation with legacy software.

Applications

  • HTTPS, where RSA-based certificates and signatures in TLS help authenticate web servers
  • Pretty Good Privacy (PGP) and S/MIME for encrypting and signing email messages
  • Public key infrastructure (PKI) and digital certificates that bind public keys to identities
  • Encrypting short keys in hybrid systems, where a symmetric cipher such as AES handles the bulk data
  • Hardware security modules and enterprise key management systems that support RSA operations

How it works

How it works

1

Select two large distinct prime numbers p and q, compute their product n = p × q, compute Euler's totient φ(n) = (p-1)(q-1), choose e with 1 < e < φ(n) coprime to φ(n), compute d such that e × d ≡ 1 (mod φ(n)). The public key is (e, n) and the private key is (d, n).

Formula
n = p \times q, \qquad \varphi(n) = (p-1)(q-1), \qquad e \cdot d \equiv 1 \pmod{\varphi(n)}
2

To encrypt a message m, compute the ciphertext c = m^e mod n, where e and n are the recipient's public key.

Formula
c \equiv m^{e} \pmod{n}
3

To decrypt a ciphertext c, compute the plaintext m = c^d mod n, where d and n are the private key.

Formula
m \equiv c^{d} \pmod{n}
4

A signature is produced by applying the private exponent to a hash of the message, usually after the hash has been combined with a padding scheme such as PSS. Anyone can verify it by applying the public exponent to the signature and comparing the result with a freshly computed hash of the message. A match indicates that the signature was made with the private key corresponding to the public key and that the message has not been altered.

Common pitfalls

  • Textbook RSA without padding is deterministic: the same plaintext always produces the same ciphertext, and structured messages can be attacked. Use OAEP for encryption and PSS for signatures.
  • If the primes p and q are too close together, or are generated poorly, n can be factored more easily; prime selection requires cryptographically secure randomness and proper primality testing.
  • Using one key pair for both encryption and signing widens the set of operations an attacker can probe, so separate key pairs are preferred.
  • Legacy PKCS#1 v1.5 encryption padding should not be used in new designs, because it is vulnerable to padding-oracle attacks (Bleichenbacher-style). Any decryption error that reveals whether the padding was valid must be treated as a security vulnerability.
  • Implementation-level leakage can expose the private key even when the mathematics is sound. Timing and power side channels in modular exponentiation, and fault attacks on CRT-based private-key operations, are practical risks. Use vetted, constant-time cryptographic libraries rather than custom RSA arithmetic.

Frequently asked questions

Why is RSA slow compared to symmetric encryption like AES?

RSA encryption and decryption involve modular exponentiation with numbers of 2048 bits or more, which requires considerably more computation per operation than the block operations used by AES. For that reason, RSA is typically used to encrypt a short symmetric key, and AES then encrypts the bulk data.

What happens if someone factors my public key modulus n?

If an attacker factors n into its prime factors p and q, they can compute φ(n) and then derive your private key d from your public exponent e. This is why using sufficiently large primes and key sizes is critical.

Can RSA signatures be forged without the private key?

Signatures produced with a standard padding scheme such as PSS are designed to resist forgery. Unpadded or incorrectly padded RSA signatures are vulnerable to known mathematical attacks, so a standard padding scheme should always be used.

Is RSA still secure?

RSA with 2048-bit keys is commonly regarded as secure against classical computers, and longer keys are often recommended for data that must stay confidential for many years. A sufficiently large quantum computer could break RSA, which is why post-quantum cryptography is an active area of research.

How do I choose appropriate primes p and q?

Use a cryptographically secure random number generator to generate large numbers, then test each for primality using algorithms like the Miller-Rabin test. Modern libraries handle this automatically.

Related methods

Sources

  1. Rivest, R. L., Shamir, A., & Adleman, L. (1978). A method for obtaining digital signatures and public-key cryptosystems. Communications of the ACM, 21(2), 120-126.

    Open DOI reference
  2. Koblitz, N. (1987). A Course in Number Theory and Cryptography. Springer-Verlag.

    ISBN: 978-0387966618