1 Cryptography:: 4.1 Encryption
1 Cryptography:: 4.1 Encryption
1 Cryptography:
The part where we develope algorithms to get security/ designing the algorithm.
2 Cryptoanalysis:
We try to break the security of designed algorithm.
3 Cryptology:
Cryptology: Cryptography + Cryptoanalysis
4
ATM 1 = PIN 1 + x = Y1 – write
ATM 2 = PIN 2 + x = Y2 – write
ATM 3 = PIN 3 + x = Y3 – write.....
Where,
PIN is the plain text
x is the ”secret key” (Any Number)
Y is the Cipher Text
4.1 Encryption
Convert readable text to an unreadable text.
Ciphertext: Its readable but meaningless and is used to find the plain text.
E(P,K)=C
1
4.2 Decryption
D(C,K)=P
5 Crypto
Crypto is based on two keys:
2. Public Key
• Public[E(P,Ck)=C]
• Secret[D(C,dk)=P]
2. Integrity(Reciever should be able to identify that message has not been altered)
3. Authentication(Able to identify that information information is been shared from the desired
sourse)
7 CAESAR Cipher
This cipher is named after ”Julius Caesar”. It relies on shiftingthe letters of a message by an
agreed number.
Agreed No.= 3
A=0,B=1,C=2,.......Z=25.
7.1 Encryption:
E(x,3)=(x+3)%26
7.2 Decryption:
D(C,3)=(C+26-3)%26
2
8
Plain text= INTERNET
Agreed No.= 3 (Secret Key)
Cipher text= LQWHUQHW (Eacj Alphabet+3)
N=pXq
Its easy to compute. Therefore,
Given N, find p,q, st. N=pXq.
Where, p q are large primes
10 Substitution Box
S : A → B with |B| ≤ |A|
Its a mapping where size of domain is less than equal to size of codamain.
11 Transposition Cipher
m = m1, m2, ....mt → plaintext
e: permutation on t elements (Secret Key)
1,2,3.....t
11.1 Encryption:
C = me(1), me(2), ......me(t) = c1c2....ct
where c is cipher text
3
11.2 Decryption:
m = Ce− 1(1)....Ce− 1(t)
Example:
1 2 3 4 5 6
Secret key e:
6 4 1 3 5 2
(Encryption)
It is a bijection(Permutation).
1 2 3 4 5 6
d = e− 1
3 6 4 2 5 1
(Decreption)
12 Substitution Cipher
m = m1m2m...ml
A = A, B, C, ..., Z
miA.
e: Substitution from A to A
e is Secret key.
12.1 Encryption:
C = e(m1)e(m2)....e(ml)
Example:
e(A)=Z, e(B)=D,... e(C)=A
4
13 Affine Cipher
A=0 to Z=25
Therefore, (Z26= 0-25) 0,1,2,...25 A= Set of elements A is Z26 Z26 =Z26 mod 26
K= Secret Key= (a, b)Z26XZ26.
x:plain text(xZ26.)
Encryption function
x(x, k) = (a.x + b)mod26 = C.
Decryption function
d(c, k) = ((c − b).a).a− 1)mod26
Multiplicative inverse: When we devide any number its mod should be 1.
Here, a− 1 is Multiplicative Inverse.
and b is Additive Inverse.
a ∗ a− 1 = 1mod26
plaintext: xZ26. gcd(a,26)=1
Z26=0,1,2,3,4,5 x, yZ26. Z=(x+y)%6
x + (6 − x) = 6%6 = 0
0: Additive identity
0 1 2 3 4 5
1 2 3 4 5 0
2 3 4 5 0 1
3 4 5 0 1 2
4 5 0 1 2 3
5 0 1 2 3 4
(x, yZ26.)
x+y=z%6=y
x ∗ 6y
1 is multiplicative identity
(x ∗ y)%6 = 1
0 0 0 0 0 0
0 1 2 3 4 5
0 2 4 0 2 4
0 3 0 3 0 3
0 4 2 0 4 2
0 5 4 3 2 1
5
This is Extended Eucledian algorithm(We can find the GCD). m is deviding (xy-1) there is one
integer t.
t = m/(xy − 1)
13.1 Question:
Let us consider m=17, x=3
Since, gcd = am + yx
Therefore,
1 = am + yx
1 = 3 − (1X2)
3 + (−1).2
3 + (−1)17 − (5X3))
3 + (−1).17 + (5X3)
6X3 + (−1)X17
6X3 ≡ 1 mod 17
14 Playfair Cipher
Secret key= Playfair Example
P L A Y F
I R E X M
B C D G H
K N O Q S
T U V W Z
Plain Text:H I D E
Therefore,
H I → BM
D E → OD
Ciphertext: B M O D
Using the secret key we have to prepare 5X5 table. We need to keep all 25 alphabets in 5X5
table. Exactly same alphabets I J so they are same. Therefore, J will also be considerd as I.
6
Message is H I D E ⇒
So, from the Playfair Example table, rectangle whose corner points are H I are replaced with
the end points of otherside B M. Same goes with D E, It shifts verticaly downwards.
So, E becomes D and D becomes O.
****