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

Lecture 4 and 5.ppt

The lecture focuses on the application of matrices in cryptography, including operations, determinants, and multiplicative inverses. It also covers solving linear congruence equations and introduces classical symmetric-key ciphers, explaining their mechanisms and categories such as substitution and transposition ciphers. Additionally, it discusses specific types of ciphers like additive, multiplicative, and affine ciphers, along with their cryptanalysis methods.

Uploaded by

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

Lecture 4 and 5.ppt

The lecture focuses on the application of matrices in cryptography, including operations, determinants, and multiplicative inverses. It also covers solving linear congruence equations and introduces classical symmetric-key ciphers, explaining their mechanisms and categories such as substitution and transposition ciphers. Additionally, it discusses specific types of ciphers like additive, multiplicative, and affine ciphers, along with their cryptanalysis methods.

Uploaded by

Shahzaib Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

Cryptography

&
Network Security

Lecture#4

Dr. Muhammad Faheem Mushtaq


Objectives of the Lectures

 Review and understanding of matrices


and their use in cryptography

 Solving LINEAR CONGRUENCE equations

 Understanding traditional symmetric-key cipher

2.2
MATRICES

In cryptography we need to handle matrices. So we


briefly review of matrices for the study of cryptography.

Topics discussed in this section:


1 Definitions
2 Operations and Relations
3 Déterminants
4 Multiplicative Inverse
5 Résidu Matrices
1 Definition
A matrix of size l ´ m

Examples of matrices

2.4
2 Operations and Relations
Ex1: Addition and subtraction of matrices

Ex2: Scalar multiplication

2.5
2 Operations and Relations….cont’d
Ex3:Multiplication of a row matrix (1 × 3) by a column matrix (3 × 1)
The result is a matrix of size 1 × 1.

Ex4: Multiplication of a 2 × 3 matrix by a 3 × 4 matrix.


The result is a 2 × 4 matrix.

2.6
3 Determinant
The determinant of a square matrix A of size m × m
denoted as det (A) is a scalar calculated recursively
as shown below:

The determinant is defined only for a


square matrix. 2.7
Examples: Determinant of a matrix
Ex1: we can calculate the determinant of a 2 × 2 matrix
based on the determinant of a 1 × 1 matrix.

Ex2: calculation of the determinant of a 3 × 3 matrix.

2.8
4 Multiplicative Inverse of a Matrix

The multiplicative inverse of a square matrix A of


size m × m denoted as A-1 is a matrix of size m x m
such that
A x A-1= I

The A-1 can be found as follows


A-1= 1/det(A) x adj(A) = (det(A) )-1 x adj (A)

2.9
5 Residue Matrices

 Cryptography uses residue matrices: matrices where


all elements are in Zn.

 All matrix operations on residue matrix are same as


in integer matrices, but using modular arithmetic

A residue matrix (A) in Zn has multiplicative Inverse,


if the determinant of A has mult Inv in Zn.

It means A has a multiplicative inverse


if gcd (det(A), n) = 1.
 Example: A residue matrix A in Z26 has det(A)= 21, as gcd (21, 26)=1,
multiplicative Inverse of det(A) = 5 in Z26, so we can find
2.10
matrix A-1 such
that A x A-1 = I
5 Multiplicative Inverse of a Residue Matrix

2.11
LINEAR CONGRUENCE

 Cryptography often involves solving an


equation or a set of equations of one or more
variables with coefficient in Zn.

 This section shows how to solve equations


when the power of each variable is 1 (linear
equation).
Topics discussed in this section:
1 Single-variable Linear Equations
2 Set of Multi-variable Linear Equations
2.12
1. Single-Variable Linear Equations
Equations of the form ax ≡ b (mod n ) might have no
solution or a limited number of solutions.

 How we can find d solutions


 Reduce the equation by dividing both sides
of the equation (including the modulus) by d.
 Multiply both sides of the reduced equation by
multiplicative inverse of a to find the particular solution x0
 The general solution are x=x0 + k(n/d) where k=0,1,2,…,d-1

Ex1: Solve the equation 10 x ≡ 2(mod 15).


First find gcd (10 , 15) = 5
Since 5 does not divide 2, so no solution exists for 2.13

this equation.
Examples: Single-Variable Linear Equations
Ex2: Solve the equation 14 x ≡ 12 (mod 18).

Ex3: Solve the equation 3x + 4 ≡ 6 (mod 13).


First we change the equation to the form ax ≡ b (mod n).
We add −4 (the additive inverse of 4) to both sides,
which gives 3x ≡ 2 (mod 13).
Because gcd (3, 13) = 1, equation has only one solution,
which is x0 = (2 × 3−1) mod 13 = 18 mod 13 = 5.
We can see that the answer satisfies the original
2.14

equation: 3 × 5 + 4 ≡ 6 (mod 13).


2. Set of Multi-variable Linear Equations
We can also solve a set of linear equations with the
same modulus if the matrix formed from the
coefficients of the variables is invertible.

2.15
Example: Set of Linear Equations (Single-Variable)
Ex: Solve the set of following three equations:

Solution
The result is x ≡ 15 (mod 16),
y ≡ 4 (mod 16), &
z ≡ 14 (mod 16).
We can check the answer by inserting these
values into the equations. 2.16
Assignment 01

Quiz 01

Semester Project

2.17
Classical Symmetric Key Ciphers
Classical Symmetric Key Ciphers

 Examine traditional encryption/decryption


techniques

 enables us to understand
 The basic approaches to symmetric
encryption
 Their benefits and weakness

2.19
General idea: symmetric-key cipher

 Plain Text (PT) : The original message from Alice to


Bob.
 Cipher Text (CT): Message that is sent through the
channel.
 Encryption Algo.: An algorithm used to create CT from
PT
 Decryption Algo: An Algorithm used to create the PT
General idea: symmetric-key
 Encryption and Decryption algorithms are inverses of
cipher
each others: They cancels out the effect of each
other if they are applied to one after the other on the
same input
 If P is the plaintext, C is the cipher text, and K is the
key,

We assume that Bob creates P1; we prove that


P1 = P:

3.21
Kerckhoff’s principle
 The adversary, Eve, knows the
encryption/decryption algorithm.
 The resistance of the cipher to attack must be
based only on the secrecy of the key:
 Guessing the key should be so difficult that
there is no need to hide
encryption/decryption algorithms
Categories of Classical Symmetric Key
Ciphers
Substitution Ciphers
A substitution cipher replaces one symbol with
another.
e.g. we can replace letters A,I,M,N,R in the
plaintext with D,P,Q,L,S ,respectively to create
the cipher text
 Transposition Ciphers
A Transposition Cipher does not replaces one
symbol with another, instead changes the location
of symbols.
Substitution Ciphers

 Substitution
Ciphers can be
categories as either
monoalphabetic Ciphers
Polyalphabetic Ciphers
Monoalphabetic Ciphers
 In these Ciphers, a character or symbol is always
replaced to the same character in the cipher text
regardless of its position.
 E.g. if an algorithm says that the letter A in the plain Text is replaced with letter D
then every letter A is changed to Letter D.

 The relationship between a symbol in the plaintext to


a symbol in the cipher text is always one-to-one.
Monoalphabetic
Ciphers: Examples
 Additive Cipher
 Multiplicative Cipher
 Affine Cipher
Additive Cipher
 The encryption Algorithm add the key to the each character of the
plain text.
 The decryption Algorithm subtract the key from each character of
the cipher text.
 To perform mathematical operation,
 each letter is assigned an integer in Z26, as shown
 The secret Key is also an integer in Z26.
 We assume that the PT consists of lowercase letter and the CT
consists of upper case letters.
Additive Cipher
Examples:cipher
Use the additive additive with
cipherkey = 15 to encrypt the
message “hello”.
We apply the encryption algorithm to the plaintext,
character by character:

Use the additive cipher with key = 15 to decrypt the


message “WTAAD”.
We apply the decryption algorithm to the cipher text
character by character:

3.29
Additive Cipher: Cryptanalysis

 Any vulnerability of additive cipher ?????


 Hint: number of keys
Additive Cipher: Cryptanalysis
 Ciphertext-only attack using exhaustive key searches.

Example: Eve has intercepted the cipher text


“UVACLYFZLJBYL”. Show how she can use a brute-force
attack to break the cipher.

Solution
Eve tries keys from 1 to 7. With a key of 7, the plaintext
is “not very secure”, which makes sense.
Additive Cipher:
Cryptanalysis
 Ciphertext-only attack using statistical
attack. Frequency of characters in English

Frequency of diagrams and trigrams

3.32
Example: Eve has intercepted the following ciphertext.
Using a statistical attack, find the plaintext.

Solution
When Eve tabulates the frequency of letters in this
ciphertext, she gets: I =14, V =13, S =12, and so on.
The most common character is I with 14 occurrences.
This means key = 4.

3.33
Multiplicative Ciphers

In a multiplicative cipher, the plaintext and


ciphertext are integers in Z26; the key is an
3.34

integer in Z26*.
3.2.1 Continued

Example 3.7
What is the key domain for any multiplicative cipher?
Solution
The key needs to be in Z26*. This set has only 12
members: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25.
Example 3.8
We use a multiplicative cipher to encrypt the message
“hello” with a key of 7. The ciphertext is “XCZZU”.

3.35
Affine Ciphers

The affine cipher uses a pair of keys in which the first


key is from Z26* and the second is from Z26. The size of
the key domain is:-
3.36

26 × 12 = 312.
Example: Affine cipher
Use an affine cipher to encrypt the message “hello”
with the key pair (7, 2).

Use the affine cipher to decrypt the message “ZEBBW”


with the key pair (7, 2) in modulus 26.

The additive cipher is a special case of an affine cipher


in which
3.37
k1 = 1. The multiplicative cipher is a special case of
Cryptanalysis of Affine cipher

 C= ((P x k1) + k2) mod 26


 P= ((C – k2) x k1-1) mod 26
 - k2 is AI & k1-1 is MI
 k1 is from Z , k2 is from Z26
26*

 Size of key domain is 26 x 12


 brute force &
 chosen plain text attack
C = P K  K = P-1C

You might also like