What is RSA Encryption?
RSA (Rivest–Shamir–Adleman) is a widely used asymmetric encryption algorithm. Unlike symmetric encryption, RSA uses a pair of keys: a public key for encryption and a private key for decryption. It's a foundational technology for securing digital communications, especially over the internet.
Key Features of RSA:
- Asymmetric Encryption: Uses two keys — public and private.
- Based on Number Theory: Relies on the difficulty of factoring large prime numbers.
- Key Lengths: Commonly 2048 or 4096 bits.
- Slower: Not ideal for bulk data encryption.
Common Uses:
- Secure key exchange
- Digital signatures
- SSL/TLS (HTTPS)
- Email encryption (PGP, S/MIME)
How RSA Works
RSA uses a pair of mathematically linked keys. Here’s a simplified view of the process:
- Generate two large prime numbers (p and q).
- Compute
n = p × q
andϕ(n) = (p - 1)(q - 1)
. - Choose public exponent
e
such that 1 < e < ϕ(n). - Calculate private exponent
d
such thatd × e ≡ 1 (mod ϕ(n))
. - Publish
{e, n}
as the public key and keep{d, n}
private.
To encrypt, the sender uses the recipient’s public key. To decrypt, the recipient uses their private key.
Encryption vs. Signing
Encryption
Encrypt with the recipient's public key, decrypt with their private key.
Used for confidentiality.
Digital Signatures
Sign with your private key, verify with your public key.
Used for authenticity and integrity.
Limitations of RSA
- Slower than symmetric algorithms like AES.
- Not suitable for encrypting large files directly.
- Quantum computers could eventually break RSA.
RSA vs Symmetric Encryption
Feature | RSA | AES |
---|---|---|
Type | Asymmetric | Symmetric |
Keys Used | Public & Private | Single Shared Key |
Speed | 🐢 Slow | ⚡ Fast |
Best For | Key exchange, signatures | Bulk data encryption |
Security Basis | Prime factorization | Substitution & permutation |