Cryptanalysis of Classical Ciphers: Objectives

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

COMUTER ENGINEERING DEPARTMENT


FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING


NETWORK SECURITY Prepared by:
Dr. Muhammad Asif Khan
Assist. Prof. CPED
LAB #2: Cryptanalysis of Classical Ciphers
UET Taxila

Ø Objectives: To learn cryptanalysis and implement cryptanalysis attacks on


classical ciphers (i.e., substitution ciphers) and to analyze the complexity of
different cryptanalysis attacks


What is Cryptanalysis:-

Cryptanalysis is the process of obtaining the original message (called the plaintext) from an
encrypted message (called the ciphertext) without knowing the algorithms and keys used to
perform the encryption. Cryptanalysis is the study of ciphertext, ciphers and cryptosystems
with the aim of understanding how they work and finding and improving techniques for
defeating or weakening them. While the objective of cryptanalysis is to find weaknesses in
or otherwise defeat cryptographic algorithms, cryptanalysts' research results are used by
cryptographers to improve and strengthen or replace flawed algorithms. Both cryptanalysis,
which focuses on deciphering encrypted data, and cryptography, which focuses on creating
and improving encryption ciphers and other algorithms, are aspects of cryptology, the
mathematical study of codes, ciphers and related algorithms.
Researchers may discover methods of attack that completely break an encryption algorithm,
which means that ciphertext encrypted with that algorithm can be decrypted trivially
without access to the encryption key. More often, cryptanalytic results uncover weaknesses
in the design or implementation of the algorithm, which can reduce the number of keys that
need to be tried on the target ciphertext. For example, a cipher with a 128 bit encryption
key can have 2128 (or 340,282,366,920,938,463,463,374,607,431,768,211,456) unique
keys; on average, a brute force attack against that cipher will succeed only after trying half
of those unique keys. If cryptanalysis of the cipher reveals an attack that can reduce the
number of trials needed to 240 (or just 1,099,511,627,776) different keys, then the
algorithm has been weakened significantly, to the point that a brute-force attack would be
practical with commercial off-the-shelf systems.


Cryptanalytic Techniques and Attacks:

1
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
COMUTER ENGINEERING DEPARTMENT
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

There are many different types of cryptanalysis attacks and techniques, which vary
depending on how much information the analyst has about the ciphertext being analyzed.
Some basic cryptanalytic methods for classical ciphers are shown in Figure 1.


Figure 1: Cryptanalyst attack

• Ciphertext-only attack: In a ciphertext-only attack, the attacker only has access to one
or more encrypted messages but knows nothing about the plaintext data, the encryption
algorithm being used or any data about the cryptographic key being used. This is the
type of challenge that intelligence agencies often face when they have intercepted
encrypted communications from an opponent.


Figure 2: Ciphertext-only attack

• Known-plaintext attack: In a known-plaintext attack, the analyst may have access to
some or all of the plaintext of the ciphertext; the analyst's goal in this case is to discover
the key used to encrypt the message and decrypt the message. Once the key is
discovered, an attacker can decrypt all messages that had been encrypted using that
key.


Figure 3: Known-plaintext attack

• Chosen-plaintext attack: In a chosen-plaintext attack, the analyst either knows the
encryption algorithm or has access to the device used to do the encryption. The analyst
can encrypt the chosen plaintext with the targeted algorithm to derive information
about the key.

2
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
COMUTER ENGINEERING DEPARTMENT
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING


Figure 4: Chosen-plaintext attack

• Chosen-ciphertext attack: A chosen-ciphertext attack is an attack model for
cryptanalysis where the cryptanalyst can gather information by obtaining the
decryptions of chosen ciphertexts. From these pieces of information the adversary can
attempt to recover the hidden secret key used for decryption. Chosen-ciphertext attacks
are generally used for breaking systems with public key encryption.


Figure 5: Chosen-ciphertext attack

Computational Resources Required for Cryptanalysis:
Cryptanalysis attacks can are characterized by the resources they require. These resources
include:
• Time — the number of computation steps (e.g., test encryptions) which must be
performed.
• Memory — the amount of storage required to perform the attack.
• Data — the quantity and type of plaintexts and ciphertexts required for a particular
approach.
Frequency Analysis Attack:
In cryptanalysis, frequency analysis is the study of the frequency of letters or groups of
letters in a ciphertext. The method is used as an aid to breaking classical ciphers. Frequency
analysis is based on the fact that, in any given stretch of written language, certain letters and
combinations of letters occur with varying frequencies. Moreover, there is a characteristic
distribution of letters that is roughly the same for almost all samples of that language. For
instance, given a section of English language, E, T, A and O are the most common, while Z, Q
and X are rare. Likewise, TH, ER, ON, and AN are the most common pairs of letters (termed
bigrams or digraphs), and SS, EE, TT, and FF are the most common repeats.
Table 1 shows the typical distribution of individual letters, digrams and trigrams in English
language writing. In some ciphers, such properties of the natural language plaintext are
preserved in the ciphertext, and these patterns have the potential to be exploited in a
ciphertext-only attack.

3
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
COMUTER ENGINEERING DEPARTMENT
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING


Table 1: Frequency of letters, diagrams and trigrams in English language text










Lab Tasks:

Task 01:
Consider the ciphertext given below, which has been encrypted using affine cipher with two keys i.e.,
a and b. Apply brute-force attack to find out the plaintext.

TZL XSF FKBSTOWNKJ WYNH WFEW LHNKJ XUUNKF BNOYFS

Task 02:
Suppose Eve has intercepted the cryptogram below, and it is known to be encrypted using a simple
substitution cipher as follows:

LIVITCSWPIYVEWHEVSRIQMXLEYVEOIEWHRXEXIPFEMVEWHKVSTYLXZIXLIKIIXPIJVSZE
YPERRGERIMWQLMGLMXQERIWGPSRIHMXQEREKIETXMJTPRGEVEKEITREWHEXXLEXX
MZITWAWSQWXSWEXTVEPMRXRSJGSTVRIEYVIEXCVMUIMWERGMIWXMJMGCSMWXSJO
MIQXLIVIQIVIXQSVSTWHKPEGARCSXRWIEVSWIIBXVIZMXFSJXLIKEGAEWHEPSWYSWIWI
EVXLISXLIVXLIRGEPIRQIVIIBGIIHMWYPFLEVHEWHYPSRRFQMXLEPPXLIECCIEVEWGISJ
KTVWMRLIHYSPHXLIQIMYLXSJXLIMWRIGXQEROIVFVIZEVAEKPIEWHXEAMWYEPPXLMW
YRMWXSGSWRMHIVEXMSWMGSTPHLEVHPFKPEZINTCMXIVJSVLMRSCMWMSWVIRCIGXM
WYMX

a) Write a code for applying brute-force attack on the given ciphertext to obtain plaintext. What
is the key value used for cipher encryption?
b) Apply a frequency analysis attack on the given ciphertext to decipher it. Your code should be
dynamic and must be applicable to any given ciphertext.
c) What computational resources are required to apply brute-force attack and frequency analysis
attack on the ciphertext given in Task 02? You have to compute the processing time and the
amount of storage required to perform the attack, and the quantity and type of plaintexts
or/and ciphertexts required for applying each of these particular approach.

4
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
COMUTER ENGINEERING DEPARTMENT
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

Task 03:
Write a program that takes your name and registration number as input and concatenates this
information to form a plaintext as following: yournamezzzregistrationnumber (your name and
registration number should be separated by three consecutive z’s). Suppose, you want to send this
information to one of your friends and there is a possibility that any third person may intercept your
message. Your task is to secure this plaintext so that any third person if intercepts this message
cannot get any information about your name or/and registration number. You can implement any
encryption algorithm for this purpose. Once you encrypt your message, find out what types of
cryptanalyst attacks are possible from an eavesdropper? Write a program that implements those
cryptanalysis attacks to decipher your own encrypted text. Also, find out the complexities of those
cryptanalysis attacks.

Note: Practical Report Required!

For all labs, you are expected to write up a concise report on what you did, including results in the
report. The main thing is to convey your understanding of each of the steps taken.

Ø Report format: Flexible (MS Word document)


Ø Delivery: online
Deadline: Given

You might also like