Chapter 3 Cryptographyyy
Chapter 3 Cryptographyyy
Chapter 3 Cryptographyyy
Cryptography
1
Cryptography
is a study 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 …
3. Hash functions: are irreversible, one-way functions that protect the data, at
the cost of not being able to recover the original message
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 half ( L) and the right half (R )
28
Data Encryption Standards(DES)
30
Advanced Encryption Standard(AES)
The strength of AES lies on key length and the complexity of its
substitution and permutation operations
AES supports key sizes of 128, 192, or 256 bits, which makes it
much more secure than DES, which only supports a 56-bit key size
31
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.
32
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 ≤ . 33
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.
35
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}
36
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}
37
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
38
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. 39
Key management and exchange in cryptography
The processes of generating, distributing, and managing cryptographic keys
1. Symmetric-key cryptography: the same key is used for both encryption and
communicating parties.
private key for decryption. The public key is distributed widely, while the private
40
key is kept secret.
Key management and exchange in cryptography…
3. Key exchange protocols: protocols enable two parties to exchange keys
securely over an insecure network.
The shared secret key is then calculated by each party using their own
private key and the other party's public key.
41
Key management and exchange in cryptography…
In RSA key exchange protocol: each party generates a public-private key pair
1. Party A generates a random secret number called a session key and encrypts it
using Party B's public key. Party A then sends the encrypted message to Party B.
2. Party B receives the encrypted message from Party A and decrypts it using its
own private key, obtaining the session key.
3. Party B generates a random secret number and encrypts it using Party A's
public key. Party B then sends the encrypted message to Party A.
4. Party A receives the encrypted message from Party B and decrypts it using its
own private key, obtaining the session key.
The security of RSA key exchange relies on the difficulty of factoring large
numbers into two prime factors.
42
Key management and exchange in cryptography…
4. Key management systems: are used to manage the lifecycle of cryptographic
keys, including key generation, exchange, storage, use, crypto-shredding
(destruction) and replacement of keys
Helps to reduce risk of data breaches, unauthorized access, and other security
threats.
If the original data changes in any way, even by a single bit, the
hash value will be completely different.
44
Cryptographic hash functions
how it works
By comparing the hash value of original data with hash value of the
received or stored data, one can easily determine whether the data
has been tampered with or corrupted.
45
Cryptographic hash functions
46
Cryptographic hash functions
Properties of Hash Functions
m H(m) h
47
Cryptographic hash functions…
PROPERTIES…
48
Cryptographic hash functions…
PROPERTIES…
Authentication.
1. MD5 (Message Digest 5): a widely-used hash algorithm produces a 128-bit hash
value.
These algorithms produce hash values of different lengths, ranging from 224 bits
to 512 bits.
They are widely-used for digital signatures, password storage, and other
cryptographic applications.
4. SHA-3 (Secure Hash Algorithm 3): is a recent addition to the SHA family of hash
algorithms.
Certificate Authorities (CAs) are trusted third-party entities that issue and
manage digital certificates.
SSL is now deprecated and has been replaced by Transport Layer Security
(TLS), but the terms SSL and TLS are often used interchangeably.
SSL/TLS is used to encrypt data sent between a client (web browser) and a
server (web server) to ensure that the data cannot be intercepted or
tampered with by third parties.
54
Certificates and Certificate Authorities (CAs)
How SSL/TLS works
1. Handshake: establishing a secure connection b/n client and server, exchange information
about the SSL/TLS version and cipher suites they support, session ID etc.
The client and server also exchange public keys and digital certificates to establish trust.
2. Key Exchange: after handshake, client and server use the exchanged public keys to establish
The key exchange can use either symmetric or asymmetric encryption, depending on the
3. Data Transfer: Once shared secret key is established, client and server can encrypt and
4. Session Termination: client and server terminate the SSL/TLS connection and shared secret
56