You are on page 1of 48

T215B

Communication and
information technologies (II)

Arab Open University - Spring 2021


Session 3
Block 4
Protecting and prying
1
Session Outline
• Part 5: Encryption
• Introduction
• Encryption: basic concepts

Arab Open University - Spring 2021


• Breaking a cipher

2
1. Introduction [1]
How do we protect data?
• High-profile security breaches could be prevented by
implementing appropriate protection measures.
• ENCRYPTION is one of these protection measures

Arab Open University - Spring 2021


• Encryption is a method of altering data in a systematic way such
that it can be restored to its original form by those ‘in the know’.
• In this part of the block you will learn:
• What data encryption is.
• How to use encryption to prevent unauthorized people from
having access to private information?
• i.e. How to use Encryption to Protect from Prying!
3
1. Introduction [2]
• Some encryption techniques have been around for
hundreds, even thousands, of years ➔ the Caesar
cipher
• Today, computers are available!

Arab Open University - Spring 2021


• Computers can do the hard work of trying to break a code and, of
course, they can do it much more quickly than a human can!
• The encryption techniques employed have had to become far
more complex and sophisticated.

4
1. Introduction [3]
• Encryption is the fundamental building block of
all modern security systems.
• Encryption provides mechanisms for:
• confidentiality – keeping things secret

Arab Open University - Spring 2021


• authentication – ensuring that the identities of people
and things are correct
• integrity – ensuring that data has not been tampered
with
• This part of the block is designed to give an
insight into encryption methods. 5
Session Outline
• Part 5: Encryption
• Introduction
• Encryption

Arab Open University - Spring 2021


• Basic concepts
• A simple substitution cipher
• Mathematical Representation: The Caesar Cipher
• Decrypting the Caesar Cipher
• A Simple Transposition Cipher
• Breaking a cipher 6
2. Encryption: basic concepts [1/6]
• Encryption is a process by which information is changed in
some systematic way so as to hide its content from everyone
except its intended recipient.
• Cryptology: The branch of science concerned with the
concealment of information, a word that has its roots in Greek

Arab Open University - Spring 2021


from kryptos (hidden) and logos (word).
• Cryptography: the science of creating codes and ciphers.
• Cryptanalysis: the science of breaking them.

• In Cryptography ‘codes’ and ‘ciphers’ have different meanings.

What is the difference between a code and a cipher? 7


2. Encryption: basic concepts [2/6]
• Codes:
• A code replaces whole words, phrases or groups of symbols with
alternatives (or code words).
• The purpose of creating a code is not always for secrecy.
• A code is used simply as an abbreviation

Arab Open University - Spring 2021


• A code is used to provide an alternative way of communicating
information.
• A code is the output of an encoding process (the reverse is
decoding) and generally relies on sets of look-up tables
(codebooks) for the conversion processes

8
2. Encryption: basic concepts [3/6]
• Examples:
• ASCII: American ASCII table
Standard Code for
Information Interchange
• Used to replace
characters (a-z; A-Z; 0-9;

Arab Open University - Spring 2021


some punctuation
symbole, etc.) with
binary codes (initially 7
bits).
Morse codes
• Morse code:
• A standard for substituting groups of long and
short pulses (or groups of dots and dashes) for
letters.
• It has been used extensively in telegraphy
9
because of its resistance to corruption and
efficiency.
2. Encryption: basic concepts [4/6]
• Ciphers:
• A cipher is the output of an encryption process that either
replaces data symbols with alternative symbols, or rearranges
existing symbols.
• The operation used to create a cipher is systematic (i.e.

Arab Open University - Spring 2021


follows some set rules).
• A cipher is almost always created for reasons of secrecy.

How do we create a cipher?


10
2. Encryption: basic concepts [5/6]
• Encryption is the process of transforming data known as plaintext
into a cipher known as ciphertext.
• Decryption reverses the process by transforming ciphertext back
into plaintext.

Arab Open University - Spring 2021


• There are two basic types of ciphers:
• Substitution Cipher
• Transposition Cipher

What is the difference between a substitution 11


an transposition cipher?
2. Encryption: basic concepts [6/6]
• Substitution cipher: The encryption process systematically
manipulate a symbol (or a group of symbols) in the plaintext
to produce a different symbol (or group of symbols), which
becomes the ciphertext.
• The substituted symbols in the ciphertext appear in exactly the same

Arab Open University - Spring 2021


order as the original versions in the plaintext.

• Transposition cipher: The encryption process ‘scrambles’ the


order of the symbols of the plaintext in some systematic way.
• Using this approach, the symbols remain unchanged between
plaintext and ciphertext, but the ordering of those symbols changes.

12
Session Outline
• Part 5: Encryption
• Introduction
• Encryption

Arab Open University - Spring 2021


• Basic concepts
• A simple substitution cipher
• Mathematical Representation: The Caesar Cipher
• Decrypting the Caesar Cipher
• A Simple Transposition Cipher
• Breaking a cipher 13
2.1 A simple substitution cipher:
The Caesar cipher [1/4]
• Caesar cipher is one of the earliest recorded and best known
ciphers was used by Julius Caesar in the 1st century BC.
• Caesar cipher is one of the simplest of substitution ciphers.

Arab Open University - Spring 2021


• How did Caesar preserve the confidentiality of his message?
• He substituted each letter in his message with the letter three
places further forward in the alphabet.
• Thus the letter ‘a’ would be substituted by the letter ‘d’, the letter
‘b’ by the letter ‘e’, and so on.

• The process used by Caesar is an example of a systematic


14
manipulation!
2.1 A simple substitution cipher:
The Caesar cipher [2/4]
• Example: using this method, the word ‘acme’ becomes
DFPH.

But what if we wanted to encrypt the word ‘zenith’ using


the Caesar cipher? How ‘z’ is encrypted?

Arab Open University - Spring 2021


• The solution is to jump back to the letter ‘a’ and
continue the count as if the letters of the alphabet were
arranged in a circle
• Example: the word ‘zenith’ becomes CHQLWK.
• Study note: Always represent the plaintext in lower case
and ciphertext in UPPER CASE. 15
2.1 A simple substitution cipher:
The Caesar cipher [3/4]
• The circular nature of the Caesar cipher can be exploited
to produce a simple encryption tool known as a cipher
wheel.
• The wheel is made up of two
discs

Arab Open University - Spring 2021


• The alphabet is written around
the circumference of both discs
• Discs are fitted together at their
centers
• The sender and recipient first
agree on the number of shifts
• One wheel is then rotated using
the pre-agreed number of shifts.
• Each letter of the outer wheel is 16
consiquently aligned with any
letter on the inner wheel
2.1 A simple substitution cipher:
The Caesar cipher [4/4]
• A key element in Caesar Cipher is “the number of shifts”
• Changing the “number of shifts” produces different ciphertext
from a given plaintext
• Example: Caesar’s successor, Augustus Caesar, changed the shift
from 3 to 2.

Arab Open University - Spring 2021


• Any shift of 1 to 25 would work equally and produces different
ciphertext from a given plaintext.

• In any encryption process, when altering a “variable” produces


different outcome (ciphertext) this “variable” is called a Key
• So here we can say that Julius
Caesar used an encryption key of 3
and Augustus Caesar an encryption
key of 2. 17
Session Outline
• Part 5: Encryption
• Introduction
• Encryption

Arab Open University - Spring 2021


• Basic concepts
• A simple substitution cipher
• Mathematical Representation: The Caesar Cipher
• Decrypting the Caesar Cipher
• A Simple Transposition Cipher
• Breaking a cipher 18
2.2 Mathematical representation [1/9]
• Modern communication systems use computers to process
messages.
• Computers do not work with letters but with numbers!
How the Caesar cipher can be represented

Arab Open University - Spring 2021


as a numerical algorithm that can be
processed by a computer?

19
2.2 Mathematical representation [2/9]
• Caesar Cipher can be mathematically represented by using
“Modular arithmetic”
• Modular arithmetic operates with a limited set of integers
• Integer: positive or negative whole number, including zero.

Arab Open University - Spring 2021


• Example of a set of integers: S = {0, 1, 2, 3, 4, 5}.

• In Modular arithmetic:
• The modulus is the number of integers in the set.
• In the previous example, the modulus is 6.
• Whatever mathematical operation we perform on the integers in
the set, the result must always be less than the modulus.
20
2.2 Mathematical representation [3/9]
• Modular Addition:
• Let’s assume we want to move forward eight hours from ten o’clock
using the 12-hour clock, how can we implement this?
• Mathematically this can be represented as:
10 + 8 modulus 12 is congruent to 6 modulus 12.

Arab Open University - Spring 2021


• Firstly, we add the two left-hand integers together in the
conventional way:
10 + 8 = 18
• Secondly, if the result is equal to or greater than the modulus
• subtract the modulus from the result
• repeating the subtraction until the result is less than the modulus
18 − 12 = 6
• Finally, Now express the answer as a congruence modulus 12:
21
10 + 8 ≡ 6 mod 12
2.2 Mathematical representation [5/9]
How to apply the same method to implement the
Caesar Cipher encryption algorithm?
• Modular arithmetic deals with integers, so:
• At first, alphabet is converted to numbers.

Arab Open University - Spring 2021


• The following coding table can be used for this purpose:

Why we have chosen to set ‘a’ to 0 rather than to 1?


• Because the result of any calculation in modular arithmetic must
always be less than the modulus (i.e. 26).
• if we had set ‘a’ to 1 and therefore ‘z’ to 26, 26 would be an invalid
result. 22
2.2 Mathematical representation [6/9]
• Caesar encryption technique can be mathematically modeled
using “Modular addition”
• The general formula of a Caesar cipher would be expressed as:
c ≡ p + K mod n

Arab Open University - Spring 2021


• Where:
• n is the modulus
• p is used to represent the plaintext
• c is used to represent the ciphertext
• K is used to represent the key.

• For Caesar Cipher:


• We have 26 different letters so the modulus is n = 26 23
• p, c and K can take any value between 0 and 25.
2.2 Mathematical representation [7/9]
• Example: Encrypt the letter ‘z’ with a Caesar cipher using a
key of K=3.

Arab Open University - Spring 2021


• The numerical form of z is: p=25.
• The ciphertext is obtained by: c ≡ p + K mod 26
so, c ≡ 25 + 3 mod 26 ≡ 28 mod 26 ≡ 2 mod 26
so, the numerical for of the ciphertext is c = 2
• The numerical value of 2 represents the letter ‘C’ (the
ciphertext) 24
• So ‘z’ encrypts to C.
2.2 Mathematical representation [8/9]
• Activity 5.5: Write out the following using mathematical
notation and evaluate the result. Use the grid in Figure
5.5 to translate between alphabetic symbols and
numerical values.

Arab Open University - Spring 2021


• (a) The ciphertext resulting from encryption letter ‘f’
using the Caesar cipher with a key of 6.
• (b) The ciphertext resulting from encryption letter ‘s’
using the Caesar cipher with a key of 12.
• (c) The ciphertext resulting from encryption letter ‘m’
using the Caesar cipher with a key of 20.
25
2.2 Mathematical representation [9/9]
• Activity 5.1 – Sol. :
• (a) pf = 5, so when K=6, so
• c ≡ 5 + 6 mod 26 ≡ 11 mod 26
• The numerical value of 11 represents the letter L.

Arab Open University - Spring 2021


• (b) ps = 18, so when K=12, so
• c ≡ 18 + 12 mod 26 ≡ 4 mod 26
• The numerical value of 4 represents the letter E.
• (c) pm = 12, so when K=20, the calculation becomes
• c ≡ 12 + 20 mod 26 ≡ 6 mod 26
• The numerical value of 6 represents the letter G.
26
Session Outline
• Part 5: Encryption
• Introduction
• Encryption

Arab Open University - Spring 2021


• Basic concepts
• A simple substitution cipher
• Mathematical Representation: The Caesar Cipher
• Decrypting the Caesar Cipher
• A Simple Transposition Cipher
• Breaking a cipher 27
2.3 Decrypting the Caesar cipher [1/3]
• Using the cipher wheel the decryption process simply
involves:
• Displacing the outer wheel clockwise a number of places
corresponding to the agreed key
• Translating each ciphertext letter shown on the inner wheel to its

Arab Open University - Spring 2021


equivalent plaintext letter on the outer wheel.
• Using Julius Caesar’s version of the cipher this would require a
clockwise displacement of three places.
• This would be just the same as displacing the outer wheel 23
places in an anticlockwise direction.
• An anticlockwise displacement of 23 (or 26 − 3) is the equivalent
of a clockwise displacement of 3.
• Thus 3 and 23 form a complementary pair
• Two numbers X and Y are said to be complementary pair when X+Y = 28
modulus (3+23 = 26 = modulus)
2.3 Decrypting the Caesar cipher [2/3]
• Mathematically the decryption algorithm of a Caesar cipher
would be expressed as:
ഥ mod 26
p≡c+𝐾

Arab Open University - Spring 2021


Where 𝑲ഥ (read as K bar) is the decryption key.
ഥ form a complementary pair (K+ 𝐾
And K and 𝐾 ഥ =26)

• Activity 5.3: What are the decryption keys for the Caesar
cipher with encryption keys of: 10, 15 and 7?
• K=10 → K+ 𝐾 ഥ =26 → 𝐾ഥ =26 – K = 26 – 10 → 𝐾ഥ =16
• K=15 → K+ 𝐾 ഥ =26 → 𝐾ഥ =26 – K = 26 – 15 → 𝐾ഥ =11
• K=7 → K+ 𝐾ത =26 → 𝐾ത =26 – K = 26 – 7 → 𝐾ത =19 29
2.3 Decrypting the Caesar cipher [3/3]
• You noted that one key is so easy to derive from the
other
• Effectively the encryption and decryption key of a Caesar cipher
can be regarded as a single key.
• if we know the encryption key we also know the decryption key

Arab Open University - Spring 2021


• or we can decrypt the ciphertext by reversing the encryption
algorithm.
• Encryption systems like this are known as symmetric key
systems
• In a Symmetric Key system: only a single key is involved in the
encryption and decryption processes.
30
Session Outline
• Part 5: Encryption
• Introduction
• Encryption

Arab Open University - Spring 2021


• Basic concepts
• A simple substitution cipher
• Mathematical Representation: The Caesar Cipher
• Decrypting the Caesar Cipher
• A Simple Transposition Cipher
• Breaking a cipher 31
2.4 A simple transposition cipher [1/4]
• A transposition cipher: is an anagram of the plaintext created
systematically using a method that can be shared with the
intended recipient so that it can be decrypted.

• One way to create the transposition is to use a matrix of cells

Arab Open University - Spring 2021


and to write the message a letter at a time in sequential cells
across the matrix.
• Encryption is performed by reordering the columns of the
matrix in some systematic way and then reading off the
result to produce the ciphertext.
• This kind of cipher is known as a columnar transposition
cipher. 32
2.4 A simple transposition cipher [2/4]
Columnar Transposition Cipher:
1. The sender and receiver agree on a codeword and a way to reorder
the letters in the keyword into an anagram.
• For example: Suppose the code word is Tuesday and the agreed
transposition is:
• to reverse the order of the letters (YADSEUT)

Arab Open University - Spring 2021


• then swap pairs of letters, starting at the right-hand end to produce the anagram
YDAESTU.
• The number of letters in the keyword dictates the number of columns in the
matrix
2. The plaintext is entered into each of the columns (with the keyword
at the top) a letter at a time working across the rows.
3. Any empty places in a row can be padded with redundant letters (the
‘x’ in the chosen example).
4. The columns are then reordered according to the keyword anagram.
5. The ciphertext is given by reading back the letters from the reordered 33
matrix.
2.4 A simple transposition cipher [3/4]
Example: The sender and recipient agreed to use the keyword “tuesday” and
its anagram”YDAESTU” to encrypt the following message using columnar
transposition cipher: “Mary had a little lamb its fleece was white as snow”.
What the ciphertext from this message?

Arab Open University - Spring 2021


The resulting ciphertext is: 34
“DHARYMAETLITALSITMBLAWCEEEFLEITWHASXOWSNAS”
Session Outline
• Part 5: Encryption
• Introduction
• Encryption: basic concepts

Arab Open University - Spring 2021


• Breaking a cipher
• Introduction
• Brute Force Attack

35
3. Breaking a cipher [1/2]
• Breaking (or cracking) a cipher: is to derive the plaintext from
the ciphertext without knowledge of the key (and often
without knowledge of the encryption algorithm).
• The strength of a cipher is measured by how long it takes to
break it.

Arab Open University - Spring 2021


• Notice that we said ‘how long it takes to break it’ and NOT
‘whether it can be broken’.
• Potentially all known ciphers except one are thought to be breakable !
• The time and effort required to break a cipher is not justified by
the value of the information retrieved.
• The cipher may take so long to break that by the time the information
is retrieved it has lost its value.
36
3. Breaking a cipher [2/2]
• Strong Ciphers take a long time to break, but they also tend to
be more difficult to use.
• Weak ciphers are quicker to break but are usually also quite
easy to use.
• The choice of cipher will usually be determined by the value of

Arab Open University - Spring 2021


the information it is designed to protect
• The use of any cipher induces an overhead in terms of time and
processing demands

How to break a cipher?


37
Session Outline
• Part 5: Encryption
• Introduction
• Encryption: basic concepts

Arab Open University - Spring 2021


• Breaking a cipher
• Introduction
• Brute Force Attack

38
3.1 Brute force attack [1/9]
• Imagine that you have a bunch of keys
and you know that one of them (but not
which one) will unlock the door to a room
you wish to enter. What would you do to
unlock the door?

Arab Open University - Spring 2021


• The obvious thing to do is to try every key in the lock in turn.
• If you are lucky, the first one you try will open the door.
• If you are unlucky it may be the last one.
• A similar method to this can be used to break a cipher using
a known algorithm!
39
3.1 Brute force attack [2/9]
• Example: if you have a ciphertext message that you know has
been encrypted using the simple Caesar cipher described
earlier, how many keys would you need to try before you
could be certain of finding the right one?
• The answer is 26, since there are 26 possible keys that could be

Arab Open University - Spring 2021


used with this algorithm.

• This method of trying all possible combinations in a key space


is known as a brute force attack.
• The number of possible key combinations for a particular
algorithm is known as its key space.

40
3.1 Brute force attack [3/9]
• The time taken to break a cipher by this method alone is
directly proportional to the key space.
• For example: The Caesar cipher has a very small key space and so
can be broken very quickly.

Arab Open University - Spring 2021


• A brute force attack can be applied to transposition ciphers
as well as substitution ciphers:
• Substitution cipher: test every key in the key space.
• Transposition cipher: test every permutation of the possible
transpositions.

How long would it take a Brute force attack to 41


break a cipher?
3.1 Brute force attack [4/9]
• Activity 5.5: How many different arrangements would be
possible using the seven letters of the word ‘article’?
• Sol:
• Each letter in the word ‘article’ appears only once.

Arab Open University - Spring 2021


• Taking one letter at a time, the first can appear in any
of the seven positions; the second in any of the 6
remaining positions; the third in any of the five
remaining positions; and so on.
• This gives a total possible number of combinations of
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040
42
3.1 Brute force attack [5/9]
• From Activity 5.5, working through all possible 5040
permutations using a pencil and paper would take quite a long
time to do.
• However, a computer would be able to yield the correct

Arab Open University - Spring 2021


answer in a fraction of a second!
• Example: A computer can perform one thousand billion
calculations every second, how long would it take to try all the
possible arrangements of the word ‘article’?
• Sol.: The computer speed is: 1000 × 1 000 000 000 = 1 × 1012
calculations per second
• So to perform 5040 ≈ 5 × 103 calculations would take roughly:
5 × 103 −9 Seconds = 5 nanoseconds. 43
= 5 × 10
1 × 1012
3.1 Brute force attack [6/9]
• Activity 5.6: Using a computer that can perform 1012
calculations a second, roughly how long would it take to
try all possible permutations of:
(a) 10 different letters

Arab Open University - Spring 2021


(b) 15 different letters
(c) 20 different letters.

44
3.1 Brute force attack [7/9]
• Activity 5.6 – Sol. :

Arab Open University - Spring 2021


45
3.1 Brute force attack [8/9]
• A transposition cipher with 26 different letters would
take
• 12.7million years to try all the possible combinations!!!
• The probability of getting the correct plaintext at the first try is 1
in 26! (or 1 in about 4 × 1026 )

Arab Open University - Spring 2021


46
3.1 Brute force attack [9/9]
• Weakness of a transposition cipher: the number of
possible permutations to crack a transposition cipher
depends on the content of the message.
• A transposition cipher is incapable of encrypting a string of

Arab Open University - Spring 2021


identical characters!
• A transposition cipher weak when there are long blocks of
identical characters within the string → Easier to break
• However, given text with normal language
characteristics, a transposition cipher can be strong
against a brute force attack.

Is there any other technique to break a cipher? 47


Yes there is:
The linguistic analysis

Arab Open University - Spring 2021


To be discussed Next Week!

48

You might also like