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

CSC314 Network Security Lecture 9

Uploaded by

ammar.ali01
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

CSC314 Network Security Lecture 9

Uploaded by

ammar.ali01
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Lecture 9 Network Security CSC314

Hash Function, RSA Algorithm


Ammar Ali Qazi
Welcome!!
Insert the title of your subtitle Here
Hash Functions
• Mapping of variable sized input data in to a fixed
sized data
• One way function that cannot be revert
• The output is called “Digest”
Hash Algorithms
MD-5: 512-bit block, 128-bit hash
Secure Hash Algorithm (SHA)
SHA-1: 512-bit block, 160-bit hash
SHA-224: 512-bit block, 224-bit hash
SHA-256: 512-bit block, 256-bit hash
SHA-384: 1024-bit block, 384-bit hash
SHA-512: 1024-bit block, 512-bit hash
Applications of Hash Functions
 Password Storage
• Hash function provides protection to the password storage
• Instead of storing password in plain text, passwords are stored
in form of Hashes so that no body can guess the actual
password
Application [Cont..]
 Data Integrity
• Data integrity is the most common application
of Hash functions
Example:
• Create a text file in Notepad and save as “test”. Below shows
the content of the text file
Example [cont..]
• Open Command prompt and run “Certutil” command to apply Hash
function as shown below

Note: The above command calculates the


hash value for SHA1 i.e. 160Bit
Example [cont..]

• Make a small change in the text and put a little


dot at the end as shown below
Example [cont..]
• Calculate the Hash again

Note that just by adding a single dot has


changed the entire Hash value
DH Algorithm
 Diffie-Hellman Key Exchange
• Used to generate a common secret (symmetric)
key
Alice generates a large Bob generates a large
random number x random number y
gx mod n

gy mod n

key = gxy mod n


Example:
g=3 n=7
Alice secret integer = x=2
Bob’s secret integer = y = 3

Alice calculates gx mod n and send it to Bob


i.e. 32 mod 7 = 2

Bob calculates gy mod n and send it to Alice


33 mod 7 = 6

Alice now calculate (gy mod n) x mod n = 62 mod 7 = 1

Bob also calculate the same at his end i.e. 23 mod 7 = 1

Both came up with same value that is 1


Therefore the secret key will be 1

By using DH formula

Key = gx y mod n = 32*3 mod 7 = 729 mod 7 = 1


Digital Signature Application
Private/Public Key pair and Hash Function:
A public key is used to verify the digital signa-
ture
Digital Signature Process
• The signer calculates the hash for the data he needs to sign
• The signer, using his private key, encrypt the hash calculate.
• Signer sends the original data and the digital signature to the receiver
• The document is in clear text but it has the signature of the sender and
can be sent so that it can be read by anyone but not altered
• For the verification, The receiving software first uses the signer’s public
key to decrypt the hash
• The receiving software will generate the new Hash and compare it with
the original Hash
• If the two hashes match, the data has not changed since it was signed.
RSA Algorithm
•Select two large prime numbers, p and q
•Find n=p*q
•Find φ(n)=(p-1)(q-1)
•Select an odd number ‘e’ such that e and φ(n) are relative prime
•Find a number d, such that
de mod φ(n) = 1

Public key = (e, n)


Private key = (d, n)

Verification:
To encrypt a plain text message “M”
C = Me mod n
To decrypt the block
M=Cd mod n
RSA Example
p = 3 and q = 11
n = p * q = 3 * 11 = 33
φ(n) = (p - 1) * (q - 1) = 2 * 10 = 20
φ(n) = 20
Choose e such that e and φ(n) are co-prime
Let e = 7
Choose d such that
de mod φ(n) = 1
d=3
(3)(7)mod20 = 1
Public key is (e, n) => (7, 33)
Private key is (d, n) => (3, 33)
Verification:
The encryption of m = 2 is c = 27 mod 33 = 29
The decryption of c = 29 is m = 293 mod 33 = 2
Thank you
Insert the title of your subtitle Here

You might also like