LearnViz CompSci
Home / Learn / Security & Cryptography / RSA

Beginner Topic 16 of 51 Security & Cryptography

RSA

Public-key system based on factoring large numbers.

How it works

RSA is a public-key algorithm based on the difficulty of factoring a product of two large primes. A key pair is generated from primes p and q with modulus n equal to p times q, a public exponent e and a private exponent d such that encrypting is m to the e mod n and decrypting is c to the d mod n. Keys are typically 2048 to 4096 bits, and real use needs padding schemes like OAEP for encryption and PSS for signatures.

Step-by-step walkthrough

  1. Choose two large primes and multiply them to get n.
  2. Publish n and e, keep d secret.
  3. Encrypt a message as m to the power e modulo n.
  4. Decrypt with c to the power d modulo n.
  5. Security depends on the difficulty of factoring n.

Where it is used

TLS certificates, code and document signing, SSH keys and encrypted key exchange have used RSA for decades, although elliptic curves are increasingly preferred.

Common pitfall

Textbook RSA without padding is insecure and malleable. Small exponents, shared primes from poor randomness and short keys have led to real breaks. RSA is slow and limited in message size, so use it to encrypt symmetric keys. Side-channel leakage during private-key operations is a risk. Prefer vetted libraries and migrate to stronger or post-quantum schemes over time.

Where it fits in the course

RSA is topic 16 of 51 in Security & Cryptography, rated Beginner. It follows Asymmetric Encryption. The next topic is Hash Functions.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Security & Cryptography quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is RSA?
Public-key system based on factoring large numbers. It belongs to Security & Cryptography and is a beginner-level topic.
Where do people use RSA?
TLS certificates, code and document signing, SSH keys and encrypted key exchange have used RSA for decades, although elliptic curves are increasingly preferred.
What is the most common mistake with RSA?
Textbook RSA without padding is insecure and malleable.
What should I learn before this topic?
Start with Asymmetric Encryption, the topic just before it in Security & Cryptography.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Security & Cryptography quiz.
Is RSA hard to learn?
It is a Beginner topic, so it works as an entry point. If the terms are new, read the explanation twice and try the visualizer before the quiz.
How long does it take to learn RSA?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to RSA?
Asymmetric Encryption, Hash Functions, AES are closely connected. The full list is in the related topics section of this page.
What should I study after RSA?
Continue with Hash Functions, the next topic in Security & Cryptography.

Related topics