SlideShare a Scribd company logo
RSA Algorithm:
Pseudocode and
Implementation in C++
Name: Anees ur Rehman
Reg#: BCB242011
Design And Analysis Of Algorithm
Introduction
•What is RSA?
• RSA (Rivest-Shamir-Adleman) is a widely used public-key
cryptosystem for secure data transmission.
• It is based on the mathematical properties of large prime
numbers.
•Key Concepts:
• Public Key: Used for encryption.
• Private Key: Used for decryption.
•Applications:
• Secure communication (e.g., HTTPS, SSL/TLS).
• Digital signatures.
• Data encryption.
Common Problems Related to RSA
•Key Generation Challenges:
• Finding large prime numbers.
• Ensuring the security of the private key.
•Computational Complexity:
• Modular exponentiation is computationally expensive.
•Security Concerns:
• Vulnerable to brute-force attacks if key size is small.
• Vulnerable to quantum computing attacks (Shor’s algorithm).
•Implementation Issues:
• Handling large integers in programming languages.
RSA Algorithm Overview
•Steps in RSA:
• Key Generation:
• Choose two large prime numbers, pp and qq.
• Compute.
• Choose public key ee such that and .
• Compute private key .
• Encryption:
• , where M is the plaintext message.
• Decryption:
• , where C is the ciphertext.
“1. Generate two large prime numbers, p and q.
2. Compute n = p * q.
3. Compute φ(n) = (p-1) * (q-1).
4. Choose e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1.
5. Compute d such that d ≡ e^(-1) mod φ(n).
6. Public Key: (e, n).
7. Private Key: (d, n).
Pseudocode for RSA
Key Generation
“1. Input: Plaintext message M, Public Key (e, n).
2. Compute ciphertext C = M^e mod n.
3. Output: Ciphertext C.
Pseudocode for RSA
Encryption
“1. Input: Plaintext message M, Public Key (e, n).
2. Compute ciphertext C = M^e mod n.
3. Output: Ciphertext C.
Pseudocode for RSA
Encryption
“1. Input: Ciphertext C, Private Key (d, n).
2. Compute plaintext M = C^d mod n.
3. Output: Plaintext M.
Pseudocode for RSA
Decryption
Working Example of RSA
Step 1: Key Generation Step 2: Encryption
• Let M=65.
• Compute
Step 3: Decryption
• Compute
Time and Space Complexity
•Key Generation:
• Time Complexity: , where k is the number of bits in n.
•Encryption/Decryption:
• Time Complexity: for modular exponentiation.
•Space Complexity:
• O(k)O(k) for storing keys and intermediate results.
Implementation in C++
Implementation in C++
Implementation in C++
Summary
• RSA is a robust public-key cryptosystem based on the difficulty of
factoring large prime numbers.
• It involves key generation, encryption, and decryption using modular
arithmetic.
• Proper implementation requires handling large integers and ensuring
security through appropriate key sizes.
• Applications include secure communication and digital signatures.
References
•Books:
• "Introduction to Algorithms" by Cormen, Leiserson, Rivest,
and Stein.
• "Applied Cryptography" by Bruce Schneier.
•Online Resources:
• Wikipedia: RSA Algorithm
• GeeksforGeeks: RSA Algorithm
Thank you
Anees ur Rehman
Reg#: BCB242011

More Related Content

PPTX
RSA Algorithem and information about rsa
PDF
Analysis of rsa algorithm using gpu
PDF
ANALYSIS OF RSA ALGORITHM USING GPU PROGRAMMING
PPTX
RSA-Algorithm-in-Modular-Arithmetic11 (1) (1).pptx
PPT
RSA Algorithm - Public Key Cryptography
PPTX
Rsa Crptosystem
PDF
CRYPTOGRAPHY (2).pdf
RSA Algorithem and information about rsa
Analysis of rsa algorithm using gpu
ANALYSIS OF RSA ALGORITHM USING GPU PROGRAMMING
RSA-Algorithm-in-Modular-Arithmetic11 (1) (1).pptx
RSA Algorithm - Public Key Cryptography
Rsa Crptosystem
CRYPTOGRAPHY (2).pdf

Similar to RSA Algorithm and its implementation in C++.pptx (20)

PPTX
RSA Algm.pptx
PPTX
Rsa algorithm
PPT
Rsa rivest shamir adleman
PPT
RSA Algorithm.ppt
PDF
Presentation about RSA
PPT
PUBLIC KEY & RSA.ppt
PPTX
Data security using rsa
PDF
Public-Key Cryptography.pdfWrite the result of the following operation with t...
PPT
ch09_rsa_nemo.ppt
PPTX
Information and network security 33 rsa algorithm
PPT
ch09-Critt.Asimettrica.notes has good info in security
PPTX
RSA.pptx
 
PPT
Digital Signature Recognition using RSA Algorithm
PPTX
RSA & MD5 algorithm
PPT
PPTX
IOT_DEPARTMENT_CST_433_PSI__RSA_unit2.pptx
PDF
12- Public-key Cryptography and RSA the lecture on cryptography
PPT
Rsa diffi-network security-itt
PPTX
Module-2 Public-Key Cryptography and RSA.pptx
RSA Algm.pptx
Rsa algorithm
Rsa rivest shamir adleman
RSA Algorithm.ppt
Presentation about RSA
PUBLIC KEY & RSA.ppt
Data security using rsa
Public-Key Cryptography.pdfWrite the result of the following operation with t...
ch09_rsa_nemo.ppt
Information and network security 33 rsa algorithm
ch09-Critt.Asimettrica.notes has good info in security
RSA.pptx
 
Digital Signature Recognition using RSA Algorithm
RSA & MD5 algorithm
IOT_DEPARTMENT_CST_433_PSI__RSA_unit2.pptx
12- Public-key Cryptography and RSA the lecture on cryptography
Rsa diffi-network security-itt
Module-2 Public-Key Cryptography and RSA.pptx
Ad

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
KodekX | Application Modernization Development
PPTX
Big Data Technologies - Introduction.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPT
Teaching material agriculture food technology
PPTX
MYSQL Presentation for SQL database connectivity
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25 Week I
KodekX | Application Modernization Development
Big Data Technologies - Introduction.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Unlocking AI with Model Context Protocol (MCP)
Programs and apps: productivity, graphics, security and other tools
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx
Teaching material agriculture food technology
MYSQL Presentation for SQL database connectivity
Ad

RSA Algorithm and its implementation in C++.pptx

  • 1. RSA Algorithm: Pseudocode and Implementation in C++ Name: Anees ur Rehman Reg#: BCB242011 Design And Analysis Of Algorithm
  • 2. Introduction •What is RSA? • RSA (Rivest-Shamir-Adleman) is a widely used public-key cryptosystem for secure data transmission. • It is based on the mathematical properties of large prime numbers. •Key Concepts: • Public Key: Used for encryption. • Private Key: Used for decryption. •Applications: • Secure communication (e.g., HTTPS, SSL/TLS). • Digital signatures. • Data encryption.
  • 3. Common Problems Related to RSA •Key Generation Challenges: • Finding large prime numbers. • Ensuring the security of the private key. •Computational Complexity: • Modular exponentiation is computationally expensive. •Security Concerns: • Vulnerable to brute-force attacks if key size is small. • Vulnerable to quantum computing attacks (Shor’s algorithm). •Implementation Issues: • Handling large integers in programming languages.
  • 4. RSA Algorithm Overview •Steps in RSA: • Key Generation: • Choose two large prime numbers, pp and qq. • Compute. • Choose public key ee such that and . • Compute private key . • Encryption: • , where M is the plaintext message. • Decryption: • , where C is the ciphertext.
  • 5. “1. Generate two large prime numbers, p and q. 2. Compute n = p * q. 3. Compute φ(n) = (p-1) * (q-1). 4. Choose e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1. 5. Compute d such that d ≡ e^(-1) mod φ(n). 6. Public Key: (e, n). 7. Private Key: (d, n). Pseudocode for RSA Key Generation
  • 6. “1. Input: Plaintext message M, Public Key (e, n). 2. Compute ciphertext C = M^e mod n. 3. Output: Ciphertext C. Pseudocode for RSA Encryption
  • 7. “1. Input: Plaintext message M, Public Key (e, n). 2. Compute ciphertext C = M^e mod n. 3. Output: Ciphertext C. Pseudocode for RSA Encryption
  • 8. “1. Input: Ciphertext C, Private Key (d, n). 2. Compute plaintext M = C^d mod n. 3. Output: Plaintext M. Pseudocode for RSA Decryption
  • 9. Working Example of RSA Step 1: Key Generation Step 2: Encryption • Let M=65. • Compute Step 3: Decryption • Compute
  • 10. Time and Space Complexity •Key Generation: • Time Complexity: , where k is the number of bits in n. •Encryption/Decryption: • Time Complexity: for modular exponentiation. •Space Complexity: • O(k)O(k) for storing keys and intermediate results.
  • 14. Summary • RSA is a robust public-key cryptosystem based on the difficulty of factoring large prime numbers. • It involves key generation, encryption, and decryption using modular arithmetic. • Proper implementation requires handling large integers and ensuring security through appropriate key sizes. • Applications include secure communication and digital signatures.
  • 15. References •Books: • "Introduction to Algorithms" by Cormen, Leiserson, Rivest, and Stein. • "Applied Cryptography" by Bruce Schneier. •Online Resources: • Wikipedia: RSA Algorithm • GeeksforGeeks: RSA Algorithm
  • 16. Thank you Anees ur Rehman Reg#: BCB242011