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

Public-Key Cryptography: Dr. Amjad Ali Department of Computer Science COMSATS University Islamabad, Lahore Campus

Public-key cryptography uses a pair of keys (public and private) to encrypt and decrypt messages. It allows secure transmission over insecure channels. RSA is an important public-key encryption algorithm that is widely used today. It relies on the fact that factoring large numbers is computationally difficult, so decrypting a message without the private key is infeasible.

Uploaded by

Shaheer Arshad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Public-Key Cryptography: Dr. Amjad Ali Department of Computer Science COMSATS University Islamabad, Lahore Campus

Public-key cryptography uses a pair of keys (public and private) to encrypt and decrypt messages. It allows secure transmission over insecure channels. RSA is an important public-key encryption algorithm that is widely used today. It relies on the fact that factoring large numbers is computationally difficult, so decrypting a message without the private key is infeasible.

Uploaded by

Shaheer Arshad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Public-key Cryptography

Dr. Amjad Ali


Department of Computer Science
COMSATS University Islamabad, Lahore Campus
What Is Cryptography?
 Cryptography – Greek word meaning “secret writing” -- is the mathematical
“scrambling/encryption” of data so that only someone with the necessary key can
“unscramble/decrypt” it.

 Cryptography allows secure transmission of private information over insecure


channels (for example packet-switched networks).

 Cryptography also allows secure storage of sensitive data on any computer.


Classical Cryptography:
Secret-Key or Symmetric Cryptography
 Alice and Bob agree on an encryption method and a shared key.

 Alice uses the key and the encryption method to encrypt (or encipher) a message and
sends it to Bob.

 Bob uses the same key and the related decryption method to decrypt (or decipher) the
message.
Advantages of Classical Cryptography
 There are some very fast classical encryption (and decryption) algorithms

 Since the speed of a method varies with the length of the key, faster algorithms allow
one to use longer key values.

 Larger key values make it harder to guess the key value -- and break the code -- by
brute force.
Disadvantages of Classical Cryptography

 Requires secure transmission of key value


 Requires a separate key for each group of people that wishes
to exchange encrypted messages (readable by any group
member)
 For example, to have a separate key for each pair of people,
100 people would need 4950 different keys.
Public-Key Cryptography: Asymmetric Cryptography

 Alice generates a key value (usually a number or pair of


related numbers) which she makes public.

 Alice uses her public key (and some additional information)


to determine a second key (her private key).

 Alice keeps her private key (and the additional information


she used to construct it) secret.
Public-Key Cryptography (continued)

 Bob can use Alice’s public key to encrypt a message for Alice.

 Alice can use her private key to decrypt this message.

 No-one without access to Alice’s private key (or the information


used to construct it) can easily decrypt the message.
An Example: Internet Commerce
 Bob wants to use his credit card to buy some brownies from Alice
over the Internet.

 Alice sends her public key to Bob.

 Bob uses this key to encrypt his credit-card number and sends the
encrypted number to Alice.

 Alice uses her private key to decrypt this message (and get Bob’s
credit-card number).
Hybrid Encryption Systems

 All known public key encryption algorithms are much slower


than the fastest secret-key algorithms.

 In a hybrid system, Alice uses Bob’s public key to send him a


secret shared session key.

 Alice and Bob use the session key to exchange information.


Internet Commerce (continued)

 Bob wants to order brownies from Alice and keep the entire
transaction private.

 Bob sends Alice his public key.

 Alice generates a session key, encrypts it using Bob’s public key,


and sends it to Bob.

 Bob uses the session key (and an agreed-upon symmetric


encryption algorithm) to encrypt his order, and sends it to Alice.
Digital Signatures: Signing a Document

 Alice applies a (publicly known) hash function to a document that


she wishes to “sign.” This function produces a digest of the
document (usually a number).

 Alice then uses her private key to “encrypt” the digest.

 She can then send, or even broadcast, the document with the
encrypted digest.
Digital Signature Verification

 Bob uses Alice’s public key to “decrypt” the digest that Alice
“encrypted” with her private key.

 Bob applies the hash function to the document to obtain the digest
directly.

 Bob compares these two values for the digest. If they match, it
proves that Alice signed the document and that no one else has
altered it.
Digital Signature : Signer and Verifier
Secure Transmission of Digitally Signed Documents

 Alice uses her private key to digitally sign a document. She


then uses Bob’s public key to encrypt this digitally signed
document.

 Bob uses his private key to decrypt the document. The result is
Alice’s digitally signed document.

 Bob uses Alice’s public key to verify Alice’s digital signature.


Historical Background

 1976: W. Diffie and M.E. Hellman proposed the first public-key


encryption algorithms -- actually an algorithm for public
exchange of a secret key.

 1978: L.M Adleman, R.L. Rivest and A. Shamir propose the RSA
encryption method
 Currently the most widely used
 Basis for the spreadsheet used in the lab
RSA (Rivest-Shamir-Adleman):
Public-Private Key Encryption
Algorithm
RSA
▪ Invented by Rivest, Schamir and Adleman in 1977

▪ The security of RSA depends on the problem of factoring large


numbers.

▪ The speed of RSA does not beat DES, because DES is about 100
times faster than RSA in software.
RSA
▪ Step 1: Select two large prime numbers p and q.

▪ Step 2: Compute n = pq \\n will be used in modular arithmetic

▪ Step 3: Compute totient function


ϕ (n) = (p-1)(q-1)

▪ Step 4: Select the value Public Key “e” such that 1< e < ϕ (n)
e and ϕ (n) are coprime means the gcd (e, ϕ (n) =1)

▪ Step 5: Compute the Private Key “d” by taking the multiplicative


inverse of e such that
d ≡ e-1 (mod ϕ (n)) or ed ≡ 1(mod ϕ (n))
RSA Encryption And Decryption

 Message m
 Encryption Public key (e, n)
C ≡ me (mod n)
 Decryption
m ≡ cd (mod n)

 It is proved that
cd ≡ (me)d ≡ med ≡ m (mod n)
Due to the fact that ed ≡1 (mod ϕ (n))
RSA Example
 If p = 17 and q = 31 are chosen, then

 n= pq = 17x31 = 527

 ϕ (n) = (p-1)x (q-1) =16x30 = 480

 If e = 7 is chosen, then compute


d ≡ e-1 (mod ϕ (n)) or ed ≡ 1(mod ϕ (n))
≡ 7-1 (mod 480) ≡ 343

 This decryption key d is calculated using the extended euclidean algorithm

ed ≡ 7x 343 (mod 480) ≡ 2401 (mod 480 ) ≡ 1


Security Of RSA

 Relies on the fact that prime factorization is computationally very


hard.

 Let k be the number of bits in the binary representation of n.

 No algorithm, polynomial in k, is known to find the prime factors of


n.

 Try to find the factors of a 100-bit number.


Why RSA Works (2)

 If one knows only M, finding P and Q is hard: in essence, the


number of operations depends on the value of M.
 The simplest method for factoring a 768-bit number takes
about 2384  3.94 x10115 trial divisions.

 A more sophisticated methods takes about 285  3.87 x 1025


trial divisions.

 A still moresophisticated method takes about 241 


219,000,000,000 trial divisions
Why RSA Works (3)

 No-one has found a quick algorithm for factoring a large


number M.

 No-one has proven that such a quick algorithm doesn’t exist


(or even that one is unlikely to exist).

 Peter Shor has devised a very fast factoring algorithm for a


quantum computer, if anyone manages to build one.

You might also like