0% found this document useful (0 votes)
51 views13 pages

Rsa and Elgamal Algorithms

This document discusses the implementation of the RSA and ElGamal cryptographic algorithms. It provides details on how each algorithm works, including choosing prime numbers, calculating keys, encrypting and decrypting messages. It also gives an example calculation for each algorithm and discusses some of their applications and differences. The document was implemented in Java using the NetBeans IDE for a class project.

Uploaded by

Abhinav Chinnala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views13 pages

Rsa and Elgamal Algorithms

This document discusses the implementation of the RSA and ElGamal cryptographic algorithms. It provides details on how each algorithm works, including choosing prime numbers, calculating keys, encrypting and decrypting messages. It also gives an example calculation for each algorithm and discusses some of their applications and differences. The document was implemented in Java using the NetBeans IDE for a class project.

Uploaded by

Abhinav Chinnala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

IMPLEMENTATION OF

RSA AND ELGAMAL


ALGORITHMS

COUNSELLOR - G.REKHA MADAM


CO-ORDINATOR - S.NARASIMHA REDDY SIR

M.SRIRAM
B16CS111
3 CSE-2
Cryptography
 Study of techniques for secure communication in the
presence of third parties.
 It enables us to store sensitive information or transmit
it across networks so that it cannot be read by anyone
except the intended recipient.
 Types of Cryptography-
 Private Key Cryptography
 Public Key Cryptography
1.Private Key Cryptography
-uses only key called symmetric key
-called as Symmetric Cryptography
-Algorithms : DES , AES

2.Public Key Cryptography


-uses two keys(public and private keys)
-called as Asymmetric Cryptography
-Algorithms : RSA , ElGamal
RSA Algorithm
 RSA stands for Rivest Shamir Adleman.
 It was the first practical implementation of
public key encryption.
 The idea of RSA is based on integer prime
factorization.
RSA Algorithm
1.Choose large prime numbers p,q randomly
2.Calculate n=p*q
3.Euler’s Totient phi=(p-1)*(q-1)
4.Choose ‘e’ such that gcd(e,phi)=1 , 1<e<phi
5.Calculate ‘d’ such that ed mod phi=1
6.Public Key={e,n} Private Key={d,n}
7.M be the Message (PlainText) and M<n
8.Encryption:: CipherText(C)=M^e mod n
9.Decryption:: PlainText(M)=C^d mod n
Example
Destination(Client) Source(Server)
1. Let p=47 and q=59
2. n=47*59=2773 7.Let Message M=HI=31
3. phi=(47-1)*(59-1)=2668 ,M<n

4. Choose e=17 because 8. Encryption::


gcd(17,2668)=1 C=M^e (mod n)
5. d=157 since (17*157)mod C=31^7 (mod 2773)=587
2668=1
6.Public key={17,2773}
Private Key={157,2773}
9.Decryption::
C=587
M=587^157 (mod 2773)=31
ELGAMAL Algorithm
 It was described by Taher Elgamal in 1985.
 It can be defined over any Cyclic Group G.
 Its security mainly depends on computing
discrete logarithms.
ELGAMAL Algorithm
Algorithm Example

 1.Choose large prime number  P=11


p.
 2.Choose any element g from  generator g=2
the cyclic group Fp. (2^n mod 11 generates
numbers 1 to 11)
 3. Choose random number ‘a’
such that gcd(a,p)=1 ,1<a<p-1  private key a=3
 A=2^3 (mod 11)=8
 4.Calculate A=g^q (mod p)
 5.Public key={11,2,8}
 5.Public Key={p,g,A}
Private key={7}
Private Key={a}
Continued
 6.Let M be the message ,  Let M=7
0<M<p-1
 7.Encryption::  SOURCE
 Choose a random Let k=4
number k ,1<k<p-1 c1=2^4(mod 11)=5
 Compute c2=7.8^4(mod 11)=6
c1=g^k (mod p)  DESTINATION
c2=M.A^k (mod p)
M=6.Inverse(5^3)(mod 11)
 8. Decryption::
=6.3(mod 11)=18mod11
 M=c2.Inverse(c1^a) =7
(mod p) (Inverse(5^3) mod 11
Inverse(125)mod 11
->125*3 mod 11=1)
APPLICATIONS
 Client Server Architecture
 Online chatting
 Digital Signature

DIFFERENCES
1.RSA gives same ciphertext for repeated same
plaintext.
2.ELGAMAL gives different ciphertext for repeated same
plaintext.
LANGUAGES AND SOFTWARES
USED
 LANGUAGES:-
JAVA(SWING AND ABSTRACT WINDOW
TOOL KIT(AWT))
 SOFTWARES :-
NETBEANS IDE 8.2
THANK YOU

You might also like