Chapter 3 Cryptographyyy
Chapter 3 Cryptographyyy
Cryptography
1
Cryptography
is the study of how to mathematically encode and decode messages
2
Types Of Cryptography
3
Types Of Cryptography
2. Asymmetric Cryptography: different keys are used for encryption and
decryption.
Use public key for encryption and a private key for decryption.
4
Cont’d …
2. Hash functions: are irreversible, one-way functions that protect the data, at
the cost of not being able to recover the original message
Applications Of Cryptography:
Computer passwords
Electronic Signatures
Authentication
Cryptocurrencies
End-to-end encryption
6
Symmetric encryption model
A symmetric cipher model is composed of five essential parts:
Encryption Algorithm (E): takes plain text and secret key as inputs
and produces Cipher Text as output using techniques such as
substitutions, E(x, k) = y
Cipher Text (y): It is the formatted form of the plain text (x) which
is unreadable for humans
D(y, k) = x 8
Cryptography
Three Dimensions of Cryptographic Systems
3. The way in which the plaintext is processed: block cipher and stream cipher
If the plain text is considered as the string of bits, then the substitution technique
would replace bit pattern of plain text
a form of symmetric encryption the same key can be used to both encrypt
and decrypt a message.
11
Substitution technique ….
Rules: Repeating plaintext letters that are in the same pair are separated with a filler letter
E.g. balloon = ba lx lo on
1. Two plaintext letters on same row of the matrix replace by letter to the right. E.g. ar RM
2. Two plaintext letters on same column replace by letter beneath, with the top element of the
column e.g. mu CM
3. Each plaintext letter in a pair is replaced by the letter that lies in its own row and column13
Substitution technique ….
Hill Cipher
15
Substitution technique ….
encrypt for mor (c1 c2 c3)=(12 14 17)
C1=12x17+14x21+2x7 mod 26 =532mod 26 =12
C2=12x17+14x18+2x17 mod 26 = 490mod26=22
C3=5x12+14x21+17x19 mod 26 =677mod26 =1
mor = MWB
encrypt for emo (c1 c2 c3)=(4 12 14)
C1=4x17+12x21+2x14 mod 26 =348mod 26 =10
C2=4x17+12x18+2x14 mod 26 = 312mod26=0
C3=5x4+12x21+14x19 mod 26 =538mod26 =18
emo= KAS
16
Substitution technique ….
17
Substitution technique ….
18
Substitution technique ….
decryption using hill algorithm
decryption requires the inverse of matrix K
19
Substitution technique ….
decryption using hill algorithm…
Find adjoint of K to find adjoint ,first find cofactor Aij
A11 = A12= A13=
18x19-2x21=300 21x19-2x21=-357 21x2-2x18 =6
A21 = A22= A23=
17x19-2x5 =-313 17x19-2x5=313 2x17-2x17 =0
A31 = A32= A33=
17x21-18x5=267 17x21-5x21=-252 17x18-21x17 =-51
Aij=mod26 = mod26
20
Substitution technique ….
decryption using hill algorithm…
AdjK =(
mod26 =, =
mod 26
= 17 mod 26
mod 26=
21
Substitution technique ….
decryption using hill algorithm …
decryption: RRLMWBKASPDH
p=C mod 26
(p1p2p3)=(17 17 11) mod 26
P1= (17x4+15x17+24x11)mod26 =587mod26 =15 P
P2= (17x9+17x17+0x11)mod26 =442mod26 =0 A
P3= (17x15+6x17+17x11)mod26 =544mod26 =24 Y
The palintext of RRL = PAY and use the same procedure for the other
Exercise
a. Encrypt the message “meet me at the usual place at ten rather than eight
oclock” using the Hill cipher with the key a Show your calculations and the
result.
b. decryption of the ciphertext to recover the original plaintext.
22
TRANSPOSITION TECHNIQUES
Transposition cipher …
The order of the columns then becomes the key to the algorithm
Key: 4 3 1 2 5 6 7
24
TRANSPOSITION TECHNIQUES
Transposition cipher …
x y z dummy character
Cipher text: TTNAAPTMTSUOAODWCOIXKNLYPETZ
exercise
Key: CIPHER
25
Stream Ciphers
the plaintext is processed one bit at a time
27
THE FEISTEL STRUCTURE FOR BLOCK CIPHERS
The input block to each round is divided into two halves denote as left
28
THE FEISTEL STRUCTURE FOR BLOCK CIPHERS
how it works
29
Asymmetric (public-key )cryptography
It is a process of using a pair of related keys i.e. public key and
private key to encrypt and decrypt a message protect it from
unauthorized access or use.
30
Asymmetric (public-key )cryptography
Rivest–Shamir–Adlemam (RSA) is an asymmetric cryptography
algorithm.
It works on two different keys i.e. Public Key and Private Key.
The block size must be less than or equal to in practice, the block size
is i bits, where < n ≤ . 31
Asymmetric (public-key )cryptography
Encryption and decryption are of the following form for plaintext
block M and ciphertext block C.
C = mod n
The sender knows the value of e, and only the receiver knows the
value of d.
33
Asymmetric (public-key )cryptography
the keys were generated as follows.
Select p, q p and q both prime, p ≠ q
Calculate n = p * q
Calculate ∅(n) = (p - 1)(q - 1)
Select integer e gcd (∅(n), e) = 1; 1< ∅ < ∅(n)
Calculate d, d = 𝑒^(−1)(mod ∅(n))
Public key PU = {e, n} and Private key PR = {d, n}
34
Asymmetric (public-key )cryptography
the keys were generated as follows.
Select p, q p and q both prime, p ≠ q
Calculate n = p * q
Calculate ∅(n) = (p - 1)(q - 1)
Select integer e gcd (∅(n), e) = 1; 1< ∅ < ∅(n)
Calculate d, d = 𝑒^(−1)(mod ∅(n))
Public key PU = {e, n} and Private key PR = {d, n}
35
Asymmetric (public-key )cryptography
Select two prime numbers, p = 17 and q = 11.
Calculate n = pq = 17 * 11 = 187.
Select e such that e is relatively prime to ∅(n) = 160 and less than ∅(n) ; we
choose e = 7.
The resulting keys are public key PU = {7, 187} and private key PR = {23, 187}.
The example shows the use of these keys for a plaintext input of M = 88. For
encryption, we need to calculate C = mod 187
36
Asymmetric (public-key )cryptography
mod 187 = [( mod 187) * ( mod 187) * (mod 187)] mod 187
mod 187 = 88
mod 187 = [( mod 187) * ( mod 187) * (mod 187)* ( mod 187) * (mod 187)]
mod 187
mod 187 = (11 * 121 * 55 * 33 * 33) mod 187 = 79,720,245 mod 187 = 88
Exercise: two prime number p =13 , q=11 find ,n, ∅(n) , e,d, c and m. 37
Key management and exchange
Cryptographic keys are important in security system
Generation
Distribution
Use
Storage
40
Cryptographic hash functions
The same input data always generate the same hash value
A small change in the input data will generate a new hash value that
is extensively different from the previous hash value 41
Cryptographic hash functions
42
Cryptographic hash functions
Properties of Hash Functions
1. Pre-Image Resistance
43
Cryptographic hash functions…
PROPERTIES…
When two distinct inputs hash to the same output value, we call it a
44
Cryptographic hash functions…
purpose of hashing :
To verify data integrity.
Authentication.
SHA256 often checks the data integrity for hash authentication and
digital signatures.
46
Widely used in Bitcoin blockchain
Certificates and Certificate Authorities (CAs)
CAs play a critical role in how the Internet operates and how
transparent, trusted transactions can take place online.
47
Certificates and Certificate Authorities (CAs)
It ensures that data submitted online can not fall into the hands of
someone who will misuse it.
A MAC requires two inputs: a message and a secret key known only to the
49
originator of the message and its intended recipient(s).
End of chapter 3
50