Understanding RSA Encryption: The Rivest-Shamir-Adleman Algorithm

Key Generation, Encryption Process, Decryption Process, Advantages, Disadvantages, and Applications | Karthikeyan Nagaraj

Karthikeyan Nagaraj
InfoSec Write-ups

--

Introduction:

RSA (Rivest–Shamir–Adleman) is a public-key encryption algorithm that was developed in 1977 by Ron Rivest, Adi Shamir, and Leonard Adleman.

RSA is widely used for secure communication, digital signatures, and encryption of sensitive data RSA encryption is based on the difficulty of factoring large integers, which makes it very difficult to crack.

Public Key Cryptography

Public key cryptography, also known as asymmetric cryptography, is a cryptographic system that uses two keys: a public key and a private key. The public key is used for encryption, and anyone can use it to encrypt data that can only be decrypted using the private key. The private key is kept secret and is used for decryption.

Key Generation

  • RSA key generation involves generating two large prime numbers, p, and q.
  • The product of p and q is called the modulus, n.
  • The modulus, n, is made public, while the prime factors, p, and q, are kept secret.
  • The private key consists of the pair of prime numbers, p, and q, while the public key consists of the modulus, n, and a number, e, known as the public exponent.
  • The public exponent is usually chosen to be a small prime number, such as 65537.

Encryption Process

The encryption process in RSA involves the following steps:

  1. The message is converted into a number using a standardized encoding scheme, such as ASCII or Unicode.
  2. The message is raised to the power of the public exponent, e, modulo the modulus, n. This generates the ciphertext, which is the encrypted message.
  3. The ciphertext is sent to the recipient.

Decryption Process

The decryption process in RSA involves the following steps:

  1. The recipient uses their private key, consisting of the prime factors, p, and q, to calculate the value of the private exponent, d.
  2. The recipient raises the ciphertext to the power of the private exponent, d, modulo the modulus, n. This generates the original message, which is the plaintext.
  3. The recipient can now read the original message.

Example

Let’s take a simple example to illustrate the RSA encryption process. Suppose we want to encrypt the message “hello world” using RSA.

Here are the steps involved:

  1. Key Generation — We generate two prime numbers, p=61 and q=53. The modulus, n, is calculated as n=p*q=3233. We choose the public exponent, e=17.
  2. Encryption — We convert the message “hello world” into its ASCII representation, which is 104 101 108 108 111 32 119 111 114 108 100. We raise each number to the power of 17, modulo 3233, which gives us the ciphertext: 2790 3071 2276 2276 1217 1370 2286 1217 2286 569 1370.
  3. Decryption — The recipient uses their private key, consisting of the prime factors, p, and q, to calculate the value of the private exponent, d=2753. They raise each number in the ciphertext to the power of 2753, modulo 3233, which gives them the original message in ASCII representation: 104 101 108 108 111 32 119 111 114 108 100.

Advantages of RSA

  • RSA is a widely used and trusted encryption algorithm.
  • It is secure and can withstand attacks from current computers.
  • It provides a means of secure communication without requiring a shared secret key.
  • RSA can be used for digital signatures, which can verify the authenticity and integrity of data.

Disadvantages of RSA

  • RSA is a computationally intensive process, which can make it slow on low-end devices or for large amounts of data.
  • The security of RSA relies on the difficulty of factoring large integers. If someone were to discover a method for factoring large integers efficiently, then RSA would become vulnerable to attacks.
  • RSA is vulnerable to side-channel attacks, where an attacker can observe the physical characteristics of the device performing the encryption or decryption process to gain information about the key.

Applications of RSA

RSA is widely used in various applications, such as:

  1. Secure communication: RSA is used to encrypt data in secure communication protocols such as SSL/TLS and SSH.
  2. Digital signatures: RSA is used to create and verify digital signatures, which can authenticate the source and integrity of data.
  3. Password storage: RSA can be used to encrypt passwords stored in a database to protect them from unauthorized access.
  4. Payment systems: RSA is used in payment systems to encrypt sensitive data such as credit card numbers.

Conclusion

  • RSA is a widely used and trusted public-key encryption algorithm that is used to secure sensitive data in various applications.
  • It is secure and can withstand attacks from current computers, making it a popular choice for use in secure communication protocols, digital signatures, and password storage.
  • However, it is computationally intensive and can be slow on low-end devices or for large amounts of data.
  • It is also important to protect against side-channel attacks to ensure the security of the encrypted data.

Feel Free to Ask Queries via LinkedIn and to Buy me Coffee : )

Thank you for Reading!!

Happy Cryptography ~

Author: Karthikeyan Nagaraj ~ Cyberw1ng

--

--

Security Researcher | Bug Hunter | Web Pentester | CTF Player | TryHackme Top 1% | AI Researcher | Blockchain Developer