Network Security Essentials
Chapter 2
Fourth Edition
by William Stallings
Terms used
• An original message is known as the plaintext.
• The coded message is called the ciphertext.
• The process of converting from plaintext to ciphertext is
known as enciphering or encryption;
• Restoring the plaintext from the ciphertext is deciphering
or decryption.
• The area of study of encryption is known as cryptography.
• Techniques used for deciphering a message without any
knowledge of the encryption details is known as
cryptanalysis breaking the code.”
• The areas of study of cryptography and cryptanalysis
together is known as cryptology.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Categorization of Cryptographic system
along three independent dimensions
1. The type of encryption operations used
2. Number of keys used
3. The way in which plaintext is processed
Dr. Benita Jaison, MCA Dept., St. Francis College.
Categorization of Cryptographic system
along three independent dimensions
Cryptographic systems can be characterized along these three independent
dimensions.
1. The type of operations used for transforming plaintext to ciphertext. All
encryption algorithms are based on two general principles: substitution, in which
each element in the plaintext is mapped into another element, and transposition,
in which elements in the plaintext are rearranged. The fundamental requirement
is that no information be lost. Most systems, referred to as product systems,
involve multiple stages of substitutions and transpositions.
2. The number of keys used. If both sender and receiver use the same key, the
system is referred to as symmetric, single-key, secret-key, or conventional
encryption. If the sender and receiver use different keys, the system is referred to
as asymmetric, two-key, or public-key encryption.
3. The way in which the plaintext is processed. A block cipher processes the
input one block of elements at a time, producing an output block for each input
block. A stream cipher processes the input elements continuously, producing
output one element at a time, as it goes along.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Type of encryption operations used
Two general principles of encryption
algorithm.
• Substitution : each element in the plaintext
is mapped into another element,
• Transposition : each elements in the
plaintext are rearranged.
Each encryption systems, may involve
multiple stages of substitutions and
transpositions. Dr. Benita Jaison, MCA Dept., St. Francis College.
Number of keys used
• If sender and receiver use the same key,
the system referred as symmetric
encryption, single-key or private
• If sender and receiver uses different keys,
the system referred as asymmetric
encryption, two-key or public.
Dr. Benita Jaison, MCA Dept., St. Francis College.
How plaintext is processed
• A block cipher processes the input one
block of elements at a time, producing an
output block for each input block. (plaintext
considered as blocks of data(128 bit,64 bit)
• A stream cipher processes the input
elements continuously, producing output
one element at a time . (plaintext is considered
as a stream of data, each bit effected by a key)
Dr. Benita Jaison, MCA Dept., St. Francis College.
Symmetric Encryption
• Symmetric Encryption is the conventional
encryption method
• Make use of a single-key or a private-key
• Sender and recipient share a single private key
• All classical encryption algorithms are
Symmetric Encryption using a private-key
• Was the only type prior to the invention of
public-key in 1970’s
• It is most widely used method
Dr. Benita Jaison, MCA Dept., St. Francis College.
Symmetric Cipher Model
Dr. Benita Jaison, MCA Dept., St. Francis College.
5 Ingredients for Cipher Model
• Plaintext - original message to be encrypted given as input.
• Ciphertext – encrypted or scrambled unreadable message
produced as output.
• Encryption algorithm- algorithm used for transforming or
substituting the plaintext to ciphertext .
• Secret key – The secret key is also input to the encryption
algorithm. The key is a value independent of the plaintext and
of the algorithm.The key or info used in cipher for encryption
is known only to sender/receiver.
• Decryption algorithm - recovering ciphertext from plaintext
by using the secret key . It is encryption algorithm in reverse
way.
Dr. Benita Jaison, MCA Dept., St. Francis College.
2 Requirements for secure use of symmetric
encryption:
– a strong encryption algorithm such that the
opponent should be unable to decrypt ciphertext or
discover the key even if he or she is in possession of
a number of ciphertext.
• Two things has to be considered
– The information should not be lost
– The process should be reversible
– a secret key known only to sender / receiver.
Receiver should receive it in a secure fashion.
Need not keep the algorithm as secret; the principal
security problem is maintaining the secrecy of the
key. Dr. Benita Jaison, MCA Dept., St. Francis College.
Model of Symmetric Cryptosystem
Dr. Benita Jaison, MCA Dept., St. Francis College.
Model of Symmetric Cryptosystem
• a message in plaintext X= [X1,X2,…. ,XM]
• For encryption, a key of the form K= [K1,K2,...,KJ] is
generated. Key provided to the destination by means
of some secured channel or a third party could
generate the key and securely deliver it to both source
and destination.
• With the message and the encryption key as input, the
encryption algorithm forms the ciphertext Y=
[Y1,Y2,....,YN]
• mathematically have:
Y = E(K, X)
X = D(K, Y)
Dr. Benita Jaison, MCA Dept., St. Francis College.
Cryptanalysis
• Techniques used for deciphering a message
without any knowledge of the encryption
details is known as cryptanalysis breaking the
code.”
– If the opponent is interested in only a particular
message, then the focus of the effort is to recover
X by generating a plaintext estimate X^. (Y = E(K,
X))
– If the opponent is interested in being able to read
future messages an attempt is made to recover to
recover Key, K by generating an estimate K^.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Cryptanalysis
• The objective is to recover the key in use
rather then simply to recover the plaintext
of a single ciphertext.
• 2 general approaches:
– Cryptanalytic attack :Relies on the nature of the
algorithm plus some knowledge of the general
characteristics of the plaintext or even some sample
plaintext- ciphertext pairs.
– Brute-force attack : Try every possible key on a
piece of ciphertext until an intelligible translation into
plaintext is obtained.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Cryptanalytic Attacks
➢ciphertext only
⚫only know algorithm & ciphertext
➢known plaintext
⚫know/suspect plaintext & ciphertext
➢chosen plaintext
⚫select plaintext and obtain ciphertext
➢chosen ciphertext
⚫select ciphertext and obtain plaintext
➢chosen text
⚫select plaintext or ciphertext to en/decrypt
Dr. Benita Jaison, MCA Dept., St. Francis College.
Types of Attacks on Encrypted
Messages
Dr. Benita Jaison, MCA Dept., St. Francis College.
The attacker gains access to a collection of ciphertext. But the attacker cannot access
the plaintext. Dr. Benita Jaison, MCA Dept., St. Francis College.
The cybercriminal finds or knows the plaintext of some portions of the ciphertext using
information gathering techniques Dr. Benita Jaison, MCA Dept., St. Francis College.
The cybercriminal can choose arbitrary plaintext data to obtain the ciphertext
Dr. Benita Jaison, MCA Dept., St. Francis College.
The cybercriminal analyzes a chosen ciphertext and relating it to the plaintext, the attacker
attempts to guess the key. Dr. Benita Jaison, MCA Dept., St. Francis College.
Brute Force Search
• A brute-force attack involves trying every possible key
until an intelligible translation of the ciphertext into
plaintext is obtained.
• Half of all possible keys must be tried to achieve
success.
µs-microsecond --one millionth of a second, 10-6 seconds.
Key Size (bits) Number of Alternative Time required at 1 Time required at 106
Keys decryption/µs decryptions/µs
32 232 = 4.3 109 231 µs = 35.8 minutes 2.15 milliseconds
56 256 = 7.2 1016 255 µs = 1142 years 10.01 hours
128 2128 = 3.4 1038 2127 µs = 5.4 1024 years 5.4 1018 years
168 2168 = 3.7 1050 2167 µs = 5.9 1036 years 5.9 1030 years
26 characters 26! = 4 1026 2 1026 µs = 6.4 1012 years 6.4 106 years
(permutation)
Dr. Benita Jaison, MCA Dept., St. Francis College.
• An encryption scheme: computationally
secure if
– The cost of breaking the cipher exceeds the value
of information
– The time required to break the cipher exceeds the
lifetime of information
Dr. Benita Jaison, MCA Dept., St. Francis College.
Classical Encryption Techniques
• The two basic building blocks of all encryption
technique are substitution and transposition.
• Substitution : substitution involves replacing
plaintext bit patterns with ciphertext bit
patterns which can be (letters or numbers or
symbols ).
• Transposition : hide the message by
rearranging the letter order without altering
the actual letters used.
24
Dr. Benita Jaison, MCA Dept., St. Francis College.
Examples
Classic Substitution Ciphers
– Ceaser Cipher
– Monoalphabetic Ciphers
– Multiple letter cipher
• Playfair Cipher
– Polyalphabetic Ciphers
• Vigenère cipher
• One-Time Pad
Classic Transposition Ciphers
– Rail fence technique
– Row Transposition Ciphers
25
Dr. Benita Jaison, MCA Dept., St. Francis College.
Caesar Cipher
• Plaintext characters are substituted by a
different alphabet stream of characters shifted
to the right or left by n positions.
• It is the earliest known substitution cipher
started by Julius Caesar
• If the key k=3,replace each letter by 3rd letter.
• eg:
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
26
Dr. Benita Jaison, MCA Dept., St. Francis College.
Caesar Cipher
• Key k=3,replace each letter by 3rd letter on:
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
• Mathematically give each letter a number
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
• Caesar cipher is calculated as as:
c = E(p) = (p + k) mod (26)
p = D(c) = (c – k) mod (26)
27
Dr. Benita Jaison, MCA Dept., St. Francis College.
Example for Caesar Cipher
• Caesar cipher is calculated as:
c = E(p) = (p + k) mod (26)
p = D(c) = (c – k) mod (26)
Eg: howdy (7,14,22,3,24) encrypted using key k=5 (ie a
shift of 5) is MTBID
28
Dr. Benita Jaison, MCA Dept., St. Francis College.
Cryptanalysis of Caesar Cipher
Characteristics of Caesar Cipher that ease brute force cryptanalysis.
1. The encryption and decryption algorithms are known.
2. There are only 25 keys to try.
3. The language of the plaintext is known and easily recognizable
29
Dr. Benita Jaison, MCA Dept., St. Francis College.
Monoalphabetic Ciphers-Variation of
Caesar cipher
• Caesar ciphers are vulnerable to cryptanalysis attack
• The shift pattern above could be replaced by random
assignment of characters for each alphabet
• An increase in the key size can be achieved by permutation
of the 26 alphabetic characters.
• Each plaintext letter maps to a different random ciphertext
letter ,thus each key is 26 letters long .
• This would also give 26! Possibilities
30
Dr. Benita Jaison, MCA Dept., St. Francis College.
a bc d e f g h I j k l m n o p q r s t u v w x y z
p m j s q o l e y t v u a x I k c g b w d r n h zf
Dr. Benita Jaison, MCA Dept., St. Francis College.
Monoalphabetic Ciphers-Variation of
Caesar cipher
• A permutation of a finite set of elements is an ordered
sequence of all the elements, each element appearing
exactly once. Eg:if S = {a, b, c} there are six permutations of
:abc, acb, bac, bca, cab, cba
• The “cipher” line can be any permutation of the 26
alphabetic characters,then there are 26! or greater than 4 X
10 26 possible keys.
32
Dr. Benita Jaison, MCA Dept., St. Francis College.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Language Redundancy and Cryptanalysis
• Human languages are redundant and hence it is easy
for cryptanalyst to easily make out the plaintext by
understanding their frequency.
– eg "th lrd s m shphrd shll nt wnt"
• In English E is by far the most common letter
– followed by T,R,N,I,O,A,S
• Other letters like Z,J,K,Q,X are rarely used.
• Have tables of single, double & triple letter frequencies
for various languages
34
Dr. Benita Jaison, MCA Dept., St. Francis College.
English Letter Frequencies
35
Dr. Benita Jaison, MCA Dept., St. Francis College.
36
Dr. Benita Jaison, MCA Dept., St. Francis College.
Multiple Letter Cipher
• Monoalphabetic ciphers are easy to break
because they reflect the frequency data of the
original plaintext.
• A countermeasure is to provide multiple
substitutes, known as homophones, for a single
letter.
37
Dr. Benita Jaison, MCA Dept., St. Francis College.
Multiple Letter Cipher
• Playfair cipher is a multiple letter cipher.
• The plaintext is split into pairs of two letters (digrams).
• Each plaintext letter is replaced by a digram in this
cipher
• User chooses a keyword and puts it in the cells of a 5 x 5
matrix. I and J stay in one cell. Duplicate letters appear
only once.
• Alphabets that are not in the keyword are arranged in
the remaining cells from left to right in successive rows
in ascending order
38
Dr. Benita Jaison, MCA Dept., St. Francis College.
Playfair Cipher- Encryption Rules
1. If both the letters are in the same column: Take the letter below
each one (going back to the top if at the bottom).
• Diagraph: "me"
• Encrypted Text: cl
2. If both the letters are in the same row: Take the letter to the right
of each one (going back to the leftmost if at the rightmost position).
• Diagraph: "st"
• Encrypted Text: tl
39
Dr. Benita Jaison, MCA Dept., St. Francis College.
Playfair Cipher- Encryption Rules
3. If neither of the above rules is true: Form a rectangle with the two
letters and take the letters on the horizontal opposite corner of the
rectangle.
– Diagraph: "nt"
– Encrypted Text: rq
40
Dr. Benita Jaison, MCA Dept., St. Francis College.
Playfair Cipher- Decryption Rules
1. The receiver has the same key and can create the same
key table
2. Generate the key Square(5×5) at the receiver’s end.
3. The ciphertext is split into pairs of two letters
(digraphs).
4. If both the letters are in the same column: Take the
letter above each one (going back to the bottom if at
the top).
– Diagraph: "cl"
– Decrypted Text: me
41
Dr. Benita Jaison, MCA Dept., St. Francis College.
Playfair Cipher- Decryption Rules
5. If both the letters are in the same row: Take the letter to the left
of each one (going back to the rightmost if at the leftmost position).
– Diagraph: "tl"
– Decrypted Text: st
6. If neither of the above rules is true: Form a rectangle with the two
letters and take the letters on the horizontal opposite corner of the
rectangle.
Diagraph: "rq"
Decrypted Text: nt
42
Dr. Benita Jaison, MCA Dept., St. Francis College.
Playfair Cipher
• MONARCHY is the
keyword.
• ar is encrypted as RM.
• mu is encrypted as CM.
• hs becomes BP and ea
becomes IM.
43
Dr. Benita Jaison, MCA Dept., St. Francis College.
Playfair Cipher
• E.g., Plaintext: “CRYPTO IS TOO EASY”
• Keyword is “INFOSEC”
• Grouped text: CR YP TO IS TO XO EA SY
• Ciphertext: AQ VT YB NI YB YF CB OZ
• To decrypt, the receiver reconstructs the 5 x 5
matrix using the keyword and then uses the same
rules as for encryption
44
Dr. Benita Jaison, MCA Dept., St. Francis College.
Polyalphabetic Cipher
• To improve on the simple monoalphabetic technique
is to use different monoalphabetic substitutions as
one proceeds through the plaintext message known
as polyalphabetic cipher.
1. A set of related monoalphabetic substitution rules is
used.
2. A key determines which particular rule is chosen for a
given transformation.
45
Dr. Benita Jaison, MCA Dept., St. Francis College.
Polyalphabetic Cipher- Vigenère cipher
• The most common method used is Vigenère
cipher
• Vigenère cipher starts with a 26 x 26 matrix of
alphabets in sequence. First row starts with
‘A’, second row starts with ‘B’, etc.
• Vigenere cipher requires a keyword that the
sender and receiver know.
• The same plaintext character is substituted by
different ciphertext characters (i.e.,
polyalphabetic)
46
Dr. Benita Jaison, MCA Dept., St. Francis College.
Vigenère cipher -Encryption
• To encrypt, each character of the message is combined
with the characters of the keyword to find the ciphertext
character.
• The given keyword is repeated in a circular manner until
it matches the length of the plain text.
• Using the table, The first letter of the plaintext, is paired
with the first letter of the key. Use this row and column
of the Vigenère square to get the ciphertext character.
• To decrypt, the receiver places the keyword characters
below each ciphertext character
• The first letter of the key, is paired with the first letter of
the plaintext. Use this row and column of the Vigenère
square to get the plaintext letter. 47
Dr. Benita Jaison, MCA Dept., St. Francis College.
Vigenère Cipher Table
Message = SEE ME IN MA
Take keyword as INFOSEC
Vigenère cipher works as foll
S E EMEINMALL
I N F O S EC I N F O
------------------------------------
A RJ AWMPUNQZ
ARJAWMPUNQZ
INFOS ECI NFO
------------------------------------
SEEME I NMALL
Dr. Benita Jaison, MCA Dept., St. Francis College.
Vigenère Cipher
• Easiest way to handle Vigenère cipher is to use
arithmetic modulo 26(no table required).
• Keyword is converted to numbers and
corresponding numbers in message and the
keyword are added modulo 26.
• In Vigenère cipher a set of related
monoalphabetic substitution rules consists of the
26 Caesar ciphers with shifts of 0 through 25.
49
Dr. Benita Jaison, MCA Dept., St. Francis College.
Example of Vigenère Cipher
• write the plaintext
• write the key repeatedly above it
• use each key letter as a caesar cipher key
• encrypt the corresponding plaintext letter
Ci=(Pi+Ki)mod 26
Pi=(Ci-Ki)mod 26
50
Dr. Benita Jaison, MCA Dept., St. Francis College.
Example of Vigenère Cipher
eg : Encrypt using keyword deceptive
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Ci=(Pi+Ki)mod 26
Pi=(Ci-Ki)mod 26
51
Dr. Benita Jaison, MCA Dept., St. Francis College.
Security of Vigenère Ciphers
• Each plaintext letter have multiple ciphertext
letters, hence letter frequencies is not easy to
determine.
52
Dr. Benita Jaison, MCA Dept., St. Francis College.
Vernam Cipher
• In Vernam Cipher a keyword is chosen such
that it is as long as the plaintext and has no
statistical relationship to it.
• The system is represented as:
Dr. Benita Jaison, MCA Dept., St. Francis College.
Encryption Algorithm
• Assign a number to each character of the plain
text and the key according to alphabetical
order.
• Bitwise XOR both the number (Corresponding
plain-text character number and Key character
number).
• If ciphertext value is greater than 26 or equal to
26, find mod with 26.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Vernam Cipher
Dr. Benita Jaison, MCA Dept., St. Francis College.
• Plain-Text: O A K
• Key: S O N
O ==> 14 = 0 1 1 1 0
S ==> 18 = 1 0 0 1 0
• Bitwise XOR Result: 1 1 1 0 0 = 28
• 28 mod 26 = 2 ==> C
• CIPHER-TEXT: C
Dr. Benita Jaison, MCA Dept., St. Francis College.
Transposition cipher
• Transposition cipher involves a rearranging the
letter order without altering the actual letters
used.
• It makes use of some kind of permutation
function.
• Types of transposition cipher techniques
– Rail Fence Transposition Cipher
– Simple Columnar Transposition Cipher – Route
Cipher
– Columnar Transposition Cipher
Dr. Benita Jaison, MCA Dept., St. Francis College.
Rail Fence Transposition cipher
• The rail fence (zigzag) cipher involves the
plaintext written down as a sequence of
diagonals and then read off as a sequence of
rows.
• NOTHING IS AS IT SEEMS
• NTIGS STEMO HNIAI SES
Dr. Benita Jaison, MCA Dept., St. Francis College.
Columnar Transposition- Route Cipher
• Columnar Transposition involves writing the
plaintext out in rows, and then reading the
ciphertext in columns.
• Simple method :Route Cipher - read down each
column in order.
– Eg: The plaintext "a simple transposition" with 5
columns. 20 letters
The ciphertext "ALNISESTITPIMROOPASN".
Dr. Benita Jaison, MCA Dept., St. Francis College.
Columnar Transposition- Route Cipher
• The number of columns is the key information.
• To encipher: Plaintext is written horizontally in k
columns, and is then transcribed vertically
column by-column.
• To decipher: if the length of the ciphertext is n
and the key is k. Then the letters will fill n/k full
rows, and there will be one partial row at the end
with n mod k letters.
• Transcribing row-by-row will then yield the
plaintext.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Columnar Transposition Ciphers
• Select a keyword for our encryption.
• Write the plaintext out in a grid where the number of
columns is the number of letters in the keyword.
• Title each column with the respective letter from the
keyword.
• Number the letters in the keyword in alphabetical
order, and read down the columns in this order. If a
letter is repeated, one that appears first, then the next
and so on.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Columnar Transposition Ciphers
Plain text : The tomato is a plant in the nightshade family”
38 letter
Cipher text : TINES AXEOA HTFXH TLTHE YMAII AIXTA PNGDL
OSTNH MX
Dr. Benita Jaison, MCA Dept., St. Francis College.
Steganography
• Steganography is the art and science of writing hidden
messages.
• The methods of steganography conceal the existence of
the message.
• Steganography is derived from the Greek word steganos,
meaning "hidden or covered," and the graph, meaning "to
write."
• Traditional methods used:
– Character marking
– Invisible ink
– Pin punctures
– Typewriter correction ribbon
– Using the least significant bits of frames on a CD.
Dr. Benita Jaison, MCA Dept., St. Francis College.
Image Steganography
• Image Steganography refers to the process of hiding data
within an image file.
• The image selected for this purpose is called the cover
image and the image obtained after steganography is
called the stego image.
– Message is embedded into an image by altering the values of
some pixels, which are chosen by an encryption algorithm.
– The recipient of the image must be aware of the same algorithm
in order to know which pixels must be selected to extract the
message.
Dr. Benita Jaison, MCA Dept., St. Francis College.