Chapter 4
Chapter 4
Public key
Cryptography
Review of Symmetric Cryptography
• Limitation:
▪ Key distribution
▪sender and receiver must share the same key
▪Needs secure channel for key distribution
▪Impossible for two parties having no prior
relationship
▪Needs many keys for n parties to communicate
▪ Digital signatures: equivalent of signature used in paper documents.
2
Asymmetric encryption
3
Cont..
4
Cont..
• Algorithms are based on mathematical functions
rather than on substitution and permutation.
• It is asymmetric(two key): a public & a private key.
▪ A public key, which may be known by anybody, and can be used to encrypt
messages, and verify signatures
▪ A private key, known only to the recipient, used to decrypt messages, and sign
(create) signatures
Common misconception
9
Cont…
• All participants have access to public keys.
• Private keys are generated locally by each participant and need
never be distributed.
• As long as a system controls its private key, communication is
secure.
• At any time, a system can change its private key and publish the
companion public key to replace its old public key.
Cont…
• Conventional encryption • Public-key encryption
▪ The same algorithm with the ▪ One algorithm is used for
same key is used for encryption and decryption
encryption and decryption. with a pair of keys, one for
▪ The sender and receiver encryption and one for
must share the algorithm decryption.
and the key. ▪ The sender and receiver must
▪ The key must be kept secret. each have one of the
matched pair of keys.
▪ It must be impossible to ▪ One of the two keys must be
decipher a message if no kept secret.
information is available. ▪ It must be impossible to
▪ Knowledge of the algorithm decipher a message if no
and samples of ciphertext other information is available
must be insufficient to ▪ Knowledge of the algorithm
determine the key. and samples of ciphertext
and one of the keys must be
insufficient to determine the
other key.
Cont…
Public-Key Cryptosystem: Secrecy
• Message source A
• plaintext: X = [X1,X2,…,XM]
• M elements of X are letters in some finite alphabet.
• Message destination B.
• B generates a related pair of keys: a public key, KUb, and
private key, KRb.
• Whereas KRb is only known to B.
Cont…
• KUb is publicly available.
• Ciphertext: Y = [Y1,Y2,…,YN]
Y = EKUb(X)
X = DKRb(Y)
• An opponent observing Y and having access to
KUb but not having access to KRb or X, attempts
to recover X and/or KRb.
• It is assumed that the opponent does have
knowledge of encryption (E) and decryption (D)
algorithms.
Cont…
24
Encryption and Decryption
• Encryption and decryption are of the following
form.
▪ Message M < n.
▪ Encryption key = (e,n).
▪ Decryption key = (d,n).
▪ Encrypt => C = Me mod n.
▪ Decrypt => M = Cd mod n=(Me)d mod n = Med mod n
• Both sender and receiver must know the value of n.
• The sender knows the value of e, and only the
receiver knows the value of d.
Cont…
• For RSA to be satisfactory for public key encryption, the
following requirements must be met:
1. It is possible to find values of e, d, n such that Med mod n = M for
all M<n.
2. It is relatively easy to calculate Me mod n and Cd mod n for all values
of M<n.
3. It is infeasible to determine d given e and n.
RSA Example:
• Example 2:
▪ Lets choose two primes: p=11 and q=13 then n=p×q=143. ant he
totient of n (n)= (p−1)⋅(q−1)=120.
▪ We choose random e=7 and calculated a private d=103
Cont..
• Lets choose our plaintext message, m to be 9:
• encryption:
▪ Me mod n=97mod143=48=c
• decryption:
▪ Cd mod n=48103mod143=9=m
• How to encrypt a message like "attack at dawn".
• First we need to convert the message into a numeric format.
29
Cont..
• Example : Each letter is represented by an ascii character or can be
encode with another encoding technique.
• Then we need to group the result number and we need to apply
encryption and decryption for each.
• E.g A=65 and a=97, d=100 e.t.c
30
RSA Security
33
Algorithm
• A prime number P and an integer G which is
primitive root of P.
• Both are publicly available numbers
▪ P is at least 512 bits
• Users pick private values a and b which is less
than P
• Compute public values
▪ x = ga mod p
▪ y = gb mod p
• Public values x and y are exchanged
34
Cont..
• Compute shared, private key
▪ ka = ya mod p
▪ kb = xb mod p
• Algebraically it can be shown that ka = kb
▪ Users now have a symmetric secret key to encrypt
Example
• Two Internet users, Alice and Bob wish to have a secure
conversation.
▪ They decide to use the Diffie-Hellman protocol
35
Example
36
Message Authentication and Hash Function
43
Hash and MAC Algorithms
▪ MD5
• designed by Ronald Rivest
• latest in a series of MD2, MD4
• the most widely used hash algorithm
▪ Secure Hash Algorithm (SHA-1, SHA-2..)
• SHA was designed by NIST (national institute of standards and technology) in
1993, revised in 1995 as SHA-1
• generally preferred hash algorithm
• not vulnerable to any known attacks
• a little slower than MD5
Cont…