- Introduced by
- Ronald Rivest, Adi Shamir, Leonard Adleman
- Year
- 1978
- Type
- Asymmetric encryption and signature algorithm
- Family
- Public-key cryptography
What does it do?
RSA (Rivest–Shamir–Adleman) is an asymmetric cryptosystem introduced in 1978 that can provide both public-key encryption and digital signatures.
Its security rests in part on the difficulty of factoring the public modulus into its two secret primes. Each user holds a public key, which can be published, and a private key, which is kept secret. It is widely deployed in internet security infrastructure, including certificate-based authentication and key exchange.
The intuition behind the method
RSA's security rests in part on the difficulty of factoring the published modulus n, the product of two large secret primes, into those primes. The system uses two related keys: a public exponent for encryption or signature verification, and a secret exponent for decryption or signing. The key property is that publicly revealing the encryption key does not reveal the decryption key, at least not by any practical known method. The operation is a trapdoor one-way function: it is easy to apply in the forward direction with the public key, and reversing it without the secret exponent d is believed to be computationally infeasible. That belief depends in part on the difficulty of factoring n into p and q, because knowing the factors makes d straightforward to compute. This asymmetry is what allows parties with no prior shared secret to communicate securely.
History
RSA was invented by Ronald Rivest, Adi Shamir, and Leonard Adleman and published in 1978 in Communications of the ACM. The paper describes encryption by raising a message to a public exponent modulo a product of two secret primes, and signing with a privately held exponent that anyone can verify. Its security has been analysed continuously since publication, and research into quantum-resistant alternatives is ongoing.
When to use it
Choose RSA when asymmetric operations are required, most commonly for digital signatures, certificate-based authentication in public-key infrastructure, and transporting a short symmetric key or other small value. It is suitable when interoperability with existing standards and systems matters, since RSA is deployed widely. Do not use RSA to encrypt bulk data directly, because it is much slower than symmetric ciphers; encrypt the data with a symmetric key and protect that key with RSA. For new encryption designs, use OAEP rather than PKCS #1 v1.5 padding, and PSS for signatures. Where confidentiality must hold against a future quantum adversary, RSA alone is not adequate, as the quantum-threat discussion below explains.
Limitations and considerations
- Considerably slower than symmetric cryptography, and it requires large keys (2048–4096 bits for modern security), so it is normally used only for key transport and signatures
- Raw RSA without padding is deterministic and malleable, so secure use depends on correctly implemented padding; errors in padding can expose the system to attack
- Key generation and private-key operations are computationally expensive compared with elliptic-curve alternatives
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Security rests on the assumed difficulty of factoring the public modulus n, a hardness assumption supported by decades of cryptanalysis rather than a formal proof of security
- One key mathematics serves two purposes: the public exponent encrypts or verifies, and the secret exponent decrypts or signs, so the same key-pair structure can support both uses
- The public encryption key can be published without revealing the decryption key, so parties can establish secure communication without first exchanging a secret through a separate channel
- Standardised and deployed across many protocols, with over 40 years of public cryptanalytic scrutiny of the basic scheme
Applications
- HTTPS/TLS: authenticating servers through X.509 certificates, and historically used for key exchange in some TLS configurations
- Email security: PGP/GPG for signing and encrypting electronic mail
- Digital signatures in electronic commerce and government services
- Certificate authorities: signing and verifying digital identity certificates in public-key infrastructure
How it works
How it works
Choose two large distinct secret primes p and q, and compute the public modulus n = p × q. Choose a public exponent e that is coprime with (p − 1)(q − 1), and derive a secret exponent d such that e × d ≡ 1 (mod (p − 1)(q − 1)), so that d is the multiplicative inverse of e modulo Euler's totient of n. The public key is (n, e); the private key is d, and p and q must be kept secret.
Formula
n = p \cdot q, \qquad e \cdot d \equiv 1 \pmod{(p-1)(q-1)}Represent the plaintext as an integer M smaller than n. Compute the ciphertext C as M raised to the public exponent e, reduced modulo n, so that C = M^e mod n. In practice this integer must first be encoded with a standardised padding scheme before exponentiation.
Formula
C = M^{e} \bmod nThe recipient raises the ciphertext C to the secret exponent d, reduced modulo n, so that M = C^d mod n. This recovers the original integer because e and d are inverses modulo (p − 1)(q − 1). Signing uses the same mathematics in reverse: the signer applies d to a message representative, and anyone can check the result using the public exponent e.
Formula
M = C^{d} \bmod nReview the implementation against the attack classes this scheme is known to face, and record the outcome for each. Factoring: confirm that n is the product of two distinct, randomly chosen large primes that are not close to each other, and that the key size is at least 2048 bits. Timing side channels: confirm that private-key operations run in constant time or are protected by a blinding technique, so that their running time does not reveal information about the secret exponent. Padding oracle attacks: confirm that encryption uses OAEP and signing uses PSS, and that decryption returns the same error for every malformed ciphertext, so that no response reveals whether a given ciphertext was well formed. Key separation: confirm that encryption and signing use separate key pairs, or domain separation if a key pair is shared. A check passes when the stated property holds in the code and configuration. Any non-standard padding, distinguishable decryption error, or key size below current guidance is a failure to correct before deployment. Surveys of these attack classes, such as Boneh (1999), give further detail.
Common pitfalls
- Using insufficiently large keys or outdated key sizes below 2048 bits
- Implementing custom padding schemes; always use standardized schemes like OAEP or PSS
- Reusing the same key pair for both encryption and signatures without domain separation
- Failing to validate that ciphertext is well-formed before decryption, exposing systems to padding oracle attacks
Frequently asked questions
Why is RSA considered secure if the factorization problem is known to be hard, not proven?
Integer factorization has not been proven hard, and no polynomial-time classical algorithm is known despite decades of research. RSA's security therefore rests on an assumption of computational infeasibility under current and foreseeable technology. Deployed key sizes are chosen so that factoring them is considered beyond practical reach.
Is RSA vulnerable to quantum computers?
Yes. Shor's algorithm (1994) can factor large integers in polynomial time on a sufficiently large quantum computer, which would break RSA. This threat has motivated research into post-quantum cryptography using lattice-based, hash-based, and multivariate polynomial methods. Hybrid approaches combining RSA with quantum-resistant algorithms are one option for long-term security.
Why not use RSA to encrypt all data directly instead of using symmetric encryption?
RSA is considerably slower than symmetric ciphers such as AES, so encrypting bulk data with it is impractical. The standard approach is to use RSA to transport a symmetric key, then encrypt the data with that key. This combines the key-distribution benefit of asymmetric cryptography with the performance of symmetric encryption.
What is the minimum safe key size for RSA today?
A 2048-bit modulus is the common minimum in current practice, and keys of up to 4096 bits are used where a longer protection period is needed. Keys smaller than 2048 bits are outdated and should not be used in new systems. Key-size recommendations are revised as computing power grows, so check the current published guidance from the relevant standards body for the intended deployment period.
Related methods
Sources
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 referenceMenezes, A. J., van Oorschot, P. C., & Vanstone, S. A. (1997). Handbook of Applied Cryptography. CRC Press.
Open publication referenceBoneh, D. (1999). Twenty years of attacks on the RSA cryptosystem. Notices of the American Mathematical Society, 46(2), 203–213.
Open publication reference