Download as pdf or txt
Download as pdf or txt
You are on page 1of 69

CRYPTOGRAPHY

Unit:III
Asymmetric Key Algorithm, Digital Signature and RSA

Prof. V. S. Mahalle
Department of Computer Science and Engineering
Shri Sant Gajanan Maharaj College of Engineering, Shegaon
o Asymmetric Key Algorithms, Digital Signatures and RSA:

✓ Introduction to Asymmetric Key Cryptography


✓ Symmetric Vs Asymmetric Cryptography
✓ The RSA Algorithm
✓ Digital Signatures
✓ Knapsack and other Algorithms.
INTRODUCTION

• Classification of Cryptosystem w. r. t. Key:


[1] Symmetric Key Cryptosystem
[2] Asymmetric Key Cryptosystem
• SYMMETRIC KEY CRYPTOGRAPHY / ENCRYPTION:
Also referred as Conventional / Private-key / Single-key / Secret key Cryptography.

o Sender and recipient share a common key for encryption & decryption respectively.
• Basic terminologies:
Plain Text, Cipher Text, Secret Key, Encryption & Decryption.
• Algorithms:
DES, 2-DES/3-DES, AES, Blowfish, IDEA, RC5 & RC4.
• ASYMMETRIC KEY CRYPTOGRAPHY / ENCRYPTION:
Also referred as public key Cryptography.

• Major difference between symmetric & asymmetric key cryptography:


key is the difference means key(s) used.

• Symmetric means --> Only one Key i.e.


Use same key for encryption & decryption
• What is Problem? -->
Problem is how sender sends key to the receiver?.

• Asymmetric means --> Use two keys:


(1) Public Key
(2) Private Key
that means: every user on Network have two keys.
Example:

User-A User-B
(Sender) (Receiver)

PuA =Public key of User A PuB = Public key of User B


PrA = Private Key of User A PrB = Private Key of User B

• If A encrypt message M using his public key PuA , then • If A encrypt message M using B’s public key PuB , then
it is decrypted only using his private key PrA. it is decrypted only using B’s private key PrB.
• or Or • or

• If A encrypt message M using his private key PrA , • If A encrypt message M using B’s private key PrB , then
then it is decrypted only using his public key PuA. it is decrypted only using B’s public key PuB.
• Public Key: <== Known to every one, I can broadcast it on Network.
Or
We keep public key at authorized third party, receiver will take it from them.

• Private Key: <== Known to ourself & not known to others. Do not share it to others.

Key Details A (Sender) B (Receiver)


should know should know
A’s Private Key Yes No

A’s Public Key Yes Yes

B’s Private Key No Yes

B’s Public Key Yes Yes

Matrix of Private and Public Keys


How Encryption Done?
• We have 4-Cases.
Case 1: A send message M to B using A’s public key then B required to decrypt
encrypted message only by using A’s private key. • This Case is Invalid,
A B
because PrA is only with
(Sender) (Receiver)
Sender A, So nobody
E[PuA ,M] C D[PrA ,C] can decrypt it.

Case 2: A send message M to B using A’s private key then B required to decrypt
encrypted message only by using A’s public key.
• This Case is Invalid,
A B because everybody knows
(Sender) (Receiver)
PuA, So anybody can
C
E[PrA ,M] D[PuA ,C] decrypt it. No
confidentiality will achieve
here.
Case 3: A send message M to B using B’s private key then B required to decrypt
encrypted message only by using B’s public key.
A B • This Case is Invalid, here
(Sender) (Receiver) A is not able to encrypt,
C because PrB, is with B &
E[PrB ,M] D[PuB ,C] not with A.

Case 4: A send message M to B using B’s public key then B required to decrypt
encrypted message only by using B’s private key. • This Case is valid, here A
A B encrypt message M using
(Sender) (Receiver) B’s public key & B will
E[PuB ,M] C D[PrB ,C] decrypt it using his private
key & B’s private key is
• Always use receivers Public key to encrypt message M. only with B, So only B
• Receiver decrypt it by using his Private key. receiver can decrypt
• This is the basic concept of Asymmetric Key Cryptography. encrypted message.
dIFFERENCE
Symmetric Key Cryptographic System Asymmetric key Cryptographic System
✓KE = KD ✓KE ≠ KD
✓Number of Keys Used: 1 ✓Number of Keys Used: 2
(for Encryption & Decryption) (2 keys for Encryption & 2 keys for Decryption)

✓Key, K = Must kept secret. ✓One Key kept Secret = Private key
(Only known to Sender & Receiver) Other Key make public= Public key

✓Encryption & Decryption Speed: Faster ✓Encryption & Decryption Speed: Slower
✓Most commonly used Symmetric key ✓Most commonly used Symmetric key
Cryptographic Algorithms: DES, AES Cryptographic Algorithms:RSA, Diffie-
Hellman
Public Key Cryptography Algorithm
RSA
• Developers:
• Ron Rivest
• Adi Shamir
• Leonard Adleman
• Publication Year: 1977
• It is based on Number theory : Prime Numbers
• Key Size used: 1024 to 4096 bits

• Algorithm involves 3 basic steps:


1) Key Generation: public & private keys
2) Encryption of Plain text
3) Decryption of Cipher text.
• Public key is known to every one.
• Message encrypted with public key can only be decrypted using private key.
Different steps of RSA for key generation, encryption & decryption
1. Choose two distinct large prime numbers.
Consider numbers: p & q

2. Compute Product:
n=p*q
3. Compute ᶲ(n),
ᶲ(n) = (p-1)(q-1)
Where ᶲ(n) = Euler’s Totient function
4. Choose integer, e
such that
1< e < ᶲ(n)
where e & ᶲ(n) are- Relatively prime(co-prime)
i.e. GCD(e, ᶲ(n)) = 1
5. Now, we get public key,
public key = (n,e)
6. Calculate d for private key,

d = e-1 (mod ᶲ(n)) • d * e = 1 mod ᶲ(n)


• d*e mod ᶲ(n) = 1
7. We get private key,
private key = (n, d)

8) To get Cipher Text, encrypt bit pattern M


C = me (mod n)

9) To decrypt cipher text C & get Plain text M,


M = Cd (mod n)
Example-1:
Given p =17 & q =11 two prime numbers & plain test M = 88
Compute
public key, private key, cipher text & original plain text form cipher text?
(i) Calculate product,
n = p*q = 17 * 11 = 187
(ii) Calculate ᶲ(n),
ᶲ(n) = (p-1) (q-1) = (17 -1) (11-1) = 160
(iii) Select e such that e is relatively prime to ᶲ(n) less than ᶲ(n) & greater than 1.
ᶲ(n) =160
Suppose we choose e =7,
Verify GCD(7, 160) = 1

7|7 2|160
|1 2|80
2|40
2|20 7 = 7, 1
2|10 160 = 2,2,2,2,2,5, 1
5|5
|1 GCD = 1*1 = 1
(iv) Determine d,
such that d*e mod160 = 1 & d <160
Therefore, select d = 23 Because(d*e), (23 *7) = 161
161 mod 160 = 1
(v) Public key & Private key:
public Key = {7,187}
private Key = {23,187}

11
88
88 887Mod 187 = 11 1123Mod 187 = 88

For encryption,
C = 887Mod 187 = 11
( me mod n)

For decryption,
M = 1123 mod187 = 88
Example-2:
Given p =3 & q =11 two prime numbers & plain test M = 5
Compute
public key, private key, cipher text & original plain text form cipher text?

1) n = p * q 4) Find d?
= 3 * 11 d*e mod ᶲ(n) = 1 6) Find M from C?
= 33 d*3 mod 20 = 1
7*3 mod 20 = 1 M = Cd mod n
2) ᶲ(n) = (p-1)*(q-1)
= 2 * 10
d=7 M
= 26= 5 33
7 mod

= 20 5) M = 5
.
C = Me mod n
3) Find e? = 53 mod 33
GCD(e, ᶲ(n)) = 1
GCD(e, 20) = 1
= 125 mod 33
C = 26
. e=3 .
Example-3 & 4:
Given p =61 & q =53 two prime numbers 0r take p =47 & q = 71
Compute
public key, private key, cipher text & original plain text form cipher text?

Example-5:
Given p =3, q =11, e = 7 & M = 5
find d?
Diffie-Hellman Key Exchange
• Cryptographic System with Key:
o For encrypting plain text to get cipher text &
o For decrypting cipher text to get original plain text.

Encryption Decryption Key


Key KE KD

P C P
E D
Now, we want
• Secret key, used in encryption process is
1) Symmetric Encryption: securely send to Receiver.

KE = KD • Algorithms: DES & AES • How secret key used in symmetric


encryption is shared between two
2) Asymmetric Encryption: users?
• How to verify key exchange between
KE ≠ KD • Algorithms: RSA two user is successful?.
• One way is to generate secret key,
• Every user have two keys, public & private keys.
• If one key is used for encryption, then other key is use for decryption. • at sender site & at receiver site.
• In Deffie-Hellman,
o For encryption of plain text & decryption of cipher text:

✓ Symmetric Encryption Technique is Used (Same key is used).

o For Exchanging key between Sender & Receiver:


✓ Diffie-Hellman key exchange algorithm is used.
✓ This uses Asymmetric Encryption Technique.

✓ i.e. Public key • To generate Secret Key


& Uses ==> at
Private key Sender site & Receiver site
And
The key generated at sender & receiver sites are matched, then we
can say,
Secret Key Exchange between Sender & Receiver is successful.
ALGORITHM
(i) Assume Prime Number, q
(ii) Select α,
such that
α must be primitive root of q
&
α < q
(iii) Calculate public key of user A & public key user B using their Private key.
Assume: XA ----> Private key of A
X as Private key == > XB ----> Private key of B
Y as Public key &
YA ----> Public key of A
YB ----> Public key of B
(a) Calculate Public Key of User A===> YA ?,
Using his Private Key XA and XA < q

YA = αXA mod q

(b) Calculate Public Key of User B == > YB ?


Using his Private Key XB and XB < q

YB = αXB mod q
(iv) Generate Secret Key K at Sender site & at Receiver site:
• Public keys are available to all.
K -> K ->
• Keys Generated must
Key Generated Key Generated be equal at both the
at Sender site = at Receiver site sites, then
we can say, Key
K = (YB) XA mod q K = (YA) XB mod q Exchange is successful.
• EXAMPLE:
Prime Number q = 11
Private Key of A, XA = 8
Private Key of B, XB = 4
Determine Public key of A & Public Key of B?
Also Generate secret key at both sender & receiver sites & verify Key is exchange successfully or not?
• Select α ?
α should be Primitive root of 11

• What do you mean by primitive root? How can we find primitive root?
We say α is a Primitive root of q,
if
α mod q, α2 mod q, α3 mod q ………… αq-1 mod q
should give result ===>
{1, 2, 3, 4, … q-1} <--- Value should not be repeated.
This condition satisfied, then we say that,
α is a Primitive root of q.
Select α ?
q-1
Power of α 1 2 3 4 5 6 7 8 9 10
1 1 1 1 1 1 1 1 1 1 1
22 2 4 8 5 10 9 7 3 6 1
3 3 9 5 4
4
55
6
77
8

Number
Selecting, α
Suppose we consider α = 1,
then verify 1 is primitive root of 11 or not. Put α = 1 in equation,
α mod q, α2 mod q, α3 mod q ………… αq-1 mod q
If result is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} then 1 is primitive root of 11.
If not then consider α = 2 :
Now we selected α = 2 & Given XA = 8.
Determine YA?

YA = αXA mod q
= 2 8 mod 11
= 256 mod 11
YA=3

Now, α = 2 & Given XB = 4.


Determine YB?

YB = αXB mod q
4
= 2 mod 11
=16 mod 11
= 5 (public key)
• Calculate Secret Key, K at Sender & Receiver sites:

XA = 8
XB = 4
YA = 3

YB= 5

K -> K ->
Key Generated Key Generated
at Sender site at Receiver site

K = (YB) XA mod q K = (YA) XB mod q

K=4 K=4
Digital Signature
• Asymmetric Key Cryptography:
CASE-A: PuB PrB Sender uses receiver’s public
key to encrypt message.
C
P E D • This is valid approach.
A B Failure of encryption.
(Confidentiality not achieved)
PrA PuA
PuA Accessible to anybody.
C Anybody who is interested can
P E D
decrypt message.
But
When A encrypt message using his private key, his intension is not to achieve confidentiality.
His intension here is to achieve (i) Authentication (ii) Non-repudiation
• Hacker also not achieve their any purpose, because hacker does not have A’s private key
to encrypt & resend.
• B will not believe it comes from A, because (after changes) it was not encrypted with A’s
private key (A’s private key is only with A & not with hacker or any others.

“If Message encryption is done with Sender’s Private Key,


then it is called Digital Signature & it form the basis of
digital signature”

• Digital Signature ensures,


➢ Message Authentication
➢ Message Integrity
➢ Non-repudiation of Message.
Digital Signature Technique
• NIST --> Published it in 1991. It was revised in 1993 & 1996.

• DSS(Digital Signature Standard) --> Make use of SHA-1 algorithm for calculating Message Digest over original Message.
&
Use Message Digest to perform digital signature.

Digital Signature is implemented in two ways:


1. RSA Approach (RSA & Digital Signature)
2. DSA/DSS Approach (DSA & Digital Signature)

Purpose of RSA:
(i) Encryption of message
(ii) Performing Digital Signature over message
Purpose of DAS:
(i) Only performing Digital Signature over message.
1. RSA and Digital Signatures
• RSA can be used for performing digital signatures.
• Understand how this work in step-by-step in algorithm:

h
M H
M A Compare
h D
H E h

PRA, PUA

• Compare two message digest are equal, then trust & accept the message. Otherwise reject it.
Algorithm:
o Assume,
Sender A want to send message M to the receiver B along with digital signature S
calculated over the message M.

Step1: The sender (A) uses the SHA-1(message digest algorithm) to calculate the
message digest(MD1) over the original message (M).
Original Message
(M)

SHA-1 Fig. Message digest calculation


Algorithm

Message Digest
(MD1)
Step2: The sender (A) now encrypts the message digest with his/her private key. The
output of this process is called as the digital signature(DS) of A.

PrA
Message Digest Digital Signature Fig. Digital Signature Creation
Encryption
(MD1) (DS)
.

Step3: Now the sender (A) sends the original message (M) along with the digital
signature(DS) to the receiver (B).

Original Message Original Message


(M) (M)
Sender Network Receiver
Digital Digital
Signature Signature
(DS) (DS)
.
Fig. Transmission of Original message and Digital Signature together
Step4: After the receiver (B) receives the original message (M) and the sender’s (A’s)
digital signature, B uses the same message digest algorithm as was used by the
A, and calculates its own message digest (MD2).

Original Message
(M)

SHA-1
Algorithm
Fig. Receiver calculate its own Message digest

Message Digest
(MD2)
Step5: The receiver (B) now uses the sender’s (A’s) public key to decrypt the digital
signature.
Note that A has used her private key to encrypt her message digest (MD1)
to form the digital signature. Therefore, only A’s public key can be used to
decrypt it. The output of this process is the original message digest as was
calculated by A (MD1) in step 1.

PubA
Digital Signature Message Digest
(DS) Decryption
(MD1)
.
Fig. Receiver receives Sender’s message digest
Step6: B now compares the following two message digests:
• MD2, which it had calculated in step 4
• MD1, which it retrieved from A’s digital signature in step 5.
If MD1 = MD2, the following facts are established:
• B accepts the original message (M) as the correct, unaltered message from A.
• B is also assured that the message came from A, and not from someone
posing as A.

Message digest Message digest


(MD1) (MD2)

Is
MD1=MD2?

Fig. Digital Signature verification


Trust and accept the Reject the
original message Original message
(M) (M)
Attack on RSA Signature:
• Chosen-message attack1:
Attacker creates two different messages M1 & M2. They need not have close resemblance
(similarity).
The attacker somehow manages to persuade the genuine user to sign these two messages M1 &
M2 using RSA digital signature scheme. After these attempts are successful, the attacker computers
a new message M = M1 * M2 and then claims that the genuine user has signed this message M.
• Key-only attack:
Assumption is that the attacker only has access to the genuine user’s public key. The attacker
somehow then obtains a genuine message M and its signature S. The attacker then tries to create
another message MM such that the same signature S looks to be valid on MM.
However, it is not an easy attack to launch since the mathematical complexity beyond this is
quite high.
• Known-message attack:
The attacker tries to use a feature of RSA whereby tow different messages having two different signatures can
be so combined that their signatures also combine.
For example: We have two messages M1 & M2 with respective digital signatures as S1 & S2. Then
If M = (M1*M2) mod n, mathematically S = (S1 * S2) mod n.
Hence, the attacker can compute M = (M1*M2) mod n and then S = (S1*S2) mod n to forge a
signature.
2. DSA and Digital Signatures
G PRA
H
// M Signature
M H h Signature
Algorithm S verification
Algorithm
Compare
K
r
Random s,r ---> Signature Components
No.
2) Digital Signature Standard(DSS)/Digital Signature Algorithm approach(DSA):
3. K is any integer number 0<k<q.
1. Global Component:
p --->
q---> 4. Signature Component:
g--->
2. User Private Key:
Assume
x = any random number in the 5. Verification Component:
range 0<x<p.

User Public Key(y):

Y=
Note: Refer class notes for above 1 to 5.
w/
MWMQNC j“
W;
V’Y’H ' I. -

53.1»
, g g .

13%;?
ML“? Wt CNN”?
i .. . ¥

? 5

KNI‘ l‘ifi'C-K
*Devdp‘oeA we RaW‘n
H 4“?“qu
5"

M01)?“ M

*‘iGi/Qefid OQ‘O‘M K631 0% WWW h MST???“

mm we {w w MW ~s~
«#0

m 5
3a... * B4?» $847913“ ..
_. ,, _ ..

w - (x (g; .3”. I. w)
f’Kme’acK N~ @Wfi‘afi
(é)?(¢;‘p5
Vs

5‘
525ch
- ‘ V x,
m5 ?CJ£W
luv
‘fi
1
V«!

.OUU
mu “I
KnaPSwW
V A I; l
(y
(b

K12“, "aehdqu‘tm '/


“*N’?“kkfg
< i a
-‘é‘:;‘:’“ff"”"W“"tf""

WWWM“?
~r~--7:~:“r:7.~%:<fl*%~ ,,
K611“ h
I» H > I

‘ .

qu
, ¢ . e .

a; glam WW

”e
, , .

‘5} Dem

—-> we“ W5
Hm,

MW: .\ '6 {Strata


.
<

‘ e ‘
1‘ / ‘ ‘

*1

. ‘*
4 r’ "51' ;,
Mflww——QMM‘MMA “MMWH.,,;,¢_,._._*W;,M.m
" L2,, ‘-
““"‘,’f*:fii“"i‘ff1""j:f:’:fff‘.,
1 M"

__
4 t ‘

'
’ '
‘ 1Y4

WWW
"‘
0K
’ . 1
*‘~
A
e
'

. . <7 . ’LJ uh < .3

-WQEE-flg T196?“
g ,

“T"
...
Wm?”I" /4§~_
W‘

we me
"/7 ..
£5 f

5%“
‘ 5

HQAQ
P

<53:

”WW—”I
2
I ' i ;

3:? , ,

-,
““‘” """“
-

“' : """"
~

,3.-MM...W._.3__..______.__.. l .31.:
Mb
. ,

”rim
.
.

.
1w a K . em
.ii . L. ’ I , wz-y. . I I ‘ H.

- ..
_ r_')4mB-¢.KQ ‘

L541“! Mow]4|
._ . .


f
’ ’ m a {a
’1" ’
6"" “ é -‘

i *7 f“: sexed; E4153 mafia“ Z€_f§€".’,,,,


dam
:

H2232 Kma’PSM/K wow 1%


____._
'Vn' III-
3 3 ‘ ,
«A mpgmk
*1! an; . as... - as»

n 4 M49.WM:. c a 5
m

. m J) a «a. ‘
-S'ritr‘.
-
\
‘QEV‘M
“ .

. m

1.1 ., 1. <3
1.42233 ;

)
gm..wm_wwmmwwflm*; Www’ mw....,%®wf. ”7...“-..
éum PAM—WW Hat”‘44,-3,“
' .~ ”mar .. .3 i - .....3.....,,.. .

ouxn«.m.;f
' , . » .

*W‘” Hétfi4LmS—»‘.

vamw 3-...
.
g’

3* , , * ' - ‘ s .. ., -. 1T. W4~ . . ..

H
,1. , i,”
3’“ .
.m
’t

_‘_..~-«-"
a

,‘

" h
Nyghw. m3 Hg‘ .,
..,
:

<¢r‘
:
1,.

‘5} 3;. ‘fd


,4

t {5’9
‘‘
4'?“
4

“$-1;M
4 . y
W
NJ
'_
\

‘5

J 9

_'

E
E
'1

:5

-
‘iMuHifih
Emmi

/
_

1456
'

W1 éé
'

6bI
I"
-;

1+
W--.
K€V

WC
0”

In
,

mm»
——>

-.--

-;;,''-
fiQhe}.§ L (“V

2’?

W5’

No.4. 51
.

W--- .2

—""

mam
-

<

t;

b ‘3 r4 KQ
h

‘2,

f: 591044 We? 91 "Nu-FEW


’t
ML] N1» (v) gdyua—ué‘
.

"'_""""
.

at.
1

M~
.

W...
WW”)...

0")
5m

eqc
_.

.4: 2;.
'
m.

3‘

..

hahdpm $0.99
Noe

#3:;ngW
flh'ritrfigflmw

a "x e--

m
z
.2.

,1

bun A344 K?
.
.. I I};

“j
”MW.

W
>1

{LEw
'

_.-.__._,,M_,, -
1
_’
1/

a
'

2W“‘0‘ m , 0 l c {5
m,..' "u
,H.z,;~t(Hv+w+1ro:—7§L
15"" ‘ A

‘41 / 7 ’ ~
Page: ' I]

215%”
a3;
. ‘ ‘ . " v » - - A v. w,_,...,_.;,.._....,. ‘ ' "4- W ’

w is
'
'
-

13
W1: .

,3.
. ‘

1.;
e
1. 1o I a

$GQQ , Ho «=9 61— ‘gch. V69 r

QJLW 0 . L o 0
‘ /
. : _ ‘ ' '

1 ‘
' f
,. s

‘, l1
. 1 .

A , . I" , . ' D a
A. r i -w.>...,......:.....~.. 4»""“‘"“"‘ «oLw... -« A» .,, “a. -A 4‘:

”0.1530.
~-

3 ; m
'‘
, >

@m__4_., , i I '
f:

.31 A”
at
New
n. A“),
o
3‘
3

c
.

A;
;

wank

3

oo
.
'

*
1;
MSW
3’

I
,

t,
A,

,
1

o
LmAkj’JAA

._ AAAA
3'

AMAAA

101110313.”
9°13)pr
1
\. > \ l I lo. l2

PM w (3/6)» 2» m, AA; E

I ‘

0 o z; ‘51 + an; 2:12.13-3.3.A,-_33_,.AW.W,...AW


» N 1 1 oO :21: '3‘ + $1. 1 1111.130, .213?
to : J IO ":19 '3.‘ “1‘ ”0ng422.5(
‘ [/»;P"’@ TM! 121 ~:-~~:
I

,1 ',
9n7M8 flak *Ww
.,

+924 2%

[J P

3
w “w. ;
~_-::~::Wfl~--C*)t‘:ifi:fr -‘_
Mfiwé‘g e SNQH

M
m
“ ""
{T

- :-

_¢'
‘ '
P .(
‘ T

C'MC‘
.

‘I":
'31
. ‘ ‘

p.
u-.. ‘0 ‘

.,
.,.—-—-—- x

. . 3

, ‘ V
.-( “v“y:
‘ x ‘

W
I.‘
~ ~. -

‘- '
5 L: .

r"
" ‘ '

.( 5‘»
~

4‘ ’ /. 2—.
y- i

,7, ‘ i

an.
W

I ‘‘
.
I " ~

-
A

V.
's

M

. .

‘ f $ ..‘ z
E

.. I , f .‘ o ' ‘ ‘f

. g : , ,

‘ , .
v”
' _ ' ‘4'»; ‘ ; ., e ‘9

y
.

W}
p
I

.4
' ‘ a”?
.3
;
. . »

'
.

C -‘-
'A

"
o . n

i- - * ' - ‘

I.

E
. > I

I} f‘ ' . ‘
.

y i
I
:
“W h;
'

1 _

_,
”'—'W‘ w" .“nmw‘b
.
'2
. a. ‘1 ’1‘. ‘fi
tr
‘ >

.5


a: ' A,

‘ \

I;
x.

Q ’ ’ ,,
.
Sffjilx K3334 9V? \\ 1“ch WOW—2:2; ‘ 2)

PMMM L\ 32}, ,g 1.0““..5 H o .234 r?


was;
I .9 1

§“f“f:ffii“““<222< 7- 5) 222 ‘2 '


a

9" 92‘ PW
m:-(.\,'z- ,Wfl,l§mt-3012fl9m
‘92 2922: 2‘29 ' *

E:
in.

I, HWWXWMWIWQWRWJJLLW
22m”
,

’7. :32) 0 2- 1. #- R 3 (9) a”) \‘ \ \ \ o W o 22.....2222:

.222 c 2222 W 2 2222)


will; 8W9 9 $9 ., .

9%-“.14429923219h
Message Authentication

• What is message authentication


• Why we need message authentication
• Different types of message authentication
Understanding the Problem:
Hacker While sharing messages (files/
emails), there may be chance of
Message
“help Sita” alteration of message in transit.
Insecure channel
User A Third party can listen communication between A & B User B
We need a mechanism, to
Hacker
authenticate a message. i.e. How can
Message we check the authenticity of a
“kill Sita” message?

Insecure channel Message Authentication:


User A It assures that
Hacker caught the message & changes the content. User B
(i)message received are exactly as send
(i.e. contain no modification, insertion, deletion)
Hacker
(ii) Identity of sender is valid.
Message i.e. A & B are Perfect user:
“kill Sita” B receives message from A only.
A send message to B only
User A Insecure channel
User B
B consider, it is from A & according to message, he perform action.
Types of Authentications
(Different ways to achieve an authentication)
1. Message Encryption:
cipher text ---> act as Authenticator
i.e.
Receiver Authenticated by Sender
Sender Authenticated by Receiver This process done only through cipher text.

2. Message Authentication Code(MAC):


We have authentication function C with message M & secret key k.
C( M, k) = Fixed Length Code
Authentication function Called MAC or Message Digest
Act as Authenticator
3. Hash functions:
We have Hash function H with message M & it is independent of key k.
The output we get is fixed length code.
H(M) = Fixed Length Code
Called Hash Code, h
Act as Authenticator
1. Message Encryption:
a) Symmetric Encryption:
k k

M E M D M

User A User B

• Key k, shared between Sender and Receiver only.


• Cipher text act an Authenticator. Only receiver is able to decrypt the cipher text to get original message.

• Confidentiality is achieved (provided)


• Authentication is also achieved, but it is better to understand Authentication in
Asymmetric Cryptography.

• Major Problem of Symmetric Encryption: Key distribution


(How to send secret key to receiver site for decryption)
b) Asymmetric Encryption (public key encryption):
• How it provide Confidentiality , Authentication?
• Case-I: PRB
PUB

M E M D M

User A User B
PUA, PRA, PUB, PRB,

• Confidentiality:
“Unauthorized user should not get message. i.e. Only authorized user have access to message”

When we are using public key of user B for encryption, then private key of user B must be needed for decryption.
Public key available to all -----> Any user can encrypt the message & send to receiver.
i.e. No authentication is possible.
But for decryption, we require private key & it is available only with user B. The message is decrypted only
with user B’s private key. Only user B can decrypt the received message.
Therefore, Confidentiality is achieved but Authentication fails.
Case-II:

PRA PUA

M E M D M

User A User B

Only user A can encrypt the Any user (third party) may use
message & send to receiver. public key of user A to decrypt
User A is Authenticate User. the message.
No confidentiality of message

This provides only Authentication and not Confidentiality.


Case-III:

PRA PUB PRB PUA

M E M E M
M D M D M

User A User B

Message encrypted using Private key of A: message Only decrypt using A’s public key.

Message encrypted using public key of B: message Only decrypt using B’s private key.

Both Authentication and Confidentiality is Achieved.


2. Message Authentication Code(MAC):
• MAC function act as an Authenticator.
C(M , k) ---> It takes variable length message M and secret key k as input and
Produces an Authentication Code.

Secret key Secret key

User A User B
K=abc K=abc
M AEF123 k
Help sita + MAC If message altered, then different MAC
MAC(generated) There is no encryption,
M Append C Therefore,
k A M Compared
M MAC No confidentiality
MAC(appende)
C MAC AEF123 MAC is used to
authenticate a message.
Fixed Length Code
Authenticity is there
k2
M MAC
C
Append D MA If equal, then
M Compared data is send
k1 A E M C
by perfect
M MAC MAC(appende) Sender.
C MAC k2
Authenticity
Fixed Length Code is there.
3. Hash function:
Hash code act as an authenticator,
independent from key
H(M) = fixed length code

h
M H
M A Compare
h D
H E h

PRA, PUA
Anybody can decrypt the hash code--> Drawback of this
k
M H
A E M D h
M h D
H E k

PRA,
Sign up
User name: VSM User name: VSM
Password: VSM12 Password: fdfdfdfdf
MD-5
Sign in
User name: VSM User name: VSM
Password: abddddeeertretretr Password: fdfdfdfdff

1. The hash size is always fixed.


2. Hash function is non reversible. (hash function also
called as one way hash function..
3. Hash result can not collide.
4. If I change even one bit of the I/P from right or left
then entire has should change.
SHA: SECURE HASH ALGORITHM

• Developed by NIST in 1995.


• SHA algorithms are based on MD-5 Algorithm.
• Based on different digest lengths, SHA include algorithms such as
SHA-1, SHA-256, SHA-384, SHA-512
• SHA called secure because it is computationally infeasible to find a message which
corresponds to a given message digest. Also not produces the same digest for two
different message.
• The most commonly used hash function from SHA family is SHA-1 is used in SSL/TLS, PGP,
SSH, MIME & IPSec for security & authentication purposes./
SHA-1: SECURE HASH ALGORITHM-1
• SHA-1 is the extension of MD-5 algorithm. i.e. Similar to MD-5 with small modification.
• SHA-1 having 5-steps, similar to the steps in MD-5.
• In SHA-1,
• Input is plain text message:-
- Message of Arbitrary length (Variable length message)
- Message length should be < 264 bits.
(i.e. SHA-1 work with any I/P message that is less than 264 bits in length.)

• Output: Message digest.


- 160 bits fixed length Message digest

By knowing above, we can proceed the SHA-1 algorithm.

Different steps & processes of SHA-1 are:


Step1: Append padding bits.
• Add padding bits to the end of original message to prepare message in
multiple of 512 bits.
• Bits used in padding: 10000… (first is 1 followed by 00…)
• SHA-1 sequentially processes block of 512 bits of message
Step2: Append length.
• Padding remaining 64bits to make message length multiple of 512
bits.
last block of 512 bits

|64bits
• Now process each block

Step3: Initialize MD buffer:


• This is required, to hold intermediate values & final message digest.
• The size of this buffer is 160 bits.
• To handle 160 bits message digest, we need to have a registers. In SHA-1 there are
five registers named as

• Each & every register having capacity of 32bits. (Total 5*32 = 160 bits)
• We need to initialize this registers by 32 bits random hexadecimal value.
Step4: Process original message with the help of initialization registers(buffers).

• In this, we are having total 4 rounds.


• Each & every round is similar, but they are having their individual primitive
function.
• Each & every round having 20 steps.
• Each & every round have 3 things:
(i) Primitive function
(ii) Constant value, k
(iii) 20 bits world value

f1, k, w[0 – 19] <------- for first round.


First round

f1, k, w[0 – 19]

f1, k, w[0 – 19]

f1, k, w[0 – 19]

f1, k, w[0 – 19]


512 bits message

128bits
f1, k, w[0 – 19]

128bits
f1, k, w[0 – 19]
128bits
f1, k, w[0 – 19]
128bits
f1, k, w[0 – 19]
Step5: Output

We are having five registers


A, B, C, D, E
512 bits message B C D E
A Each having 32 bits hexadecimal
value. We need to proceed that
128bits(W0)
f1, k, w[0 – 19]

128bits
f1, k, w[0 – 19]
128bits
f1, k, w[0 – 19]
128bits
f1, k, w[0 – 19]

+ + + + + After all 512bits block have been


processed, the out from the nth stage is
the 160bits message digest.
160 bits message digest
SHA-1 MD-5
1. Message digest size 160bit Message Digest size 128bit
2. It is stronger against brute force It is Weaker against brute force attack
attack than MD-5 than SHA-1
3. It is not vulnerable against It is vulnerable against cryptanalyst.
cryptanalyst.
4. Slower than md-5 Faster than SHA-1
5 Perform 80 steps Perform 64 steps

You might also like