Public Key Cryptography - RSA

박서경박서경
4 min read

RSA

What is RSA (Rivest-Shamir-Adleman)?

RSA is a public-key cryptographic algorithm used for data encryption, digital signatures, and key exchange.
It is based on the mathematical difficulty of factoring large prime numbers.

1. How RSA Works

Asymmetric encryption: Uses a public key for encryption and a private key for decryption.
Digital signatures: Uses a private key to sign messages and a public key to verify signatures.

2. RSA Key Generation

RSA security is based on the difficulty of the integer factorization problem.

  1. Select two large prime numbers pp and qq

    • These primes must be very large (e.g., 1024-bit, 2048-bit, or 4096-bit).
  2. Compute their product → N=p×q

    • N becomes part of the public key.

    • The larger N, the more secure RSA is.

  3. Compute Euler’s Totient Function → ϕ(N)=(p−1)×(q−1)

  4. Select a public exponent ee

    • Typically 65537 (2¹⁶ + 1) is used.

    • ee must satisfy 1<e<ϕ(N)1 < e < \phi(N) and be coprime to ϕ(N)\phi(N).

  5. Compute the private key d

    • dd is the modular inverse of e under ϕ(N)

Final Public Key: (N,e)
Final Private Key: (N,d)

3. RSA Encryption & Decryption

  • Encryption:

    • The sender encrypts the message MM using the recipient’s public key (N,e):

  • Decryption:

    • The recipient decrypts the ciphertext CC using their private key (N,d)(N, d):

Public keys are widely available, but decryption is impossible without the private key.

4. RSA Digital Signatures

RSA is also used for message authentication and integrity verification through digital signatures.

  1. Signing (Using Private Key)

    • The sender signs a message MM using their private key dd:

    • This ensures that only the sender could have generated this signature.

  2. Verification (Using Public Key)

    • The recipient verifies the signature using the sender’s public key ee:

    • If M′=M, the signature is valid.

Digital signatures are widely used in SSL/TLS certificates, blockchain, and secure communications.

5. RSA Vulnerabilities & Attacks

While RSA is secure, it is vulnerable to certain attacks:

Attack TypeDescriptionCountermeasure
Factorization AttackIf N=p×q is factored, the private key d can be recoveredUse 2048-bit or larger keys
Weak Key AttackPoor choice of e or weak primes can weaken securityUse secure primes and e=65537
Side-Channel AttackPower analysis, timing attacks, or electromagnetic leaks can expose keysUse constant-time algorithms and hardware security
MITM Key Exchange AttackAn attacker can replace the public key with their ownUse certificates (PKI) to authenticate public keys

To maintain security, RSA should use strong key sizes and secure implementation practices.

6. RSA vs. Other Cryptographic Algorithms

AlgorithmKey SizeSecurity LevelSpeed
RSA2048-bit+Secure but requires large keysSlow
ECC (Elliptic Curve Cryptography)256-bit (RSA-3072 equivalent)Stronger than RSA at smaller sizesFaster
AES (Symmetric Encryption)256-bitSecure but requires key exchangeVery Fast

RSA is strong but slow, and ECC is becoming the preferred alternative for modern cryptography.
AES is much faster but requires a separate key exchange method.

7. Real-World Applications of RSA

TLS/SSL (HTTPS security) → Website encryption
PGP (Pretty Good Privacy) → Secure email encryption
Digital Signatures → Document authentication, blockchain security
SSH (Secure Shell) → Secure remote access authentication

However, as quantum computing advances, RSA security may weaken, leading to research in Post-Quantum Cryptography (PQC).

ATTACK

RSA attacks can be categorized into two areas: discrete logarithm attacks and factorization attacks.
Most attacks focus on factoring N.

PGP

PGP (Pretty Good Privacy) is implemented based on RSA and is likely the most widely used encryption software.
PGP is a protocol, not an algorithm.

It uses an asymmetric encryption algorithm for key exchange and a symmetric encryption algorithm to encrypt the message.

0
Subscribe to my newsletter

Read articles from 박서경 directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

박서경
박서경