You are on page 1of 90

Chapter 2

Encryption Techniques
Rola Naja

R.Naja-Chapter2: Encryption Techniques 1


Chapter Objectives
Our goals:
❑ Understand methods to ensure secrecy.

 Get introduced to Codes and Ciphers.

 Review Modular arithmetic in Addition,


Multiplication and Exponentiation.

 Apply these concepts in Encryption/Decryption.

R.Naja-Chapter2: Encryption Techniques 2


Chapter 2: Encryption
Agenda
 Codes and Ciphers
 Encryption using modular arithmetic
 Public Key Cryptography

R.Naja-Chapter2: Encryption Techniques 3


Codes and Ciphers

4
What is Cryptography?

Cryptology

 Cryptology is the science of making


and breaking secret codes. There
are two disciplines:
 Cryptography –This is the development
and use of codes that are used for
communicating privately. Specifically, it
is the practice and study of techniques
to secure communications.
 Cryptanalysis – This is the breaking of
those codes. Specifically, it is the
practice and study of determining and
exploiting weaknesses in cryptographic
techniques.
How to keep a message secret
 Hide the message.
 Use Invisible ink .
 Hide some words or letters.

Example
‘My earnest endeavours to appease the miserable
infant did not immediately gain her trust’

→ meet at midnight

R.Naja-Chapter2: Encryption Techniques 6


Codes
 ‘’’a code is the replacement of symbols, or
groups of symbols, with alternative
symbols, or groups of symbols.”

 To decode a message we need codebook


➢ List of replacement for all possible symbols or group of
symbols.

❑ The use of a code does not, however,


always imply a requirement for secrecy.
R.Naja-Chapter2: Encryption Techniques 7
Cipher
 When the intention is to obscure the original
message “secrecy”
 we use a different type of code: cipher.
 Example: The Cipher wheel

 An encryption method can be carried out


systematically by following a pattern,
 This pattern is known as an algorithm.

 An algorithm includes a variable that can be


altered to produce a different outcome,
 This variable is called a key.

R.Naja-Chapter2: Encryption Techniques 8


Cipher Wheel

R.Naja-Chapter2: Encryption Techniques 9


Keys
 With modern technology, security
of encryption lies in the secrecy
of the keys, not the algorithm.
Two terms that are used to describe
keys are:
 Key length - Also called the
key size, this is measured in
bits. In this course, we will
use the term key length.
 Keyspace - This is the number
of possibilities that can be
generated by a specific key
length.
 As key length increases, the
keyspace increases exponentially.
Encryption using Modular Arithmethic
Modular Addition
Modular Multiplication
Modular Exponentiation

11
Modular Arithmethic
 A modulus of n is the size of the set {0, 1,
2, 3, … , (n-1)}.
 modulus of n or modulo n.

The result of adding 5 and 8 in modulo 7 arithmetic is 6

R.Naja-Chapter2: Encryption Techniques 12


Addition in modular arithmetic
 Two integers a and b are said to be
congruent modulo n if (a mod n) = (b mod n)

 If this is the case then the remainder is


identical when both a and b are divided by
n. We write this as:
a ≡ b mod n

8+5 ≡ 1 mod 4 “ (8+5) is congruent to (1 modulo 4)”

R.Naja-Chapter2: Encryption Techniques 13


Properties of modular addition

Property of closure

The result of any calculation involving modulo n should itself be


a member of the set.

R.Naja-Chapter2: Encryption Techniques 14


Properties of modular addition
Definition of a group

A set and a particular operation are together called a group if


they possess certain properties .

Identity Property
Where there is one element (e) of a group which, when
combined mathematically with any other element (a), returns a,
then the element e is known as the identity of the group.
This can be expressed generally as
a º e ≡ a mod n or e º a ≡ a mod n
where the symbol º denotes any mathematical operation.

R.Naja-Chapter2: Encryption Techniques 15


Properties of modular addition
Additive Inverse Property
For any element (a) in the group, there is another element (ā) in
the group which, when combined by addition, returns a result
equal to the identity of the group.
This can be expressed mathematically as:
a + ā ≡ e or ā + a ≡ e
ā is the additive inverse of a.

Finding solutions using the addition tables for modulus:


a + x ≡ b mod n
where a and b can be any element within the group

R.Naja-Chapter2: Encryption Techniques 16


Properties of modular addition
Associative Property
If, when two or more operations are carried out in modular
arithmetic, the order in which the operations are performed does
not affect the result, this is known as the associative property.
This can be expressed generally as:
(a º b) º c mod n ≡ a º (b º c) mod n
where the symbol º denotes any mathematical operation.

Commutative Property
If, when an operation is carried out in modular arithmetic, the
order in which the integers are placed does not affect the result,
this is known as the commutative property.
This can be expressed generally as:
(a º b) mod n ≡ (b º a) mod n
where the symbol º denotes any mathematical operation.
R.Naja-Chapter2: Encryption Techniques 17
Caesar Code
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

En Encryption table for the Caesar code

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

En Encryption table for the Caesar code highlighting the encrypted letters C, A and T

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
X Y Z A B C D E F G H I J K L M N O P Q R S T U V W

A decryption table for the Caesar code. The letters F, D and W have been picked out

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

A possible numerical coding scheme for the alphabet

R.Naja-Chapter2: Encryption Techniques 18


Caesar Code

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

A possible numerical coding scheme for the alphabet

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 0 1 2

An encryption scheme for numerical codes

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

23 24 25 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

A decryption table for the encryption operation

R.Naja-Chapter2: Encryption Techniques 19


Encryption using modular addition
 The encryption operation can be described by:
c ≡ p + k mod 26, k is the encryption key (ex, k= 3)

 The decryption operation can be described by:


p ≡ c + k mod 26, k is the decryption key (ex, k =23)

R.Naja-Chapter2: Encryption Techniques 20


Caesar Code encryption/decryption

 The decryption key must be chosen so that it


complements the encryption key.

 Schemes where the sender and the receiver know


the encryption key are called symmetric.

 Schemes where the sender knows an encryption


key and the receiver knows the complementary
decryption key are said to be asymmetric.

R.Naja-Chapter2: Encryption Techniques 21


Breaking a code
 An anagram is a form of encryption.
 To solve an anagram
 arrange the letters in the correct order using
some random transposition.
 For a word with n letters it needs n! possible
combinations.

 The method of cracking a code by trying all


possible combinations until the correct is
found is called Brute Force Attack.
R.Naja-Chapter2: Encryption Techniques 22
Digraphs
 In Caesar codes, crackers need the decryption key, or the
encryption key with the initial message.

 An encryption system that had more potential keys would


discourage a cracker from using the brute force approach.

 The Caesar code can be extended


 to encrypt groups of letters.
 A simple extension would be to encrypt pairs of letters, which
are known as digraphs.

 With 26 letters, 262 combinations {AA, AB... ZZ}

R.Naja-Chapter2: Encryption Techniques 23


Multiplication in modular arithmetic

 Compute a × b mod n
 1-Multiply the two integers.
 2-Divide the result by n:
 (a x b) ÷ n = m, remainder d

 3-Express the answer as the remainder (or


residue).

 a × b ≡ d mod n

R.Naja-Chapter2: Encryption Techniques 24


Properties of modular multiplication

Property of closure

The result of modular multiplication should itself be a member


of the set.

R.Naja-Chapter2: Encryption Techniques 25


Properties of modular
multiplication
Identity Property
Where there is one element (e) of a group which, when
combined mathematically with any other element (a), returns a,
then the element e is known as the identity of the group.
This can be expressed generally as
a º e ≡ a mod n or e º a ≡ a mod n
where the symbol º denotes any mathematical operation.

R.Naja-Chapter2: Encryption Techniques 26


Properties of modular
multiplication
Property of Multiplicative Inverse

Does every element in every set have a multiplicative inverse?


For any element of the set, is there another element which,
when combined by multiplication, returns a result equal to the
identity of the set under multiplication?
NO

R.Naja-Chapter2: Encryption Techniques 27


Properties of modular
multiplication
Do any of the elements in the set
produce a single solution when
multiplied by each of the other set
elements?

Using multiplicative inverses find the


solution for x in each of the
following:
x × 3 ≡ 5 mod 10
x × 7 ≡ 9 mod 10
x × 9 ≡ 6 mod 10

R.Naja-Chapter2: Encryption Techniques 28


Properties of modular
multiplication
Associative Property
Modular multiplication is associative.
(a × b) × c ≡ a × (b × c) mod n
(2 × 3) × 4 mod 5 ≡ 24 mod 5 ≡ 4 mod 5
2 × (3 × 4) mod 5 ≡ 24 mod 5 ≡ 4 mod 5

Commutative Property
Modular multiplication is commutative.
a × b mod n ≡ b × a mod n
5 × 7 ≡ 3 mod 8
7 × 5 ≡ 3 mod 8

R.Naja-Chapter2: Encryption Techniques 29


Properties of modular multiplication

 The group has one element, the identity e such that


a × e ≡ a or e× a ≡ a
 The identity e is 1.
 a × 0 ≡ 0 mod n

 Within a group, any element (called a) that is coprime


with the modulus n has a multiplicative inverse (called
a ) such that
a × a ≡ e mod n
 There is no single solution for x to the equation
a × x ≡ b mod n unless a is coprime with the modulus.

R.Naja-Chapter2: Encryption Techniques 30


Properties of modular multiplication

 When the modulus itself is prime,


 it is coprime with all elements of the group.

 x × a × a ≡ x mod n

R.Naja-Chapter2: Encryption Techniques 31


Encryption using modular
multiplication
Encryption of Caesar Code with modulo 26 multiplication:
c ≡ p × K mod 26

An encryption table for the multiplication process with


a key of 15 working modulo 26
CAT ➔ EAZ

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

0 15 4 19 8 23 12 1 16 5 20 9 24 13 2 17 6 21 10 25 14 3 18 7 22 11

A P E T I X M B Q F U J Y N C R G V K Z O D S H W L

R.Naja-Chapter2: Encryption Techniques 32


Decryption using modular
multiplication
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

0 7 14 21 2 9 16 23 4 11 18 25 6 13 20 1 8 15 22 3 10 17 24 5 12 19

A H O V C J Q X E L S Z G N U B I P W D K R Y F M T

An decryption table for the multiplication process assuming encryption was


performed using multiplication modulo 26 and a key of 15
EAZ ➔ “4 0 25” ➔ “2 0 19” ➔ CAT

Decryption of Caesar code with modulo 26 multiplication:


_
p ≡ c × K mod 26

The decryption key is, the number that when multiplied, modulo 26, by the
encryption key gives the answer “1”

R.Naja-Chapter2: Encryption Techniques 33


Special cases
 An encryption key of 1 will leave the plaintext unaltered.
 An encryption key of 0 will produce a ciphered text of
0s.
 Some encryption keys other than 0 and 1 may generate
more than one possible ciphertext.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 21 22 23 24 25
0

0 8 16 24 6 14 22 4 12 20 2 10 18 0 8 16 24 6 14 22 4 12 20 2 10 18

A I Q Y G O W E M U C K S A I Q Y G O W E M U C K S

Example:An encryption table for the multiplication with a key of 8 modulo 26


Encryption: CAT(2 0 19) → QAW (16 0 22)
Decryption: QAW → CAT, PAT, CNT, PNT, CAG, PAG, PNG, PNT
R.Naja-Chapter2: Encryption Techniques 34
EulerTotient Function of n
 The Euler Totient Function of n, ø(n)
 ø(n) = m, means that
• there are m numbers smaller than n which are coprime
with it.
• in the encryption scheme using modulo n
multiplication, there are m keys that will not generate
ambiguous results.

R.Naja-Chapter2: Encryption Techniques 35


Modular Multiplication Encryption

 Choose the modulus of the operation as a


prime number.
 Using modulus other than 26, such as 23 or
29.
 An encryption table for a multiplication
operation modulo 29 using a key of 8:
CAT ➔ “3 1 20” ➔ “24 8 15” ➔ XHO
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z < >

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

0 8 16 24 3 11 19 27 6 14 22 1 9 17 25 4 12 20 28 7 15 23 2 10 18 26 5 13 21

H P X C K S < F N V A I Q Y D L S > G O W B J R Z E M U

R.Naja-Chapter2: Encryption Techniques 36


Modular Multiplication Decryption

 The asymmetric decryption n 8 × n mod 29

key can be found from the 1 1×8 8 mod 29

encryption key and the


2 2×8 16 mod 29

3 (2 + 1) × 8 16 + 8 24 mod 29
modulus. 4 4×8 3 mod 29

 Encryption with a key of 8 5 (4 + 1) × 8 3 + 11 11 mod 29

modulo 29 is the operation: 6 (4 + 2) × 8 3 + 16 19 mod 29


7 (4 + 2 + 1) × 8 3 + 16 + 8 27 mod 29
c ≡ p × 8 mod 29 8 8×8 6 mod 29

p ≡ c × k mod 29 9 (8 + 1) × 8 6+8 14 mod 29


10 (8 + 2) × 8 6 + 16 22 mod 29
p ≡ (p × 8) × k mod 29 11 (8 + 2 + 1) × 8 6 + 16 + 8 1 mod 29

So, 8 × k mod 29 ≡ 1
k = 11
XHO ➔ “24 8 15” ➔ “3 1 20” ➔ CAT

R.Naja-Chapter2: Encryption Techniques 37


Digraphs with Modular
Multiplication
 676 (=26*26) pairs of letters from ‘AA’ to ‘ZZ’ .
 677 is a prime number.
 AA is coded as 1 (instead of 0) and ZZ as 676
(675+1).
 Example:
 Encrypt the letter pair ‘GO’ with the Key K=143.
 GO: (6 × 26 + 14) + 1 = 171
 Attention: A:0, B:1,C:2,D:3,E:4,F:5,G:6
 Encryption:171 × 143 ≡ 24453 mod 677 ≡ 81 mod 677

 81-1 = 3×26+2 → “DC”


R.Naja-Chapter2: Encryption Techniques 38
Digraphs with Modular Multiplication

 Decryption of ‘DC’
 DC:(3*26+2)+1=81
 Decryption key for K=677 is 303.
 Decryption: 81 × 303 ≡ 171 mod 677
 171-1=170=6*26+14
• ‘GO’

R.Naja-Chapter2: Encryption Techniques 39


Exponentiation in Modular
Arithmetic
 Performing exponentiation in modular
arithmetic:
 Calculate ab mod n
ab ≡ c mod n

R.Naja-Chapter2: Encryption Techniques 40


Properties of Modular
exponentiation
 Using these tables,
evaluate:
 64 mod 9
 38 mod 10
 53 mod 7

(n – 1)a mod n ≡ 1 or (n – 1)

R.Naja-Chapter2: Encryption Techniques 41


Encryption using modular exponentiation

Encryption of Caesar Code with modulo 26 exponentiation:


c ≡ pK mod 26

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

A coding table for the alphabet avoiding problematic encodings

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

0 1 24 7 25 24 23 7 20 20 25 16 1 16 23 23 16 1 16 25 20 20 7 23 24 25 7 24 1

W F X W V F S S X O O V V O O X S S F V W X F W

An encryption table for exponentiation process with a key of 8 working modulo 29

R.Naja-Chapter2: Encryption Techniques 42


Conditions to find the decryption
key when using modular
exponentiation
❑Euler-Fermat Theorem (you will see it later):
_
❑ K × K ≡ 1 mod ø(n)

R.Naja-Chapter2: Encryption Techniques 43


Decryption using modular
exponentiation

For a modulus of n=29 and a key of K=11:


_
11 × K ≡ 1 mod ø(29) ≡ 1 mod 28
11 × 23 ≡ 1 mod 28

n 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 27
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6

11 × n mod 28 11 22 5 16 27 10 21 4 1 2 9 2 3 1 2 8 1 2 1 2 7 1 1 1 2 6 17
5 6 0 4 5 9 3 4 8 2 3

R.Naja-Chapter2: Encryption Techniques 44


Public key cryptography
One-way function
Cryptosystem Properties
Euler-Fermat Theorem
Decryption keys

45
Cryptography
 Imagine
 you were a spy master.
 You sent out James Bond into the field.
 You sent him a key with an encryption
algorithm.
 He was arrested and tortured.
 He will give the key and the cipher will be
compromised!!!!!

R.Naja-Chapter2: Encryption Techniques 46


Public Key cryptography
 Diffie and Hellmann
 You can Produce a cipher.
 The encryption method is public knowledge with
a public key cryptosystem.
 How to encrypt does not give you the
information of how to decrypt.

R.Naja-Chapter2: Encryption Techniques 47


Formal description of encryption
and decryption
 Plaintext M
 Encryption with an algorithm e and an
encryption key K:
 C=e(M,K)
 Decryption using an algorithm d and a
decryption key L.
 M=d(C,L)

R.Naja-Chapter2: Encryption Techniques 48


Public key cryptosystem
 The key K, algorithms e and d are public.

 When the spy is arrested


 The spy can give the key K.
 Knowing K would not enable to work out L.

 K is the public key and L is the private key.

R.Naja-Chapter2: Encryption Techniques 49


Cryptosystem Properties
 Property 1:
 Given K and M, it should be EASY to compute
C=e(M,K).
 Property 2:
 Given K and C, it should be
COMPUTATIONALLY NOT FEASIBLE to
compute M.
 Property 3:
 Given the ciphertext C and the key L, it should
be EASY to compute M=d(C,L).

R.Naja-Chapter2: Encryption Techniques 50


ONE-WAY FUNCTION
 One-way function
 Is a function that has the property that is not
computationnally easy to calculate the inverse.
 It is no good having L if the algorithm d takes
too much time.
 If we have L, then calculation of the inverse is
easy
• TRAPDOOR

R.Naja-Chapter2: Encryption Techniques 51


Modular Addition for
encryption/decryption?
 Give the key and the encryption function.
 Encryption function: c ≡ p + k mod N.
 Anyone can deduce the decryption function
 p ≡ c - k mod N
 Modular Addition is NOT a one-way
function.

R.Naja-Chapter2: Encryption Techniques 52


Modular Multiplication for
encryption/decryption?
 Give the key and the encryption function.
 Encryption function: c ≡ p. k mod N.
 K and N coprime

 Anyone can deduce the decryption function


 p ≡ c.K mod N
 K is the multiplicative inverse of k modulo N

 Modular Multiplication is NOT a one-way


function.

R.Naja-Chapter2: Encryption Techniques 53


Modular Exponentiation??
 N=11, c ≡ p2mod 11.
 Complete the table below.
 Conclusion!!!

p 0 1 2 3 4 5 6 7 8 9 10
p2 0 1

R.Naja-Chapter2: Encryption Techniques 54


Modular Exponentiation??
 N=11, c ≡ p3mod 11.
 Complete the table below.
 Conclusion!!!

p 0 1 2 3 4 5 6 7 8 9 10
p3 0 1

R.Naja-Chapter2: Encryption Techniques 55


Modular Exponentiation??
 Encryption: c ≡ pKmod N. Exponentiation Table modulo 11
1

 Decryption: p ≡ cKmod N 0 1 2 3 4 5 6 7 8 9 0

 Previous example K=3, N=11


0 #### 0 0 0 0 0 0 0 0 0 0

 Possible value of d??? 1 1 1 1 1 1 1 1 1 1 1 1

• K=7 2 1 2 4 8 5 9 9 7 3 6 1

3 1 3 9 5 4 3 3 9 5 4 1

4 1 4 5 9 3 4 4 5 9 3 1

5 1 5 3 4 9 5 5 3 4 9 1

6 1 6 3 7 9 5 5 8 4 2 1

7 1 7 5 2 3 4 4 6 9 8 1

8 1 8 9 6 4 3 3 2 5 7 1

9 1 9 4 3 5 9 9 4 3 5 1

10 1 10 1 10 1 1 1 10 1 10 1

R.Naja-Chapter2: Encryption Techniques 56


Fermat’s Little Theorem
 N is prime
 0<a<N is a residue number
 Then
 aN-1 ≡ 1 mod N

R.Naja-Chapter2: Encryption Techniques 57


Euler-Fermat Theorem
 Two prime numbers a, b
 N=a.b
 N2=(a-1)(b-1)
 If t is any residue number mod N which has
no common factors with N then
 tN2 ≡ 1 mod N

R.Naja-Chapter2: Encryption Techniques 58


Euler-Fermat Corollary
 Assumptions:
 Two prime numbers a, b
 N=a.b ,N2=(a-1)(b-1)
• ø(a)=a-1, ø(b)=b-1
• ø(N)=(a-1).(b-1)
 f(x) ≡ xe mod N
 d is a multiplicative inverse of e mod N2.

 Corollary: If e is prime to N2 then f(x) has


an inverse function g(x) ≡ xd mod N
 e.d ≡ 1 mod ø(N) ≡ 1 mod N2

R.Naja-Chapter2: Encryption Techniques 59


Euler-Fermat Corollary proof
 d.e ≡1 mod(N2)
 d.e=1+mN2

 g(f(t)) ≡ (te)d ≡ted≡t1+mN2≡t. tmN2


 Since tN2≡1 mod N(Euler-Fermat
Theorem)
 g(f(t)) ≡t.(1)m ≡ t

R.Naja-Chapter2: Encryption Techniques 60


Euler-Fermat Example
 a=3,b=5, encryption power e=3
 N=15, N2=2*4=8
 e.d ≡1 mod 8
• d=3

R.Naja-Chapter2: Encryption Techniques 61


Decryption keys (1/4)
 Is there a method other than searching
systematically through possibilities to find
the decryption keys?

 The Euler-Fermat Theorem:


 tø(n)
≡ 1 mod n where t and n are coprime
 Two cases: n is prime or not

R.Naja-Chapter2: Encryption Techniques 62


Decryption keys (2/4)
 When n is prime
 ø(n) = n – 1
 Kn – 1 ≡ 1 mod n
K_ × K n – 2 ≡ 1 mod n

 K ≡ Kn – 2 mod n

 In encryption with modular multiplication, a


modulus of 29 and a key of 8, the decryption
key_should be:
 K ≡ 827 ≡ 11mod 29
R.Naja-Chapter2: Encryption Techniques 63
Decryption keys(3/4)
 When n isn’t a prime e.g. n = 30 & K = 13
 Kø(n) ≡ 1 mod n
 n = 30 = 2 × 3 × 5 ➔ {1, 7, 11, 13, 17, 19, 23, 29}
 ø(n) = 8
 K_× K7 ≡ 1 mod 30
 K ≡ K7 ≡ 137 ≡ 7 mod 30

R.Naja-Chapter2: Encryption Techniques 64


Decryption keys(4/4)

The Euler Totient Function is the core of the


technique to find the decryption keys.
The general formula for such a function is:
ø(n) = n(1-1/p1)(1-1/p2)...(1-1/pn)
where p1, p2, p3,..., pn are prime factors of n

R.Naja-Chapter2: Encryption Techniques 65


 Cryptography Algorithms
 Symmetric vs Assymetric
 RSA algorithm
 PGP

R.Naja-Chapter2: Encryption Techniques 66


Symmetric versus Assymetric Algorithms
Symmetric vs Assymetric
RSA algorithm
PGP

67
Cryptography
 Cryptogtaphy:
 Algorithm for encryption involving modular
arithmetic and using a pair of keys:
• Symmetric or Asymmetric

R.Naja-Chapter2: Encryption Techniques 68


Confidentiality

Encryption
These two classes differ in how they use keys:

 Symmetric encryption algorithms - Encryption algorithms use the same key


to encrypt and decrypt data. They are based on the premise that each
communicating party knows the pre-shared key.

 Asymmetric encryption algorithms - Encryption algorithms use different


keys to encrypt and decrypt data. They are based on the assumption that the
two communicating parties have not previously shared a secret and must
establish a secure method to do so. Asymmetric algorithms are resource
intensive and slower to execute.
Asymmetric vs Symmetric keys

Advantage Disadvantage

avoid the need to Overhead due to


distribute keys in encryption greater than
Asymmetric
secret symmetric systems

Less overheads than No public keys ➔ need


Symmetric asymmetric systems to keep all keys secrets

R.Naja-Chapter2: Encryption Techniques 70


Confidentiality

Symmetric Encryption
 Symmetric algorithms use the same pre-shared key to encrypt and decrypt data.

 Today, symmetric encryption algorithms are commonly used with VPN traffic. This is
because symmetric algorithms use less CPU than asymmetric encryption algorithms.

 When using symmetric encryption algorithms, like any other type of encryption, the
longer the key, the longer it will take for someone to discover the key.

 Most encryption keys are between 112 and 256 bits. Use a longer key for more secure
communications.
Confidentiality

Symmetric Encryption Algorithms


Encryption algorithms are
often classified as either:
 Block ciphers - Block
ciphers transform a
fixed-length block of
plaintext into a common
block of ciphertext of
64 or 128 bits.
 Stream Ciphers -
Stream ciphers encrypt
plaintext one byte or
one bit at a time.

Well-known symmetric encryption algorithms include: Data Encryption Standard


(DES), 3DES (Triple DES), Advanced Encryption Standard, (AES) Software-
Optimized Encryption Algorithm (SEAL), Rivest ciphers (RC)
Confidentiality

Asymmetric Encryption Algorithms


 Asymmetric algorithms, also called public-key algorithms, are designed so that the key
that is used for encryption is different from the key that is used for decryption.

 The decryption key cannot, in any reasonable amount of time, be calculated from the
encryption key and vice versa.

 Asymmetric algorithms use a public key and a private key.


 Both keys are capable of the encryption process, but the complementary paired
key is required for decryption.
 The process is also reversible in that data encrypted with the public key requires the
private key to decrypt.
 This process enables asymmetric algorithms to achieve confidentiality, authentication,
and integrity.
Confidentiality

Asymmetric Encryption – Confidentiality


 Asymmetric algorithms are used to
provide confidentiality without pre-
sharing a password.

 The confidentiality objective of


asymmetric algorithms is initiated
when the encryption process is
started with the public key.

The process can be summarized using


the formula: Public Key (Encrypt) +
Private Key (Decrypt) = Confidentiality
 When the public key is used to
encrypt the data, the private key
must be used to decrypt the
data.
 Only one host has the private
key.
Assymmetric Encryption
Credit card number
With
Without ?????
1234-555555-54

security

? ?

Intruder: Eve

Bob Alice
R.Naja-Chapter2: Encryption
75 Techniques 75
 RSA System

R.Naja-Chapter2: Encryption Techniques 76


Rivest-Shamir-Adelman (RSA)
system
 RSA System Security:
 No fast way of factoring numbers that are the
product of two LARGE primes.

R.Naja-Chapter2: Encryption Techniques 77


RSA keys

 Main concern:
 How can I choose a pair of complementary
encryption and decryption keys so that knowledge
of one does not help me find the other?
Centerpiece:
 Themultiplication of two very large prime numbers,
and using the result as the modulus of the
encryption calculations.
Objectives:
 choosean encryption key and calculate the
decryption key according to certain conditions.
R.Naja-Chapter2: Encryption Techniques 78
RSA Algorithm
 RSA
 Encryption: modular exponentiation
 Encryption and decryption keys derived from
secret data.
• using a difficult but tractable process.

 If the encryption key is made public,


• it is infeasible with a suitable large key and present-day
computing resources
– to work out the decryption keys and decrypt the messages.

R.Naja-Chapter2: Encryption Techniques 79


RSA Algorithm
 Encryption with modular exponentiation
 modulus n,
• not prime
• the product of two primes a and b
• n=a×b & c ≡ pK mod ab
_
 The decryption
_ key K is calculated:
 K × K ≡ 1 mod ø(n)

R.Naja-Chapter2: Encryption Techniques 80


RSA Procedure (1/2)
 1-Select two LARGE prime numbers, a and b.
 2-Set the modulus N to be the product of a
and b, N = ab
 3-Calculate ø(N)
 a and b are prime ➔ø(N)
_ = (a - 1) × (b_- 1)
 How to select K and K such that K.K ≡ 1 mod
ø(n) ???? Follow following steps
 4-Find the highest common factor of (a - 1)
and (b - 1).
 5-Divide ø(N) by this factor and set m equal to
the result.
R.Naja-Chapter2: Encryption Techniques 81
RSA Procedure(2/2)
 6-Select an encryption key K such that K is
less _than and coprime with m.
 K.K ≡ 1 mod m

 7-Factorize m, then calculate ø(m) .

_
 8- Compute
_ the decryption key K from
 K ≡ Kø(m)-1 mod m

_
 9-Check that K × K ≡ 1 mod m

R.Naja-Chapter2: Encryption Techniques 82


RSA Example(1/3)
 a = 7 & b = 11
 a-1= 6 = 3x2 & b-1 = 10 = 5x2
 m = (a-1)(b-1)/2
_ = 30
 K × K ≡ 1 mod 30

Possible values of K should be coprime with m


 7, 11, 13, 17, 19, 23 or 29

Let’s choose 13 : K = 13

R.Naja-Chapter2: Encryption Techniques 83


RSA Example (2/3)
To encrypt the letter S that is encoded as 20
 2013 ≡ 208+4+1 mod 77
 202 ≡ 15 mod 77; 204 ≡ (202)2 ≡ 152 ≡ 71 mod 77;
 208 ≡ (204)2 ≡ 712 ≡ 36 mod 77;
 2013 ≡ 36x71x20 ≡ 15x20 ≡ 69 mod 77

R.Naja-Chapter2: Encryption Techniques 84


RSA Example(3/3)
_
13 × K ≡ 1 mod 30
 n = 30 = 2 × 3 × 5 ➔ {1, 7, 11, 13, 17, 19, 23, 29}
 ø(n)
_ =8
 K=137=7 mod 30

Decrypt the ciphertext 69:


 697 ≡ 694+2+1 mod 77
 692 ≡ 64 mod 77; 694 ≡ (692)2 ≡ 642 ≡ 15 mod 77;
 697 ≡ 15x64x69 ≡ 36x69 ≡ 20 mod 77

R.Naja-Chapter2: Encryption Techniques 85


 PGP

R.Naja-Chapter2: Encryption Techniques 86


Pretty Good Privacy (PGP)
 PGP was developed by Philip Zimmerman.
 PGP is a hybrid cryptosystems.
 PGP combines the security of the public key
systems with the speed of the conventional
systems.
 PGP combines the use of symmetric and
asymmetric algorithms.
 PGP is a freeware.

R.Naja-Chapter2: Encryption Techniques 87


PGP: Encryption process
 Compression process:
 reduce the size and obscure the plaintext
message.
 Build a temporary key.
 Encrypt the compressed plaintext message by
the temporary key.
 Encrypt the temporary key with the
recipient’s PGP public key.
 Transmit the Encrypted message and
encrypted temporary key to the recipient.
R.Naja-Chapter2: Encryption Techniques 88
PGP: Decryption process
 Decrypt the temporary key with recipient’s
PGP private key.
 Decrypt the compressed message with the
temporary key.
 Decompress the message.
 Discard the temporary key.

R.Naja-Chapter2: Encryption Techniques 89


 References:
 Handbook of Applied Cryptography
 Lecture notes-Nick Korevaar
 T209-Open University
 Sécurité des systèmes d’information et des
réseaux-R.Panko-Pearson Education

R.Naja-Chapter2: Encryption Techniques 90

You might also like