0% found this document useful (0 votes)
21 views

Lecture Notes On Public Key Cryptography (Rsa and Elgamal)

The document discusses public-key cryptography and the RSA algorithm. It provides examples of how RSA can be used for encryption and decryption. Specifically: 1) RSA uses a public/private key pair, where the public key is used to encrypt messages and the private key is used to decrypt them. 2) The document gives steps for generating the public and private keys in RSA. It also provides an example of encrypting a message and decrypting it. 3) Confidentiality with RSA is achieved by a receiver using their private key to decrypt ciphertexts encrypted with the sender's public key. An example demonstrates this by having one person encrypt and send a message that only the intended recipient can decrypt.

Uploaded by

samaher hussein
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Lecture Notes On Public Key Cryptography (Rsa and Elgamal)

The document discusses public-key cryptography and the RSA algorithm. It provides examples of how RSA can be used for encryption and decryption. Specifically: 1) RSA uses a public/private key pair, where the public key is used to encrypt messages and the private key is used to decrypt them. 2) The document gives steps for generating the public and private keys in RSA. It also provides an example of encrypting a message and decrypting it. 3) Confidentiality with RSA is achieved by a receiver using their private key to decrypt ciphertexts encrypted with the sender's public key. An example demonstrates this by having one person encrypt and send a message that only the intended recipient can decrypt.

Uploaded by

samaher hussein
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

TheUniversityofBabylon

DepartmentofSoftware

LECTURENOTESONPUBLIC KEYCRYPTOGRAPHY
(RSAandElGamal)
By
Dr.SamaherHusseinAli
CollegeofInformationTechnology,UniversityofBabylon,Iraq
[email protected]

4/11/2012

Publickeycryptography
Calledalsoasymmetriccryptography
Thekeysusedtoencryptanddecryptaredifferent.

Anyonewhowantstobeasenderneedstopublishanencryptionkey,whichis
knownasthepublickey,KB.
Anyonewhowantstobeareceiverneedsauniquedecryptionkey,whichis
knownastheprivatekey,kv.
IfBwantstosendanencipheredtexttoA,Bshouldknowsthethe encryption
algorithm andAspublickey.
4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

ConfidentialityviaPublickeycryptography
Samaher wants to send a secret message m to Eman
Eman should have 2 keys: public KB and private kv
Prior to message encryption, samaher gets by some means an authentic copy
of Emans public key (i.e., the encryption key)

4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

PublickeySystems

Itprovidesconfidentialitybydependondigitalsignatures.
Itreducenumberofusingkeys,example;ifweneedcommunication
among100usersintraditionmethods,weneed
(n(n-1)/2)= 100(99)/2=4950 keys
while,whenweusethepublickeysystemneedonly100keys

RSA

ItisnamedafteritinventorsRonRivest,Adi ShamirandLenAdleman.
Publishedin1978
Itisthemostwidelyusedpublickeyencryptionalgorithmtoday.
Itprovidesconfidentialityanddigitalsignatures.
Itssecurityisbasedonthedifficultyofintegerfactorization

4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

RSAalgorithm(keygenerationforRSApublickeyencryption)
Each entity A creates a public key and a corresponding private key by doing
the following
Who is capable of computing public key?
Generate three prime numbers p and q, e
Compute n=p*q
As Public key: (e, n) // to be published
Who is capable of computing d?
d

gcd( ( n )) * ( n ) 1
e

(n)=(p1)(q1)
Toverificationd:wemust[e*dmod(n) 1]
Asprivatekey:(d,n))//tobekeptsecretlybyA

4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

RSAEncryption/Decryption
Summary:Aencryptsamessagem forB.Uponreception,
Bdecryptsitusingitsprivatekey.
Encryption:Ashoulddothefollowing
ObtainBsauthenticpublickey(n,e).
Representthemessageasanintegerintheinterval[0,n1]
Computec =me modn//Encryption
Sendtheciphertext ctoB
Decryption:torecoverplaintextmfromc,Bdoesthefollowing
Usetheprivatekeyd torecoverm =cd modn//Decryption

4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

RSAEncryption/Decryption

4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

Example1:Let,p=3,q=17,e=5:FindthepublicandSecretkeythen
cipherthemessageABC
n=p*q=3*17=51
Publickey<e,n>=<5,51>
d=(GCD((n))*(n)+1)/e
(n)=(p1)(q1)=(31)(171)=(2*16)=32
GCD((n))=GCD[(P1)(q1)]=GCD(2,16)=2
d=((2*32+1)/5)=(64+1)/5=65/5=13
SecretKey<d,n>=<13,51>
Toverificationd:
e.d mod(n)=1
5*13mod32
65mod32=1

4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

Example1:Let,p=3,q=17,e=5:FindthepublicandSecretkeythen
cipherthemessageABC
2.Findtheciphertextusingthepublickey<e,n>=<5,51>
Ci=Mie modn
C1=(1)5 Mod51=1mod51=1
C2=(2)5 Mod51=32mod51=32
C1=(3)5 Mod51=243mod51=39
3.FindtheciphertextusingtheSecretKey<d,n>=<13,51>
Mi=Cid modn
M1=(1)13Mod51=1
M2=(32)13 Mod51=2
M1=(39)13 Mod51=3

4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

Example2:Confidentiality
Takep =7,q =11,son =p*q=77
(n) =(p1)(q1)=(71)(111)=60
Lete =17 publickey(17,77)
Computed =[gcd(6,10)*60+1]/17=53
17x53mod60=1 secretkey(53,77)

samaher wantstosecretlysendEman themessage


HELLO[0704111114]

0717 mod77=28
0417 mod77=16
1117 mod77=44
1117 mod77=44
1417 mod77=42

samaher sendsciphertext [2816444442]


4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

Example2:Confidentiality
Eman receives[2816444442]
Eman usesprivatekey< 53,77>,todecryptthemessage:

2853 mod77=07

1653 mod77=04

4453 mod77=11

4453 mod77=11

4253 mod77=14

Nooneelsecouldreadit,asonlyEman knowshisprivatekeyandthatis
neededfordecryption

4/11/2012

Dr.SamaherHusseinAli

NotesofLecture8

You might also like