Cryptography (CSC316) : Unit I: Introduction and Classical Ciphers

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

CRYPTOGRAPHY

(CSC316)
Unit I : Introduction and Classical Ciphers

Prepared by: Suresh Thapa


Vedas College, Jawalakhel, Lalitpur
Introduction
■ Computer data often travels from one computer to another, leaving the safety of its
protected physical surroundings. Once the data is out of hand, people with bad intention
could modify or forge your data, either for amusement or for their own benefit.
Cryptography can reformat and transform our data, making it safer on its trip between
computers. The technology is based on the essentials of secret codes, augmented by
modern mathematics that protects our data in powerful ways.
■ Computer Security - generic name for the collection of tools designed to protect data
and to thwart hackers
■ Network Security - measures to protect data during their transmission
■ Internet Security - measures to protect data during their transmission over a collection
of interconnected networks
Introduction
■ To assess the security needs of an organization effectively, the manager responsible for
security needs some systematic way of defining the requirements for security and
characterization of approaches to satisfy those requirements. One approach is to
consider three aspects of information security:
■ Security attack – Any action that compromises the security of information owned
by an organization.
■ Security mechanism – A mechanism that is designed to detect, prevent or recover
from a security attack.
■ Security service – A service that enhances the security of the data processing systems
and the information transfers of an organization. The services are intended to counter
security attacks and they make use of one or more security mechanisms to provide the
service.
Basic Concept
■ Cryptography : The art or science encompassing the principles and methods of transforming an
intelligible message into one that is unintelligible, and then retransforming that message back to its
original form
■ Plaintext : The original intelligible message
■ Cipher text : The transformed message
■ Cipher : An algorithm for transforming an intelligible message into one that is unintelligible by
transposition and/or substitution methods
■ Key : Some critical information used by the cipher, known only to the sender& receiver
■ Encipher (encode) : The process of converting plaintext to cipher text using a cipher and a key
■ Decipher (decode) : The process of converting cipher text back into plaintext using a cipher and a key
■ Cryptanalysis : The study of principles and methods of transforming an unintelligible message back
into an intelligible message without knowledge of the key. Also called code breaking
■ Cryptology : Both cryptography and cryptanalysis
■ Code : An algorithm for transforming an intelligible message into an unintelligible one using a code-
book
Cryptography
Cryptography

Symmetric Key Cryptography Asymmetric Key Cryptography

Classic Cryptography Modern Cryptography

Substitution Cipher Transposition Cipher Block Cipher Stream Cipher


Cryptosystem
■ Cryptosystem is a 5-tuple/quintuple (E, D, M, K, C),
where M set of plaintexts,
K set of keys,
C set of ciphertexts,
E set of encryption functions e: M x K  C and
D set of decryption functions d: C x K  M.
– Example: Caesar
– Cipher M = {sequences of letters}
– K = {i | i is an integer and 0 ≤ i ≤ 25}
– E = {Ek | k  K and for all letters m,
– Ek(m) = (m + k) mod 26 }
– D = {Dk | k  K and for all letters c, Dk(c) = (26 + c – k) mod 26}
– C=M
Cryptanalysis
■ The process of attempting to discover X or K or both is known as cryptanalysis. The strategy used by
the cryptanalysis depends on the nature of the encryption scheme and the information available to the
cryptanalyst.
■ There are various types of cryptanalytic attacks based on the amount of information known to
the cryptanalyst.
– Cipher text only – A copy of cipher text alone is known to the cryptanalyst.
– Known plaintext – The cryptanalyst has a copy of the cipher text and the corresponding
plaintext.
– Chosen plaintext – The cryptanalysts gains temporary access to the encryption machine. They
cannot open it to find the key, however; they can encrypt a large number of suitably chosen
plaintexts and try to use the resulting cipher texts to deduce the key.
– Chosen cipher text – The cryptanalyst obtains temporary access to the decryption machine,
uses it to decrypt several string of symbols, and tries to use the results to deduce the key.
■ Brute-force attack : The attacker tries every possible key on a piece of cipher text until an intelligible
translation into plaintext is obtained. On average, half of all possible keys must be tried to achieve
success.
SECURITY SERVICES
The classification of security services are as follows:
■ Confidentiality: Ensures that the information in a computer system and transmitted information
are accessible only for reading by authorized parties. E.g. Printing, displaying and other forms of
disclosure.
■ Authentication: Ensures that the origin of a message or electronic document is correctly identified,
with an assurance that the identity is not false.
■ Integrity: Ensures that only authorized parties are able to modify computer system assets and
transmitted information. Modification includes writing, changing status, deleting, creating
and delaying or replaying of transmitted messages.
■ Non repudiation: Requires that neither the sender nor the receiver of a message be able to deny the
transmission.
■ Access control: Requires that access to information resources may be controlled by or the target
system.
■ Availability: Requires that computer system assets be available to authorized parties when needed.
SECURITY MECHANISMS
■ One of the most specific security mechanisms in use is cryptographic techniques.
Encryption or encryption-like transformations of information are the most common
means of providing security.
■ Some of the mechanisms are
– Encipherment
– Digital Signature
– Access Control
SECURITY ATTACKS
There are four general categories of attack which are listed below.
■ Interruption : An asset of the system is destroyed or becomes unavailable or unusable.
This is an attack on availability e.g., destruction of piece of hardware, cutting of a
communication line or Disabling of file management system.
■ Interception : An unauthorized party gains access to an asset. This is an
attack on confidentiality. Unauthorized party could be a person, a program
or a computer. e.g., wire tapping to capture data in the network, illicit copying of files

Sender Receiver

Eavesdropper
or forge
SECURITY ATTACKS
■ Modification : An unauthorized party not only gains access to but tampers with an asset.
This is an attack on integrity. e.g., changing values in data file, altering a program,
modifying the contents of messages being transmitted in a network.

Sender Receiver

Eavesdropper or forge
■ Fabrication : An unauthorized party inserts counterfeit objects into the system. This is
an attack on authenticity. e.g., insertion of spurious message in a network or addition of
records to a file.

Sender Receiver
Eavesdropper
or forge
Cryptographic Attacks
■ Passive Attacks
– Passive attacks are in the nature of eavesdropping on, or monitoring of,
transmissions. The goal of the opponent is to obtain information that is being
transmitted. Passive attacks are of two types:
■ Release of message contents: A telephone conversation, an e-mail message and a
transferred file may contain sensitive or confidential information. We would like to
prevent the opponent from learning the contents of these transmissions.
■ Traffic analysis: If we had encryption protection in place, an opponent might still be
able to observe the pattern of the message. The opponent could determine the location
and identity of communication hosts and could observe the frequency and length of
messages being exchanged. This information might be useful in guessing the nature of
communication that was taking place.
– Passive attacks are very difficult to detect because they do not involve any
alteration of data. However, it is feasible to prevent the success of these attacks.
Cryptographic Attacks
■ Active attacks
– These attacks involve some modification of the data stream or the creation of a false
stream. These attacks can be classified in to four categories:
■ Masquerade – One entity pretends to be a different entity.
■ Replay – involves passive capture of a data unit and its subsequent transmission to produce
an unauthorized effect.
■ Modification of messages – Some portion of message is altered or the messages are
delayed or recorded, to produce an unauthorized effect.
■ Denial of service – Prevents or inhibits the normal use or management of
communication facilities. Another form of service denial is the disruption of an entire
network, either by disabling the network or overloading it with messages so as to degrade
performance.
– It is quite difficult to prevent active attacks absolutely, because to do so would require
physical protection of all communication facilities and paths at all times. Instead, the
goal is to detect them and to recover from any disruption or delays caused by them.
Classical Cryptosystem
■ There are two basic building blocks of all encryption techniques: substitution and
transposition.
■ SUBSTITUTION TECHNIQUES
– A substitution technique is one in which the letters of plaintext are replaced by
other letters or by numbers or symbols. If the plaintext is viewed as a sequence of
bits, then substitution involves replacing plaintext bit patterns with cipher text bit
patterns.
■ TRANSPOSITION TECHNIQUES
– All the techniques examined so far involve the substitution of a cipher text
symbol for a plaintext symbol. A very different kind of mapping is achieved by
performing some sort of permutation on the plaintext letters. This technique is
referred to as a transposition cipher.
SUBSTITUTION TECHNIQUES
■ Caesar cipher (or) shift cipher
– The earliest known use of a substitution cipher and the simplest was by Julius Caesar. The
Caesar cipher involves replacing each letter of the alphabet with the letter standing 3
places further down the alphabet.
– e.g., plain text : pay more money
– Cipher text: SDB PRUH PRQHB
– Note that the alphabet is wrapped around, so that letter following “z” is “a”.
– For each plaintext letter p, substitute the cipher text letter c such that
C = E(p) = (p+3) mod 26
– A shift may be any amount, so that general Caesar algorithm is
C = E (p) = (p+k) mod 26 Where k takes on a value in the range 1 to 25.
– The decryption algorithm is simply
P = D(C) = (C-k) mod 26
SUBSTITUTION TECHNIQUES
■ Monoalphabetic Ciphers
– also known as a simple substitution cipher, relies on a fixed replacement structure.
That is, the substitution is fixed for each letter of the alphabet. Thus, if "a" is
encrypted to "R", then every time we see the letter "a" in the plaintext, we replace
it with the letter "R" in the ciphertext.
SUBSTITUTION TECHNIQUES
■ Playfair Cipher
– The best known multiple letter encryption cipher is the playfair, which treats diagrams in the plaintext as single units and
translates these units into cipher text diagrams.
– The playfair algorithm is based on the use of 5x5 matrix of letters constructed using a keyword. Let the keyword be
“monarchy” .
– The matrix is constructed by filling in the letters of the keyword (minus duplicates) from left to right and from top to bottom,
and then filling in the remainder of the matrix with the remaining letters in alphabetical order.
– The letter i and j count as one letter.
– Plaintext is encrypted two letters at a time
– According to the following rules:
■ Repeating plaintext letters that would fall in the same pair are separated with a Filler letter such as ‘x’.
■ Plaintext letters that fall in the same row of the matrix are each replaced by the letter to the right, with the first element of the row
following the last.
■ Plaintext letters that fall in the same column are replaced by the letter beneath, with the top element of the column following the last.

■ Otherwise, each plaintext letter is replaced by the letter that lies in its own row And the column occupied by the other plaintext letter.
– Plaintext = meet me at the school house
– Splitting two letters as a unit => me et me at th es ch ox ol ho us ex
– Corresponding cipher text => CL KL CL RS PD IL HY AV MP HF XL IU
Strength of playfair cipher
Playfair cipher is a great advance over simple mono alphabetic ciphers. Since there are 26 letters, 26x26 = 676 diagrams are
possible, so identification of individual diagram is more difficult.
SUBSTITUTION TECHNIQUES
■ Hill Cipher
– Another interesting multi letter cipher is the Hill cipher, developed by the
mathematician Lester Hill in 1929. The encryption algorithm takes m successive
plaintext letters and substitutes for them m ciphertext letters. The substitution is
determined by m linear equations in which each character is assigned a numerical
value (a = 0, b = 1 ... z = 25).
– Hence in general the hill cipher can be expressed as
– C= E(K, P) = KP mod 26
– As with Playfair, the strength of the Hill cipher is that it completely hides single-
letter frequencies. Indeed, with Hill, the use of a larger matrix hides more
frequency information. Thus a 3 x 3 Hill cipher hides not only single-letter but also
two-letter frequency information.
– P = D(K, P) = K-1C mod 26 = K-1KP = P
SUBSTITUTION TECHNIQUES
■ Polyalphabetic Ciphers : Vigenere Cipher
– It is like Caesar cipher, but uses a phrase.
– Here, generally, we repeatedly write key above the plaintext and use the Caesar
cipher for each letter in the plaintext where key for each letter being processed is
taken from the repeated key letter just above it.
– This process is simplified by using the table as below called Tableau.
– Assuming key on top and the plaintext on left, Decryption is performed by finding
the position of the ciphertext letter in a column, corresponding to the key letter, of
the table, and then taking the label of the row in which it appears as the plaintext
letter.
– For example, in column V (key letter), the ciphertext letter O appears in row T,
which taken as the first plaintext letter. The second letter is decrypted by looking
up P in column I of the table; it appears in row H, which is taken as the plaintext
letter. This process continues until we find the plaintext letters for all the ciphertext
letters
SUBSTITUTION TECHNIQUES
SUBSTITUTION TECHNIQUES
■ Onetime pad
– It is a variant of a Vigenère cipher with a random key at least as long as the
message.
– Since it has very high key length it is provably unbreakable.
– Joseph Mauborgne proposed this concept. He suggested using a random key that
is as long as the message, so the key need not be repeated.
– In addition, the key is to be used to encrypt and decrypt a single message, and then
is discarded. Each new message requires a new key of the same length as the new
message.
– In One-time pad keys must be random, or we can attack the cipher by trying to
regenerate the key approximations, such as using pseudorandom number
generators to generate keys, are not random.
– This approach produces random output that bears no statistical relationship to the
plaintext. Because the ciphertext contains no information whatsoever about the
plaintext, there is simply no way to break the code.
Transposition Cipher
■ Row Transposition Cipher
– A more complex scheme is to write the message in a rectangle, row by row, and
read the message off, column by column, but permute the order of the columns.
The order of columns then becomes the key of the algorithm.
– plaintext = meet at the school house
Key = 4312567
PT = meetatt
heschoo
lhouse
CT = ESOTCUEEHMHLAHSTOETO
– A pure transposition cipher is easily recognized because it has the same letter
frequencies as the original plaintext.
– The transposition cipher can be made significantly more secure by performing
more than one stage of transposition.
– The result is more complex permutation that is not easily reconstructed.
Transposition Cipher
■ Rail-Fence Cipher
– The Rail Fence Cipher is a form of transposition cipher that derives its name from
the way in which it is encoded.
– In the rail fence cipher, the plaintext is written downwards and diagonally on
successive "rails" of an imaginary fence, then moving up when we reach the
bottom rail.
– When we reach the top rail, the message is written downwards again until the
whole plaintext is written out.
– The message is then read off in rows.
– For example, using 3 "rails" and a message of 'WE ARE DISCOVERED FLEE AT
ONCE', the cipher writes out:
W...E... C... R... L... T... E
. E . R . D. S. O. E . E . F . E .A. O. C .
..A.. . I... V... D... E. .. N. .
– Then reads off: WECRL TEERD SOEEF EAOCA IVDEN
Modern Cipher
Modern Cipher
■ Digital data is represented in strings of binary digits (bits) unlike alphabets. Modern
cryptosystems need to process this binary strings to convert in to another binary string.
Based on how these binary strings are processed, a symmetric encryption schemes can be
classified in to
■ Block Ciphers
– In this scheme, the plain binary text is processed in blocks (groups) of bits at a time;
i.e. a block of plaintext bits is selected, a series of operations is performed on this
block to generate a block of ciphertext bits.
– The number of bits in a block is fixed.
– For example, the schemes DES and AES have block sizes of 64 and 128, respectively.
■ Stream Ciphers
– In this scheme, the plaintext is processed one bit at a time i.e. one bit of plaintext is
taken, and a series of operations is performed on it to generate one bit of ciphertext.
– Technically, stream ciphers are block ciphers with a block size of one bit.
Modern Cipher
■ Though any size of block is acceptable, following aspects are borne in mind while
selecting a size of a block.
■ Avoid very small block size
– Say a block size is m bits. Then the possible plaintext bits combinations are then
2m. If the attacker discovers the plain text blocks corresponding to some previously
sent ciphertext blocks, then the attacker can launch a type of ‘dictionary attack’ by
building up a dictionary of plaintext/ciphertext pairs sent using that encryption
key. A larger block size makes attack harder as the dictionary needs to be larger.
■ Do not have very large block size
– With very large block size, the cipher becomes inefficient to operate. Such
plaintexts will need to be padded before being encrypted.
■ Multiples of 8 bit
– A preferred block size is a multiple of 8 as it is easy for implementation as most
computer processor handle data in multiple of 8 bits.
Modern Cipher
■ Different algorithms have come up with powerful encryption mechanisms incorporated
in them. It gave rise to two new ways of encryption mechanism for data security. These
are:
– Symmetric key encryption
– Asymmetric key encryption
■ Key: It can be a number, word, phrase, or any code that will be used for encrypting as
well as decrypting any ciphertext information to plain text and vice versa.
■ Symmetric and asymmetric key cryptography is based on the number of keys and the
way these keys work
Modern Cipher
■ Symmetric Key Encryption
– Symmetric key encryption technique uses a straight forward method of encryption.
Hence, this is the simpler among these two practices.
– In the case of symmetric key encryption, the encryption is done through only one
secret key which is known as "Symmetric Key" and this key remains to both the
parties.
– The same key is implemented for both encodings as well as decoding the
information.
– So the key is used first by the sender prior to sending the message and on the
receiver side, that key is used to decipher the encoded message.
– One of the good old examples of this encryption technique is Caesar's Cipher.
Modern examples and algorithms that use the concept of symmetric key encryption
are RC4, QUAD, AES, DES, Blowfish, 3DES, etc.
Modern Cipher
■ Asymmetric Key Encryption
– Asymmetric Encryption is another encryption method that uses two keys, which is
a new and sophisticated encryption technique. This is because it integrates two
cryptographic keys for implementing data security.
– These keys are termed as Public Key and Private Key. The "public key", as the
name implies, is accessible to all who wants to send an encrypted message.
– The other is the "private key" that is kept secure by the owner of that public key or
the one who is encrypting.
– Encryption of information is done through public key first, with the help of a
particular algorithm and then the private key, which the receiver possesses, will
use to decrypt that encrypted information.
– The same algorithm will be used in both encodings as well as decoding.
– Examples of asymmetric key encryption algorithms are Diffie-Hellman and RSA
algorithm.
Assignment I (Submission Date:9 Dec, 2019)
■ List and briefly define types of cryptanalytic attacks based on what is known to the attacker.
■ The larger the size of the key space, the more secure is a cipher. Justify your answer.
■ What makes Vigenere cipher more secure than say, the playfair cipher?
■ How monoalphabetic substitution is differ than polyalphabetic. Briefly define with suitable
example.
■ Integrity leads to confidentiality. Explain
■ Construct a play fair matrix with key ‘KEYWORD’. Using the matrix encrypt the message
‘WHY DONOT TOU’.
■ Suppose a key logger program intercepts user password and is used to modify user account. Now,
justify whether it’s a violation of confidentiality, integrity or availability or some combination of
them.
■ Mention the advantage of using stream cipher over block cipher.
■ Encrypt the message ‘NANT’ using the hill cipher with the key ( 4 5 / 6 9). Show your
calculation and the results.
■ What do you mean by reply attacks? Describe with example.
Thank You
End of Unit I
Introduction and Classical Cipher

You might also like