0% found this document useful (0 votes)
72 views54 pages

T215B Session 4

(a) The modulus used would be 676 since there are 676 possible digraph combinations. (b) The values could range from 0 to 675 to represent the 676 possible digraph combinations. To encrypt a digraph using a Caesar cipher: 1. Convert the plaintext digraph to its numerical code value using the formula: code = letter1 * 26 + letter2 2. Add the numerical key value to the code value 3. Take the remainder when dividing the resulting value by the modulus (676) 4. Convert the remainder back to its equivalent digraph This encrypts the digraph using the Caesar cipher approach with the increased key space of 676 possible values.

Uploaded by

Patrick Farah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views54 pages

T215B Session 4

(a) The modulus used would be 676 since there are 676 possible digraph combinations. (b) The values could range from 0 to 675 to represent the 676 possible digraph combinations. To encrypt a digraph using a Caesar cipher: 1. Convert the plaintext digraph to its numerical code value using the formula: code = letter1 * 26 + letter2 2. Add the numerical key value to the code value 3. Take the remainder when dividing the resulting value by the modulus (676) 4. Convert the remainder back to its equivalent digraph This encrypts the digraph using the Caesar cipher approach with the increased key space of 676 possible values.

Uploaded by

Patrick Farah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

T215B

Communication and
information technologies (II)

Arab Open University Spring


Session 4

2021
Block 4
Protecting and prying 1
Session Outline
• Part 5: Encryption
• Breaking a Cipher
• Linguistic Analysis
• Building Stronger Ciphers

Arab Open University


• Building Blocks of modern encryption

Spring 2021
systems

2
3.2 Linguistic analysis [1/8]
• The first approach to cipher breaking is Brute Force Attack
• A second approach to cipher breaking is the linguistic analysis
• Linguistic Analysis: to attempt to exploit any linguistic patterns
inherited from the plaintext (for only textual contexts).

• All written languages exhibit characteristic patterns.

Arab Open University


• For example, in written English
• the letter ‘q’ is almost always followed by a ‘u’
• certain pairs of letters (known as digraphs) are more likely to appear

Spring 2021
together than others: ‘th’ is common as are ‘ea’, ‘of’, and ‘st’.
• Some identical letters can often appear together, for example ‘ee’, ‘oo’,
‘tt’, but seldom ‘uu’ or ‘hh’.
• There is a higher probability of certain letters appearing than other
letters
• For example , in written English 3
• The most common letter is ‘e’, followed by ‘t’, ‘a’ and ‘o’.
• ‘etaoin’ are the six most frequent letters.
3.2 Linguistic analysis [2/8]

Arab Open University


4

Spring 2021
3.2 Linguistic analysis [3/8]

Arab Open University


5

Spring 2021
3.2 Linguistic analysis [4/8]

Arab Open University


6

Spring 2021
3.2 Linguistic analysis [5/8]
• A ciphertext sequence can also be analysed for letter
frequency.
• If the analysis shows a curve similar to Figure 5.8 or Figure 5.9
then:
• There is a strong possibility that the most frequently occurring
ciphertext letters will correspond to their equivalents in standard

Arab Open University


English text!

Spring 2021
How linguistic analysis can help to break ciphers?
7
3.2 Linguistic analysis [6/8]
Standard English letter frequency
Activity 5.7: The figure below shows the
results of letter frequency analysis of a
sample of ciphertext.
• Does the ciphertext exhibit a pattern
similar to standard English letter
frequencies?
• If so, what assumptions could you

Arab Open University


make about the cipher?

Activity 5.7 – Comments: Ciphertext letter frequency

Spring 2021
The following similarities can be noted:
• R–Z→A–I
• B–G→K–P
• I – P → R – Y.

8
3.2 Linguistic analysis [7/8]
Activity 5.7 – Comments:
• The similarities mean that the cipher was created using a
simple substitution cipher!
• The ordering of the letters was preserved in the ciphertext but
their identity was changed.
• In fact, if the ciphertext letter frequency plot was shifted to

Arab Open University


the left by 17 places the result would look very similar to the
standard English plot.

Spring 2021
• The guess would be that the cipher used was a simple Caesar
cipher with a key of 17.

9
3.2 Linguistic analysis [8/8]
• Linguistic patterns can prove useful for breaking simple
transposition ciphers too.
• In a transposition cipher, the positions of the letters change
but their identity remains the same
• For example, there will be the same frequency of the letter “E” in
the ciphertext as there is in the plaintext.

Arab Open University


• Given a long enough sample of transposition ciphertext,
frequency analysis can provide a useful starting point for the

Spring 2021
cryptanalyst.

10
Session Outline
• Part 5: Encryption
• Breaking a Cipher
• Building Stronger Ciphers
• Increasing the Key Space

Arab Open University


• Weakening the linguistic association

Spring 2021
• An unbreakable cipher
• Building Blocks of modern encryption
systems
11
4. Building stronger ciphers [1/1]
• To combat Brute force attack we need:
A very large key space
• To combat Linguistic analysis benefits we need:
A weak association between the linguistic patterns in the
plaintext and ciphertext
• So, two desirable characteristics are required to

Arab Open University


build strong ciphers:
• a very large key space

Spring 2021
• a weak association with the linguistic patterns in the
plaintext.

How ciphers can be designed to address 12


these requirements?
4.1 Increasing the key space [1/9]
• Using the simple Caesar cipher, the maximum key length is 26.
What if encrypt letters as pairs (digraphs) instead of singly?

• Possible digraphs are:


aa, ab, ac, …, ay, az
Then, ba, bb, bc, …, by, bz

Arab Open University


Then … … … za, zb, …, zy, zz
• Numerical coding:

Spring 2021
aa ab … az ba bb … bz … … … za zb … zz
0 1 25 26 27 51 650 651 675

• Since each single letter represents one of 26 possibilities


• each pair of letters would represent one of 26 × 26 = 262 = 676 13
possibilities
4.1 Increasing the key space [2/9]
• So digraph coding provides a means of increasing the key space from 26
to 676!
• Using a simple Caesar cipher: the key can take any value between 0 and 25!
• Using a Caesar cipher with digraph coding: the key can take any value
between 0 and 675!

Do you think it is practical to search in a table of 676 columns?


How to mathematically calculate the numerical code of a digraph?

Arab Open University


• The numerical code of a digraph is given by:

Spring 2021
p = p1 x 26 + p2
• Where
• p is the numerical equivalent of the digraph in question.
• p1 is the numerical equivalent of the first letter in the pair (on the left).
• p2 is the numerical equivalent of the second letter in the pair (on the right). 14
4.1 Increasing the key space [3/9]
• Activity 5.10: Calculate the numerical code value for the first
digraph in the word ‘zenith’.
• Sol.:
• ‘zenith’ would be treated as three separate digraphs: ze ni th.
• The first digraph is ‘ze’.
• pz= 25 and pe = 4.

Arab Open University


• So the digraph ‘ze’ is coded as pze = pz x 26 + pe
• So, pze = (25 × 26) + 4 = 654

Spring 2021
15
How to convert a numerical code to its equivalent
digraph?
4.1 Increasing the key space [4/9]
• Example:Convert 325 into its equivalent digraph.
• Sol.:
325 𝑝2
• 325 = p1 x 26 + p2 so = 𝑝1 +
26 26
• So, if we divide 325 by 26:
• p1 would be the quotient of the division

Arab Open University


• p2 would be the remainder of the division
13
• While 325/26 = 12.5 = 12 +
26

Spring 2021
• p1 = 12 → this numerical code is equivalent to the letter ‘m’
• p2 = 13 → this numerical code is equivalent to the letter ‘n’
• So 325 is equivalent to the digraph ‘mn’
16
How to encrypt a digraph using Caesar cipher?
4.1 Increasing the key space [5/9]
• Activity 5.11: Using digraphs for coding and encrypting
alphabetic symbols:
• (a) what value would be used for the modulus?
• (b) what values could be chosen for the key?
Sol.
• (a) A coded digraph can take one of a possible 26 × 26 = 676

Arab Open University


different combinations.
So the modulus is 676.
• (b) The key can be any number from 0 to 675.

Spring 2021
• Note that “0” can be excluded from the key space since a key of
K=0 will not change the plaintext!
• The general encryption formula of a Caesar cipher with
digraph coding is:
17
c ≡ p + K mod 676
4.1 Increasing the key space [6/9]
• Example:Use a Caesar Cipher with digraph coding to encrypt
the following plaintext: ‘zenith’ with a key of K=347.
• Sol.:‘zenith’ contains three digraphs: ze; ni and th.
• ‘ze’ encryption :
• pze=pz x 26 + pe = (25 × 26) + 4 ; so pze= 654

Arab Open University


• So cze ≡ pze + K mod 676 ≡ 654 + 347 mod 676 ≡ 1001 mod 676 ≡
325 mod 676

Spring 2021
• The next step is to convert 325 into the equivalent digraph to
derive the ciphertext:
13
• 325/26 = 12.5 = 12 + 26
• p1 = 12 → this numerical code is equivalent to the letter ‘M’
18
• p2 = 13 → this numerical code is equivalent to the letter ‘N’
• so the ciphertextdigraph for ‘ze’ is ‘MN’.
4.1 Increasing the key space [7/9]
• Example:Use a Caesar Cipher with digraph coding to encrypt
the following plaintext: ‘zenith’ with a key of K=347.
• Sol.:‘zenith’ contains three digraphs: ze; ni and th.
• ‘ni’ encryption :
• pni=pnx 26 + pi= (13 × 26) + 8 ; so pni= 346
• So cni≡ pni+ K mod 676 ≡ 346 + 347 mod 676 ≡ 693 mod 676 ≡ 17

Arab Open University


mod 676
• The next step is to convert 17 into the equivalent digraph to
derive the ciphertext:

Spring 2021
17
• 17/26 = 0 + 26
• p1 = 0 → this numerical code is equivalent to the letter ‘a’
• p2 = 17 → this numerical code is equivalent to the letter ‘r’
• so the ciphertext digraph for ‘ni’ is ‘AR’. 19
4.1 Increasing the key space [8/9]
• Example: Use a Caesar Cipher with digraph coding to encrypt
the following plaintext: ‘zenith’ with a key of K=347.
• Sol.: ‘zenith’ contains three digraphs: ze; ni and th.
• ‘th’ encryption :
• Using the same method described previously, the ciphertext digraph for
‘th’ is ‘GQ’.

Arab Open University


• So, using a Caesar cipher with digraph coding, ‘zenith’ is
encrypted as ‘MNARGQ’

Spring 2021
Can we further increase the key space?
20
4.1 Increasing the key space [9/9]
• Activity 5.13: What key space is possible by encoding the
letters as blocks of:
• (a) 3 (or trigraph)?
• (b) 5?
• (c) 10?

Arab Open University


• Sol.:
• (a) a block of 3 (or trigraph) would result in 263 = 17576

Spring 2021
possible keys.
• (b) a block of 5 would result in 265 = 11881376 possible
keys.
• (c) a block of 10 would result in 2610 = 1.41 x 1014 (to 2
21
decimal places) possible keys.
Session Outline
• Part 5: Encryption
• Breaking a Cipher
• Building Stronger Ciphers
• Increasing the Key Space

Arab Open University


• Weakening the linguistic association

Spring 2021
• An unbreakable cipher
• Building Blocks of modern encryption
systems
22
4.2 Weakening the linguistic association [1/5]

• The Caesar cipher uses a monoalphabetic substitution.


• The key remains constant
• For example, the plaintext letter ‘e’ will always be encrypted as the
same ciphertext symbol.
• The ciphertext inherits the linguistic patterns of the plaintext
• The ciphertext is susceptible to letter frequency and other linguistic
analysis!

Arab Open University


How to decouple from the linguistic patterns of the

Spring 2021
plaintext?

• One way to do so is to encrypt with a cipher that uses a succession


of different keys.
• The Vigenère cipher provides an example of how this can be 23
achieved.
4.2 Weakening the linguistic association [2/5]

• The Vigenère cipher uses a key known as a running key, which


is generated by a keyword.
• Example: Use the Vigenère cipher with the keyword ‘jupiter’
to encrypt the following sentence: “A stitch in time saves nine”
• Solution:
• Using the convention of assigning a numerical value to each

Arab Open University


letter, ‘jupiter’ would produce a key sequence of 9, 20, 15, 8, 19,
4, 17.

Spring 2021
• This provides a succession of different keys that can be used over
and over again in the same sequence.
• Each symbol in the plaintext is encrypted using the next key in the
sequence.
24
4.2 Weakening the linguistic association [3/5]

• Example: Use the Vigenère cipher with the keyword ‘jupiter’


to encrypt the following sentence: “A stitch in time saves nine
• Solution:
• The following Caesar Cipher’s formula is used to determine
the numerical code of the ciphertext of each letter:

Arab Open University


c ≡ p + K mod 26
Where K takes sequentially the following values : {9, 20, 15, 8,
19, 4, 17}

Spring 2021
25
4.2 Weakening the linguistic association [4/5]

• Weakness of a Vigenère cipher:


• Where similar letters appear at distances corresponding to the
keyword length, their ciphertext letters will match each other!
• For example, the letter pair ‘ti‘ in the plaintext word ‘stitch’ and the
letter pair ‘ti’ in ‘time’ are both encrypted as ‘IQ’.

Arab Open University


Spring 2021
7 steps =
keyword
length

26
4.2 Weakening the linguistic association [5/5]

• Weakness of a Vigenère cipher:


• Given a large enough sample of ciphertext the probability of such
an issue to appear increases
• A cryptanalyst can hence determine the length of the running key ‘n’
• Every nth symbol can then be treated and analyzed as one strand
• The cipher can then be easily solved!

Arab Open University


Spring 2021
Solution?
27
Session Outline
• Part 5: Encryption
• Breaking a Cipher
• Building Stronger Ciphers
• Increasing the Key Space

Arab Open University


• Weakening the linguistic association

Spring 2021
• An unbreakable cipher
• Building Blocks of modern encryption
systems
28
4.3 An unbreakable cipher [1/2]
• The idea is to use a key that is identical in length to the
plaintext, and to use it only once.
• Encryption based on this method is known as one-time pad
encryption.
• A One Time Pad Encryption:
1. A random key – the pad – is generated that is at least as long

Arab Open University


as the plaintext message
• Two copies of the pad are required

Spring 2021
• one is used by the sender to encrypt the message.
• one is used by the recipient to decrypt the message.
2. Once it has been used both copies must be destroyed.

29
4.3 An unbreakable cipher [2/2]
• The random nature of the pad (key) means that:
• The ciphertext has no linguistic association with the original plaintext
• The ciphertext cannot be broken by analysis or brute force.
• When properly applied, the one-time pad is the only known truly
unbreakable cipher.
• One-time pads have been successfully used in the past, mostly for

Arab Open University


high-level diplomatic exchanges.
• But a one-time pad is not a practical cipher for use in modern

Spring 2021
communication technologies.

Example of a one time pad


(wikimedia commons, 2009) 30
Session Outline
• Part 5: Encryption
• Breaking a Cipher
• Building Stronger Ciphers
• Building Blocks of modern encryption

Arab Open University


systems
• Introduction

Spring 2021
• Block Ciphers
• Stream Ciphers
31
• Symmetric Key System
5. Building blocks of modern encryption systems [1/4]

• The ciphers discussed in the preceding sections were


developed to protect the privacy of text-based
communications.
• These were usually written on paper or, in later years,
transmitted by wireless telegraphy.
• Many profound changes have occurred in the last few

Arab Open University


decades in the technologies we use to communicate, store
and process data.

Spring 2021
• The old encryption methods are no longer practical
• The old encryption methods cannot provide the level of protection
needed today.

32
5. Building blocks of modern encryption systems [2/4]

• Modern encryption systems are classified according to some


general characteristics:
• They are block ciphers or stream ciphers?
• They use symmetric or asymmetric key systems?
• All are based on complex mathematical algorithms that rely
on powerful processing capabilities.
• These processes are generally implemented by operating at

Arab Open University


the bit level in the plaintext input, either:
• physically in hardware using electronic devices known as logic

Spring 2021
gates,
• or in software programming using computational logic.
• A key point to bear in mind here is that the data to be
encrypted is not always text.
• Though, the ‘ciphertext’ and ‘plaintext’ notations are commonly 33
used when encryption is discussed.
5. Building blocks of modern encryption systems [3/4]

• Encryption frequently involves an operation known as the


exclusive-or (XOR).
• The exclusive-or (XOR) takes two binary input bits and
combines them to form an output bit.
• XOR is a logical operation, its truth table is given below:

Arab Open University


Truth table of an XOR operation

Spring 2021
34
5. Building blocks of modern encryption systems [4/4]

• Example: What would be the output of combining the 7-bit


ASCII code for the letter ‘N’ (‘1001110’) with the randomly
generated coding data 0011101 using the XOR process.
• Solution:

Arab Open University


• What if we XOR the same random coding data with the
output data?

Spring 2021
• The result is the original data stream!

35
Session Outline
• Part 5: Encryption
• Breaking a Cipher
• Building Stronger Ciphers
• Building Blocks of modern encryption

Arab Open University


systems
• Introduction

Spring 2021
• Block Ciphers
• Stream Ciphers
36
• Symmetric Key System
5.1 Block ciphers [1/9]
• A block cipher breaks the plaintext into equal-sized blocks,
usually of 64 or 128 bits, and encrypts each block separately
to produce a ciphertext output exactly equal in length to the
input.
• The next figure shows a simplified version for blocks of 8
bits.

Arab Open University


Spring 2021
• For plaintext inputs smaller than the block size:
• the empty spaces are padded with recognisable additional bits
• Those additional bits are stripped off during the decryption
process. 37
5.1 Block ciphers [2/9]

Arab Open University


38

Spring 2021
5.1 Block ciphers [3/9]
• There are two basic approaches to block encryption:
• One is to encrypt each block independently of any other,
• The other is to encrypt each block so that its output ciphertext is
dependent on the output of the previous block.
• Electronic Codebook (ECB): An independent encryption approach

Arab Open University


Spring 2021
39
5.1 Block ciphers [4/9]
• Electronic Codebook (ECB):
• The same key will be used for each block.
• The encryption of each block is completely independent from
the other blocks.
• Drawbacks of ECB:

Arab Open University


• Two similar blocks of plaintext will result in similar blocks of
ciphertext
• Since the position of the ciphertext blocks remains fixed

Spring 2021
relative to the plaintext blocks this introduces a vulnerability.
• ECB is not practical when data involves long repetitive strings
of 1s and 0s, such as a picture data.
40
5.1 Block ciphers [5/9]
• Example:
• Consider the below penguin picture
• The white color background pixels are all coded with the same
binary number.
• Hence, the picture file involves long repetitive strings of 1s and 0s
• When coded with ECB, the data pattern in the plaintext can

Arab Open University


still be clearly discerned in the ciphertext.

Spring 2021
41
5.1 Block ciphers [6/9]
• Cipher-block chaining (CBC): A dependent encryption approach

Arab Open University


Spring 2021
42
5.1 Block ciphers [7/9]
• Cipher-block chaining (CBC):
• An XOR process is used to combine the ciphertext output from
one block with the plaintext input of the following block.
• Every ciphertext block is dependent on the ciphertext output
from the preceding block as well as its own plaintext input
• An encryption of identical input blocks will produce different

Arab Open University


results.
• CBC mode requires an additional extra input, known as an

Spring 2021
initialisation vector (IV), to the first block.
• The initialisation vector (IV) is a pseudo-random binary
sequence that is used in the XOR process for the first block
only.
43
What is the ciphertext of the previous penguin picture
when encrypted with a CBC technique?
5.1 Block ciphers [8/9]
• Penguin image of Figure 5.20, encrypted in CBC mode
(Wikipedia, 2009)

Arab Open University


Spring 2021
44
5.1 Block ciphers [9/9]
• Drawbacks of CBC:
• A single encryption error in one block is cascaded
through to the following blocks.
• The decryption relies on knowledge of the previous
block.

Arab Open University


• Any error or loss of data in the previous block prevents that block
and all following blocks from being decrypted!

Spring 2021
45
Session Outline
• Part 5: Encryption
• Breaking a Cipher
• Building Stronger Ciphers
• Building Blocks of modern encryption

Arab Open University


systems
• Introduction

Spring 2021
• Block Ciphers
• Stream Ciphers
46
• Symmetric Key System
5.2 Stream ciphers [1/2]
• Unlike Block Ciphers, Stream ciphers operate on very small
segments of data – usually at the bit level
• Whereas block ciphers have to wait to receive the whole block
before they can start encrypting, stream ciphers can encrypt ‘on
the fly’ one bit (or sometimes one byte) at a time.
• Stream ciphers use a short key that acts as a ‘seed’ to

Arab Open University


generate a much longer, apparently random, key stream.
• The key stream is then combined (usually by an XOR process)

Spring 2021
with the plaintext to produce ciphertext.

47
5.2 Stream ciphers [2/2]
• Decryption is also carried out ‘on the fly’ and using the same
key stream as the encryption process.
• The sender and the receiver must be synchronised to ensure
that the same key is used on each individual bit (or byte) of data.
• Stream ciphers are generally faster than block ciphers, and
are less complex to implement in hardware.

Arab Open University


• They are often used where
• the input stream length is unpredictable (such as in
telecommunications).

Spring 2021
• the input buffering is limited.
• Buffering means temporarily storing bits, as would be needed in
block ciphers where the process has to wait until all the bits in the
block have been received.
• Stream ciphers can be vulnerable if used incorrectly 48
• For example, if the input key is used more than once.
Session Outline
• Part 5: Encryption
• Breaking a Cipher
• Building Stronger Ciphers
• Building Blocks of modern encryption

Arab Open University


systems
• Introduction

Spring 2021
• Block Ciphers
• Stream Ciphers
49
• Symmetric Key System
5.3 Symmetric key systems [1/4]
• In a symmetric key system:
• Encryption and decryption are performed using a
single key or, two keys that are so closely related
to each other mathematically.
• The inherent problem with all single key systems is
secure key distribution.

Arab Open University


• To protect a message, it could be encrypted using a
private symmetric key and then sent over an

Spring 2021
insecure channel.
• But to decrypt the message the recipient must have
a copy of the private key!
How to distribute a private key over 50

the same insecure channel?


5.3 Symmetric key systems [2/4]
• If the shared key is sent over the same insecure channel it
could be intercepted by an eavesdropper and copied.
• if the same eavesdropper previously intercepted the
encrypted message, he can easily decrypt it using his
copy of the shared key.
• A general solution to this, known as the double-locking

Arab Open University


protocol
• This protocol involves a three-way exchange before both parties

Spring 2021
(sender and recipient) are in possession of a secret shared key.
• The Diffie-Hellman key exchange protocol is a well-known protocol
that is commonly used in modern electronic transactions.
• This protocol mathematically performs the same service as double-
locking protocol. 51
5.3 Symmetric key systems [3/4]
• Double-locking protocol:
• Suppose that you and I need to exchange an encryption key:
• We need a box and we each need a padlock.
• I put the encryption key in the box, lock the box with my padlock and
send it to you over the insecure channel.
• The encryption key is safe because the box is locked with my padlock
and I am the only one with the padlock key.

Arab Open University


• Of course, when you receive the box you can’t unlock it either!
Instead you lock the box with your own padlock and return it to me
over the same insecure channel.
• The box is now double locked with your padlock and with mine.

Spring 2021
• When I receive it, I unlock and remove my padlock and return the
box to you.
• The encryption key is still safe because it is locked with your padlock,
and you are the only one with your padlock key.
• On receipt, you unlock your padlock, open the box and retrieve the 52
encryption key.
5.3 Symmetric key systems [4/4]

Arab Open University


Spring 2021
1. Alice encrypts the message with her key and sends it to Bob 53
2. Bob encrypts the message he received with his key and sends it to Alice
3. Alice decrypts the message she received with her key and sends it to Bob
Bob decrypts the message he received with his key and reads the message
Is there any other solution?

Yes!
An Asymmetric Key System

Arab Open University


Spring 2021
To be discussed next week!
54

You might also like