0% found this document useful (0 votes)
16 views50 pages

CompSec 4035 Chapter 3 Lesson 1

Uploaded by

gemeda.gama
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)
16 views50 pages

CompSec 4035 Chapter 3 Lesson 1

Uploaded by

gemeda.gama
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/ 50

Chapter Three

Cryptography and Encryption Techniques


Overview
Cryptography: Meaning
What is Cryptography?
Is the science of writing or reading coded/secret
messages.
Comes from a Greece words/terms
 Cryptos ⇒Secret/hidden
 Graphia ⇒Writing
Together meaning “secret writing”
Is a sequence of mathematical operations used to
generate an alternate form of a data
Is the art and science of devising/creating ciphers/codes
Overview
Cryptography: Terminologies
Plain Text: A message in its natural format readable by
an attacker
• Before a message is put into a coded form.
Ciphertext – Message altered to be unreadable by
anyone except the intended recipients
Encryption/Encyphering: a process of converting
plaintext to ciphertext
Decryption/Decyphering: a process of constructing
plaintext from the ciphertext
Decryption is the inverse of Encryption.
Overview
Cryptography: Terminologies
Cryptography: The study of many schemes used for
encryption and decryption
Cryptanalysis: Techniques used for deciphering a
message without any knowledge of the enciphering
details
Cryptanalysis is the study of "breaking the code."
 Is the flip side of cryptography.
 It is the science of cracking codes, decoding
secrets, and in general, breaking cryptographic
protocols.
Cryptography
Cryptology: The areas of cryptography and cryptanalysis
together are called cryptology.
Encryption algorithm – technique or rules selected for
encryption.
Key: is secret value used to encrypt and/or decrypt the text.
Cryptosystem – The combination of algorithm, key, and
key management functions used to perform cryptographic
operations
A Cryptography/cryptosystem is a 5-tuple (E,D,M,K,C),
where
M: the set of plaintexts
K: the set of keys
C: the set of cipher texts
E: M x K  C —the set of enciphering functions
D: C x K  M —the set of deciphering functions
Cryptography
Cryptography has five ingredients/components :
Plaintext
Encryption algorithm

Secret Key
Ciphertext

Decryption algorithm

Security depends on the secrecy of the key, not the


secrecy of the algorithm
Cryptography
Simplified Encryption Model:
Cryptography
Simplified Encryption Model:
A key can be thought of as simply a collection of bits
The more bits, the stronger the key
Keys are tied to specific encryption algorithms
Lengths vary depending on the encryption algorithm
– e.g. 128 bits is long for some algorithms, but short for others
Three Main Categories
Secret Key
single key is used to encrypt and decrypt information
Public/Private Key
two keys are used: one for encryption (public key) and one for
decryption (private key)
One-way Function
information is encrypted to produce a “digest” of the original
information that can be used later to prove its authenticity
Cryptography
Simplified Encryption Model:
Encryption is the process of taking
some data and a key and feeding it
into a function and getting encrypted
data out
Encrypted data is, in principle,
unreadable unless decrypted

Decryption is the process of taking encrypted


data and a key and feeding it into a function
and getting out the original data
Encryption and decryption functions are
linked
Cryptography
Cryptography: Idea
A sender S wanting to transmit message M to a
receiver R
To protect the message M, the sender first encrypts it
into an unintelligible message M’
After receipt of M’, R decrypts the message to obtain
M
M is called the plaintext
 What we want to encrypt

M’ is called the ciphertext


 The encrypted output
Cryptography
Cryptography …

Mathematical Notation
Given
P=Plaintext
C=Ciphertext

C = EK (P) Encryption
P = DK ( C) Decryption
Cryptography
Services Provided by Cryptography
Guarantees
Confidentiality: provides privacy for messages and
stored data by hiding
Integrity: provides assurance to all parties that a
message remains unchanged
Authenticity: provides the identification of the
originator or
It confirms to the receiver that the data received has
been sent only by an identified and verified sender
Non-repudiation: ensures that an entity cannot refuse
the ownership of a previous commitment or an action
Cryptography

Purpose of Cryptography

Secure stored information - regardless if


access obtained

Secure transmitted information -


regardless if transmission has been
monitored
Cryptography
Historical background- Oldest System
The art of cryptography has been used to code
messages for thousands of years and continues to be
used in bank cards, computer passwords, and
ecommerce.
Steganography is good examples of ancient cryptography.
The word steganography, with origin in Greek, means “covered
writing,” in contrast with cryptography, which means “secret
writing.”
Cryptography means concealing the contents of a message by
enciphering;
steganography means concealing the message itself by covering
it with something else.
Cryptography
Historical background- Oldest System
Cryptography dates as far back as 1900 B.C., - Egypt
 Early Indian texts such as the Kama Sutra used ciphers –
simple alphabetic substitutions often based on phonetics.
 First letter is placed at the end of the word and is followed by
the sound ”ay”.
 Ex: ”try it” (rytay tiay)

Many notable personalities have participated in the


evolution of cryptography.
 Julius Caesar used a simple method of authentication in
government communications called the ”Caesar Cipher”.
 This method shifted each letter two places further in the
alphabet (for example, Y shifts to A, and M shifts to O).
Cryptography
Historical background
These manual methods were easy to crack! So what?
 Crypto Machines exist
 are machines for automatic encryption using a composition
of mixed alphabet substitutions often performed by means of
rotors.

Crypto Machines
 Thomas Jefferson invented a wheel cipher in the 1790s - used
during World War II with slight modification.
 Consisted of a set of wheels, each with random orderings of the
letters of the alphabet.
 In 1844, the development of cryptography was dramatically changed by
the invention of the telegraph.
 Ciphers were needed to transmit secret information over the telegraph.
Cryptography
Historical background
During World War II, most German codes were predominantly
based on the Enigma machine.
 A British cryptanalysis group first broke the Enigma code
early in World War II - first uses of computers!

When does the Modern Crypto started ?


By 1948, cryptographers started to use advanced mathematical
techniques to:
 Calculate ciphers, and
 Prevent computers from unscrambling the ciphers.
Modern encryption algorithms rely on encryption keys to ensure
the confidentiality of encrypted data.
Read all the history by yourself …
Encryption or Cipher Techniques
⇒ Codes Vs Ciphers
Cryptography is split into two ways of changing the
message systematically !
 To confuse anyone who intercepts it
⇒ Codes and Ciphers.
Technically they are different!
Cipher Techniques
⇒ Codes Vs Ciphers
Cipher Techniques
Two building blocks of all classical encryption/Cipher
techniques are substitution and transposition.
Substitution: means replacing an element of the
plaintext with an element of cipher text
 Each element in the plaintext (bit, letter, group of bits
or letters) is mapped into another element
 If the plaintext is viewed as a sequence of bits, then
substitution involves replacing plaintext bit patterns with
ciphertext bit patterns.
Transposition: means rearranging the order of
appearance of the elements of the plaintext.
 Transposition is also referred to as permutation
Cipher Techniques

• The difference between substitution and


transposition is that
• Substitution: each letter retains its
position but changes its identity
• Transposition: each letter retains its
identity but changes its position.
Cipher Techniques
Substitution …
A conventional scheme that replaces elements of the
plain text to get a ciphertext
involves replacing plaintext bit patterns with ciphertext
bit patterns
Examples/Types
Caesar Cipher Hill Cipher(reading )
Modified Caesar Cipher Vigenere cipher
Monoalphabetic Cipher One-time pad (reading)
Playfair Cipher
Polyalphabetic Cypher
Cipher Techniques
Substitution …
Caesar Cipher:
Earliest/oldest known and Simplest
substitution cipher
Used by Julius Ceasar
each character of a message is replaced by a
character three position down in the alphabet.
Note that the alphabet is wrapped around, so
that the letter following Z is A.
Cipher Techniques
Substitution …Caesar Cipher
We can define the transformation by listing all
possibilities, as follows:

Example
 Plaintext: are you ready
Ciphertext: duh brx uhdgb
Cipher Techniques
Substitution …Caesar Cipher
Activity
 Convert it ....to Caesar Ciphertext?
 Plaintext: are you ready

Plaintext ab c d e f g h i j k l mn o p q r s t u v w x y z

Ciphertext 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

 Plaintext: are you ready


Ciphertext: duh brx uhdgb
Cipher Techniques
Substitution…Caesar Cipher
The encryption & decryption algorithm can be
expressed as, for each plaintext letter p, substitute
ciphertext letter C.
C = E( 3, p ) = (p + 3) mod 26
p=D(3, C)= (C-3)mod 26
 Mathematically give each letter a number

 Mod 26 implies that when you reach 26, you use 0


instead (ie the letter after Z, or 25 + 1 goes to A or 0).
Cipher Techniques
Substitution…Caesar Cipher
A more general version of this cipher that allows
for any degree of shift:
C = E( k, p ) = (p + k) mod 26
The formula for decryption would be
p = D( k, C ) = (C - k) mod 26
In these formulas
 ‘k’ is the secret key [0 to 25]. The symbols ’E’ and
’D’ stand for encryption and decryption respectively,
and p and c are characters in the plain and cipher
text respectively.
Cipher Techniques
Substitution…Modified Caesar Cipher
In this version of Caesar cipher, the cipher text
alphabets corresponding to the original plain text
alphabets may not necessarily be three places down
the order, but instead, can be any places down the
order
First we must translate our message into our
numerical alphabet
Choose the number you want to shift by
Then we add the B-shift to each number
Shift-cipher with key =3 is called Caesar Cipher
Cipher Techniques
Substitution…Modified Caesar Cipher
E.g 1. The name 'James' encrypted with a B-shift of
7 is:
o J = 9 + 7 = 16 = Q
o A=0+7=7=H
o M = 12 + 7 = 19 = T
o E = 4 + 7 = 11 = L
o S = 18 + 7 = 25 = Z
o QH T L Z
Cipher Techniques
Substitution…Modified Caesar Cipher
E.g.2. The phrase 'is a spy' using the same B-shift.
 I = 8 + 7 = 15, =>is p
 S = 18 + 7 = 25, =>is Z
 A = 0 + 7 = 7, =>is H
 S = 18 + 7 = 25, => is Z
 P = 15 + 7 = 22, => is W
 Y = 24 + 7 = 31=> Use mod 26, Since, 31 mod 26 = 5,
which corresponds to F
So “is a spy” = PZHZWF
Exercise
Encrypt the message: “ we shall meet tonight” using
key value f
Cryptography
Substitution… Caesar Cipher
Problems/Cons
Brute force attack is easily carried out
Limited key size(only 25 keys to try)
You can all the 25 possibilities
Language is known and
recognizable
Algorithm is known
Cryptography
Substitution… Caesar Cipher
Problems/Cons

Exercise break the cyphertext “m lexi xlmw gpeww”


Cipher Techniques
Substitution …
Monoalphabetic Cipher:
Rather than just shifting the alphabet could shuffle
(jumble) the letters arbitrarily/randomly each plaintext
letter maps to a different random ciphertext letter.
Hence, key is 26 letters long
The cipher line can be any permutation of the 26
alphabetic characters
This would seem to eliminate Brute force technique
for cryptanalysis
A single cipher alphabet (mapping from plain
alphabet to cipher alphabet) is used per message.
Cipher Techniques
Substitution …Monoalphabetic Cipher

Monoalphabetic Cipher:
Examples
 Plain: abcdefghijklmnopqrstuvwxyz
 Cipher:
DKVQFIBJWPESCXHTMYAUOLRGZN
 Plaintext: ifwewishtoreplaceletters
 Ciphertext:WIRFRWAJUHYFTSDVFSFUU
FYA
Cipher Techniques
Substitution …Monoalphabetic Cipher

Monoalphabetic Cipher:
Cipher Techniques
Substitution …
Playfair Cipher:
Aka Playfair square or Wheatstone- Playfair Cipher
The best-known multiple-letter encryption cipher
It was the first literal digraph/digram substitution
cipher.
The scheme was invented in 1854 by Charles
Wheatstone,
 but bears the name of Lord Playfair who promoted
the use of the cipher.
 Used in WWI and WWII
It used a 5 x 5 matrix constructed using a keyword
Cipher Techniques
Substitution …
Playfair Key Matrix
The Playfair algorithm is based on the use of a 5x5
matrix of letters constructed using a keyword.
a 5X5 matrix of letters based on a keyword
fill in letters of keyword (no duplicates, i & j used as a single
letter.)
E g. using the keyword (key) simple s i/j m p l
e a b c d
f g h k n
o q r t u
v w x y z
Cipher Techniques
Substitution …
Playfair Cipher rule
First, a plaintext message is split into pairs of two letters
(digraphs) or digrams.
If there is an odd number of letters, a “z or x” is added to
the last letter.
Let us say we want to encrypt the message “hide
money”.
It will be written as −
HI DE MO NE YZ
Use filler letter to separate repeated letters
eg. "balloon" encrypts as "ba lx lo on" Encrypt two
letters together
Cipher Techniques
Substitution …
Playfair Cipher rule
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).
ac--bd
If both the letters are in the same column: Take the letter
below each one (going back to the top if at the bottom).
gk--hn
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.
Cipher Techniques
Substitution …Playfair Cipher- Example
Eg. Keyword. Now write Then finish filling up the
the letters keyword in the remaining squares of the matrix
first squares of a five by with the remaining letters of the
five matrix: alphabet, in alphabetical order

For example, the sentence “Why, don’t you?” becomes


WH YD ON TY OU
Ciphertext :YI EA ES VK EZ
Cipher Techniques
Substitution …Playfair Cipher- Exercise
Q: construct the playfair matrix using the keyword
MONARCHY ?
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z

Plaintext: Ethiopia
Ciphertext: klbfhvsb
Would you pleas tray this: “instruments” with the above
keyword
Cipher Techniques
Substitution… Polyalphabetic ciphers
Another way to improve on the simple monoalphabetic
technique is to use different monoalphabetic
substitutions as one proceeds through the plaintext
message.
The general name for this approach is polyalphabetic
substitution cipher.
All these techniques have the following common
features :
A set of related Monoalphabetic substitution rules is
used.
A key determines which particular rule is chosen for
a given transformation.
Cipher Techniques
Substitution… Vigenere Cypher
The best known, and one of the simplest, such
algorithm is referred to as the Vigenère cipher.
In this scheme, the set of related
monoalphabetic substitution rules consists of
the 26 Caesar ciphers, with shifts of 0 through
25.
Vigenere Cipher is a method of encrypting
alphabetic text.
It uses a simple form of polyalphabetic
substitution.
Cipher Techniques
Substitution… Vigenere Cypher
The Vigenere Table consists of the alphabets
written out 26 times in different rows, each
alphabet shifted cyclically to the left compared
to the previous alphabet, corresponding to the 26
possible Caesar Ciphers.
At different points in the encryption process, the
cipher uses a different alphabet from one of the
rows.
The alphabet used at each point depends on a
repeating keyword.
Vigenere Table
The Vigenère cipher uses a 26×26 table with A to Z as the row heading and column
heading
This table is usually referred to as the Vigenère Tableau, Vigenère Table or Vigenère
Square.
We shall use Vigenère Table. The first row of this table has the 26 English letters.
Starting with the second row, each row has the letters shifted to the left one position in a
cyclic way.
Plaintext
Key
Cipher Techniques
Substitution… Vigenere Cypher working rule
Use the Vigenere Table to encrypt
Write the plaintext out
Key must be as long as the plaintext
Write your keyword across the top/bottom of the text
you want to encipher
For each p, look at the letter of the key above it and
find that row in the Vigenere table
Find the column of p and trace down until we reach
the row we found before
Finally, take the value at the intersection
Cipher Techniques
Substitution… Vigenere Cypher working rule
Cipher Techniques
Substitution… Vigenere Cypher
Example
M= attack shall start tonight (plaintext)
K= secret
C=E(K, M)= sxvrgdklccplletkxhfmiyx
To decipher back to M
Key identifies row
Cipher shows which column to look for
P is the top value in that column of the row
Cipher Techniques
Transposition Cipher
All the techniques examined so far involve the substitution of a
ciphertext 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
Ciphertext mapping is achieved by performing or applying some
sort of permutation on the plaintext letters
 Positions held by units of plaintext (which are commonly
characters or groups of characters) are shifted according to a
regular system
 Can be single or double transposition
Cipher Techniques
Transposition Cipher – Next class

You might also like