0% found this document useful (0 votes)
29 views

Lecture 3.3

The document provides an introduction to cryptography. It defines cryptography as the art and science of concealing meaning and discusses how it addresses security issues like blocking, interception, modification and fabrication of messages. It describes basic cryptography concepts like plaintext, ciphertext, encryption, decryption and keys. It also covers different categories of traditional ciphers like substitution ciphers (Caesar and monoalphabetic ciphers) and transposition ciphers. Polyalphabetic ciphers like the Vigenère cipher are also introduced.

Uploaded by

King Of Luck
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Lecture 3.3

The document provides an introduction to cryptography. It defines cryptography as the art and science of concealing meaning and discusses how it addresses security issues like blocking, interception, modification and fabrication of messages. It describes basic cryptography concepts like plaintext, ciphertext, encryption, decryption and keys. It also covers different categories of traditional ciphers like substitution ciphers (Caesar and monoalphabetic ciphers) and transposition ciphers. Polyalphabetic ciphers like the Vigenère cipher are also introduced.

Uploaded by

King Of Luck
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Introduction to Cryptography

(Module-3.B)
Course Code: 20B12CS332

Dr. Charu Gandhi


Cryptography
• Cryptography is the art and science of concealing
meaning.
• Two Greek words meaning "secret writing" also
known as encryption.
• A transformation which makes data difficult for an
outsider to interpret.
• Well-disguised data made difficult to be read,
modified, or fabricated.
• Cryptography conceals data against unauthorized
access.
• Cryptanalysis is the breaking of codes.
• Cryptology: Cryptography+Cryptanalysis
Message attacks
A message sent from sender to a receiver through a transmission medium
can be attacked by an outsider in following ways:

• Blocking: Preventing its reach the receiver , affecting the availability of


the message

• Interception : Reading or listening to the message, affecting the


confidentiality of the message

• Modification :Seizing the message and changing it in some way, affecting


the message’s integrity

• Fabrication: Sending an authentic-looking message and arranging for it to


be delivered as if it came from Sender, affecting the integrity of the
message

Encryption is a technique that can address all these problems. It is a means of


maintaining secure data in an insecure environment.
Terminology

• Plaintext: The original form of a message is known as


plaintext.
• Key: A random data.
• Encryption: The process of encoding a message so that
its meaning is not obvious.
• Ciphertext: The encrypted form of plaintext.
• Decryption: The reverse process, transforming an
encrypted message back into its normal, original form.
Categories of Traditional Ciphers

• Substitution:
– A substitution cipher replaces one symbol with
another. Substitution ciphers can be categorized
as either monoalphabetic ciphers or
polyalphabetic ciphers.
• Transposition:
– A transposition cipher does not substitute one
symbol for another, instead it changes the
location of the symbols.
Substitution Cipher
The following shows a plaintext and its corresponding
ciphertext. The cipher is probably monoalphabetic because both
l’s (els) are encrypted as O’s.

The following shows a plaintext and its corresponding


ciphertext. The cipher is not monoalphabetic because each l
(el) is encrypted by a different character. The Cipher is
polyalphabetic.
Caesar Cipher
• Earliest known substitution cipher
• Invented by Julius Caesar
• Each letter is replaced by the letter three positions
further down the alphabet.
• Plain: 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
Cipher: 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
• Example: ohio state RKLR VWDWH

7
Caesar Cipher
• Mathematically, map letters to numbers:
a, b, c, ..., x, y, z
0, 1, 2, ..., 23, 24, 25
• The general Caesar cipher is:
c = EK(p) = (p + k) mod 26
p = DK(c) = (c – k) mod 26
• Can be generalized with any alphabet.

8
Cryptanalysis of Caesar Cipher
• Key space is very small: {0, 1, ..., 25}
• Vulnerable to brute-force attacks.
• Exhaustive search
– If the key space is small enough, try all possible keys until you
find the right one
– Caesar cipher has 26 possible keys
– Statistical frequencies not concealed well
• They look too much like regular English letters
• Statistical Attack
– Compute frequency of each letter in cipher text
– Apply 1-gram model of English, which presents the frequency of
letters in the English
– Using statistical analysis, the correlation between the two is
calculated to find the probable key. 9
Monoalphabetic Substitution Cipher
• Shuffle the letters and map each plaintext letter to a
different random ciphertext letter:
Plain letters: abcdefghijklmnopqrstuvwxyz
Cipher letters: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA

10
Monoalphabetic Cipher Security
• Now we have a total of 26! = 4 x 1026 keys.
• With so many keys, it is secure against
brute-force attacks.
• But not secure against some cryptanalytic
attacks.
• Problem is language characteristics.

11
Language Statistics and Cryptanalysis
• Human languages are not random.
• Letters are not equally frequently used.
• 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 fairly rare.
• There are tables of single, double & triple letter
frequencies for various languages
• In decreasing order of frequency
Double letters:
th he an in er re es on, …
Triple letters:
the and ent ion tio for nde, …
12
English Letter Frequencies

13
Use in Cryptanalysis
• Key concept: monoalphabetic substitution does not
change relative letter frequencies
• To attack,
• calculate letter frequencies for ciphertext
compare this distribution against the known one

14
Example Cryptanalysis
• Given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
• Count relative letter frequencies ( next slide)
• Guess {P, Z} = {e, t}
• Of double letters, ZW has highest frequency, so
guess ZW = th and hence ZWP = the
• Proceeding with trial and error finally get:
it was disclosed yesterday that several informal but
direct contacts have been made with political
representatives of the viet cong in moscow

15
Letter frequencies in ciphertext
P 13.33 H 5.83 F 3.33 B 1.67 C 0.00
Z 11.67 D 5.00 W 3.33 G 1.67 K 0.00
S 8.33 E 5.00 Q 2.50 Y 1.67 L 0.00
U 8.33 V 4.17 T 2.50 I 0.83 N 0.00
O 7.50 X 4.17 A 1.67 J 0.83 R 0.00
M 6.67

16
Playfair Cipher
• Not even the large number of keys in a

monoalphabetic cipher provides security.
• One approach to improving security is to
encrypt multiple letters at a time.
• The Playfair Cipher is the best known such
cipher.
• Invented by Charles Wheatstone in 1854, but
named after his friend Baron Playfair.

17
Playfair Key Matrix
• Use a 5 x 5 matrix.
• Fill in letters of the key (w/o duplicates).
• Fill the rest of matrix with other letters.
• E.g., key = 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
18
Encrypting and Decrypting

Plaintext is encrypted two letters at a time:


1. if a pair is a repeated letter, insert a filler like 'X', eg.
"balloon" encrypts as "ba lx lo on"
2. if both letters fall in the same row, replace each with letter
to right (wrapping back to start from end), eg. “ar"
encrypts as "RM"
3. if both letters fall in the same column, replace each with
the letter below it (again wrapping to top from bottom),
eg. “mu" encrypts to "CM"
4. otherwise each letter is replaced by the one in its row in
the column of the other letter of the pair, eg. “hs" encrypts
to "BP", and “ea" to "IM" or "JM" (as desired)

19
Security of Playfair Cipher
• Equivalent to a monoalphabetic cipher with an
alphabet of 26 x 26 = 676 characters.
• Security is much improved over the simple
monoalphabetic cipher.

• Once thought to be unbreakable.


• Actually, it can be broken, because it still leaves
some structure of plaintext intact.

20
Polyalphabetic Substitution Ciphers
• A sequence of monoalphabetic ciphers (M1, M2, M3,
..., Mk) is used in turn to encrypt letters.
• A key determines which sequence of ciphers to use.
• Each plaintext letter has multiple corresponding
ciphertext letters.
• This makes cryptanalysis harder since the letter
frequency distribution will be flatter.

21
Vigenère Cipher
• Simplest polyalphabetic substitution cipher
• Consider the set of all Caesar ciphers:
{ Ca, Cb, Cc, ..., Cz }
• Key: e.g. security
• Encrypt each letter using Cs, Ce, Cc, Cu, Cr, Ci, Ct,
Cy in turn.
• Repeat from start after Cy.
• Decryption simply works in reverse.

22
Vigènere Cipher
• Example
– Message THE BOY HAS THE BALL
– Key VIG
– Encipher using Caesar cipher for each letter:
key VIGVIGVIGVIGVIGV
plain THEBOYHASTHEBALL
cipher OPKWWECIYOPKWIRG

23
Tableau
Key phrase characters select
column

• | 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
•-------------------------------------------------------
•A | 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
•B | 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 a
•C | c 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
•D | 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
•E | 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 d
•…
•Q | q r s t u v w x y z a b c d e f g h i j k l m n o p
Plaintex •R | r s t u v w x y z a b c d e f g h i j k l m n o p q
•S | s t u v w x y z a b c d e f g h i j k l m n o p q r
characters •T | t u v w x y z a b c d e f g h i j k l m n o p q r s
select row •U | u v w x y z a b c d e f g h i j k l m n o p q r s t
•V | v w x y z a b c d e f g h i j k l m n o p q r s t u
•W | w x y z a b c d e f g h i j k l m n o p q r s t u v
•X | x y z a b c d e f g h i j k l m n o p q r s t u v w
•Y | y z a b c d e f g h i j k l m n o p q r s t u v w x
•Z | z 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

24
Relevant Parts of Tableau for example
• Only need columns for V, I, G
• Only characters in “THE BOY HAS THE
• V I G BALL” : A,B,
– E,H,L,O,S,T,Y
• A V I G
• B W J H • Example encipherments :
• E Z M L – Encode first plaintext letter T with key
character K : follow V column down to T
• H C P N row (giving “O”)
• L G T R – Encode second plaintext letter H using key
character I: follow I column down to H row
• O J W U (giving “P”)
• S N A Y
• T O B Z
• Y T H E
25
Example of Vigenère Cipher

• Keyword: deceptive
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ

26
Useful Terms
• period: length of key
– In earlier example, period is 3
• tableau: table used to encipher and
decipher
– Vigènere cipher has key letters on top,
plaintext letters on the left
• polyalphabetic: the key has several
different letters
– Cæsar cipher is monoalphabetic

27
Security of Vigenère Ciphers
• There are multiple (how many?) ciphertext letters
corresponding to each plaintext letter.
• So, letter frequencies are obscured but not totally lost.
• To break Vigenere cipher:
1. Try to guess the key length. How?
2. If key length is N, the cipher consists of N Caesar ciphers.
Plaintext letters at positions k, N+k, 2N+k, 3N+k, etc., are
encoded by the same cipher.
3. Attack each individual cipher as before.

28
One Time Pad(OTP)
Extends Vigenère cipher so that the key is as
long as the plaintext
– No repeat, cannot be broken by finding key
length
+ frequency analysis
• Key is a random string that is at least as long
as the plaintext
• Encryption is similar to Vigenère

29
Let Zm ={0,1,…,m-1} be
the alphabet.
Plaintext space = Ciphtertext space = Key space
= (Zm)n
The key is chosen uniformly randomly
Plaintext X = (x1 x2 … xn)
Key K = (k1 k2 … kn)
Ciphertext Y = (y1 y2 … yn)
ek(X) = (x1+k1 x2+k2 … xn+kn) mod m
dk(Y) = (y1-k1 y2-k2 … yn-kn) mod m

30
Key Randomness in One-Time Pad
• One-Time Pad uses a very long key, what if the
key is not chosen randomly, instead, texts from,
e.g., a book is used
. – this is not One-Time Pad anymore
– this does not have perfect secrecy
– this can be broken •
• The key in One-Time Pad should never be
reused.
– If it is reused, it is Two-Time Pad, and is
insecure! 31
The Binary Version of One-Time Pad
Plaintext space = Ciphtertext space =
Keyspace = {0,1}n
Key is chosen randomly
For example:
• Plaintext is 11011011
• Key is 01101001
• Then ciphertext is 10110010

32
Bit Operators
• Bit AND
0∧0=0 0∧1=0 1∧0=0 1∧1=1

• Bit OR
0∨0=0 0∨1=1 1∨0=1 1∨1=1

• Addition mod 2 (also known as Bit XOR)


0 ⊕0=0 0⊕1=1 1⊕0=1 1⊕1=0

• Can we use operators other than Bit XOR for binary version of
One-Time Pad?

33
How Good is One-Time Pad?
• Intuitively, it is secure …
– The key is random, so the ciphertext is completely
random
– Perfect secrecy ⇒ key-length ≥ msg-length
– Difficult to use in practice

34
Transposition Ciphers
• Also called permutation ciphers.
• Shuffle the plaintext, without altering the
actual letters used.
• Easy to crack as the frequency of letters in the
cipher is same as in plain text
Row Transposition Ciphers
Column Transposition Ciphers

35
Transposition Ciphers
• Also called permutation ciphers.
• Shuffle the plaintext, without altering the
actual letters used.
• Easy to crack as the frequency of letters in the
cipher is same as in plain text
Row Transposition Ciphers
Column Transposition Ciphers

36
Transposition Cipher
Alice and Bob can agree on the number of columns and use the
second method. Alice writes the same plaintext, row by row, in a
table of four columns.
Plain Text: meet me at the park

Cipher text : mmtaeehreaekttp


Column Transposition Ciphers
• Plaintext is written row by row in a rectangle.
• Ciphertext: write out the columns in an order
specified by a key.
a t t a c k p
Key: 3 4 2 1 5 6 7
o s t p o n e
Plaintext: d u n t i l t
wo a mx y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ

38
Row Transposition Ciphers
Rail Fence Cipher
Plain text is written downwards on “rails of fence “ , starting a new
column when bottom is reached.
To create cipher
• First write down plain text message as a sequence of diagonals.
• Read the plain text written in first step as a sequence of row
Example:
Plain text: come home tomorrow
Cipher text: cmhmtmrooeoeoorw

39
To decipher a rail fence cipher:
1. Divide the ciphertext in half
2. Reverse the order of the steps of
encipherment, that is, write the ciphertext
in two rows
1. Read off the plaintext in a zig-zag order

40
Product Ciphers
• Ciphers using substitutions or transpositions are not
secure because of language characteristics
• Product Cipher use a sequence of substitutions and
transpositions
– Harder to break than just substitutions or transpositions
– two substitutions make a more complex substitution
– two transpositions make more complex transposition
– but a substitution followed by a transposition makes a new
much harder cipher
• This is bridge from classical to modern ciphers

41
Cryptanalysis Attack

A good cryptosystem protects against the four types of attacks.


1. Ciphertext only: The adversary has only the ciphertext. The goal is to find
the corresponding plaintext and possible, the key, too.
2. Known plaintext: The adversary has the ciphertext and the plaintext that
was enciphered. The goal is to find the key that was used.
3. Chosen plaintext: The adversary may ask that specific plaintexts be
enciphered and has the corresponding ciphertexts. The goal is to find the
key that was used.
4. Chosen ciphertext: The adversary may ask that specific cipertext has the
corresponding plaintext. The goal is to find the key that was used.
Cipher text only attack
Known Plain Text
Chosen Plain Text attack
Chosen Cipher Text attack
Cryptanalysis
Cryptanalysis is the breaking of codes.
• The attempt to deduce the original meaning of a
ciphertext message.
• Determine which decrypting algorithm, and ideally
which key, matches the encrypting algorithm to be
able to break other messages encoded in the same
way.
• Information commonly used for cryptanalysis:
Encrypted messages, known encryption algorithms,
intercepted plaintext, data items known or suspected
to be in a ciphertext message, mathematical or
statistical tools and techniques, and properties of
languages.
Work factor
• An encryption algorithm is called breakable
when, given enough time and data, an analyst
can determine the algorithm.
• An algorithm that is theoretically breakable
may in fact be impractical to try to break.
• Work factor: amount of effort needed to
break an encryption or mount a successful
attack
In cryptanalysis there are no rules: Any action is
fair play.
Block and stream ciphers
2 categories on the basis of type of data encrypted
1. Block encryption
2. Stream encryption
In stream encryption, each bit, or perhaps each byte, of the data
stream is encrypted separately.
• Can be applied immediately to whatever data items are ready to
transmit.
• For example, streaming video, perhaps a movie, from a satellite.
The stream comes in bursts, depends on the satellite load and the
speed at operation speed of the sender and receiver.

A block cipher encrypts a group of plaintext symbols as a single block.


It works on a quantity of plaintext data all at once.
• Block ciphers work on blocks of plaintext and produce blocks of
ciphertext,
• Blocks are typically 64, 128, 256 bits or more and the block size
need not have any particular relationship to the size of a
character.
Working principles

Stream Cipher

BlockBlock
Cipher
Cipher
Pros and Cons
Cryptography Types
Symmetric Key Cryptography
Asymmetric Key Cryptography
Symmetric Vs Asymmetric Cryptography
Symmetric vs Asymmetric cryptosystems
• Symmetric system provides authenticity, proof that a message received was not
fabricated by someone other than the declared sender provided the key the is not
disclosed.
Issues :
• How do two users A and B obtain their shared secret key and that only A and B can
use that key for their encrypted communications.
• Managing keys: If n users who want to communicate in pairs need
n * (n – 1)/2 keys.
• The number of keys needed increases at a rate proportional to the square of the
number of users.
• Require a means of key distribution system.
• Asymmetric systems, have precisely matched pairs of keys.
• The keys are produced together or one is derived mathematically from the other.
Both the keys are computed as a set.
• Asymmetric systems public key can be sent in an email message or post it in a
public directory. Only the corresponding private key, which presumably is not
disclosed, can decrypt what has been encrypted with the public key.
Confusion and Diffusion
• Terms courtesy of Claude Shannon, father of
Information Theory
• Confusion obscures the relationship between the
plaintext and ciphertext,
• Diffusion spreads the plaintext statistics through the
ciphertext.
• A one-time pad relies entirely on confusion while a
simple substitution cipher is another (weak) example of
a confusion-only cryptosystem.
• A double transposition is the classic example of a
diffusion-only cryptosystem.
Confusion Vs Diffusion
Steganograpghy
• Steganography comes from the Greek steganos , meaning
covered or secret, and graphy , meaning writing or drawing.
• Steganography literally means covered writing.
• Steganography simply takes one piece of information and
hides it within another
• Computer files (images, sounds recordings, even disks)
contain unused or insignificant areas of data
• Steganography takes advantage of these areas, replacing
them with information (encrypted mail, for instance).
• The files can then be exchanged without anyone knowing
what really lies inside of them
• For example, An image of the space shuttle landing might
contain a private letter to a friend.
Steganography Principles

Computer Steganography is based on two principles.


1. The files containing digitized images or sound can be
altered to a certain extent without loosing their
functionality.
2. The human inability to distinguish minor changes in
image color or sound quality, which is especially easy
to make use of in objects that contain redundant
information, be it 16-bit sound, 8-bit or 24-bit image.
For example: The value of the least significant bit of
the pixel color won’t result in any perceivable change
of that color.
Steganography types
• Hiding a Message inside Text
o First-letter algorithm
o Every n-th character
o Altering the amount of whitespace
o Using a publicly available cover source
• Hiding a Message inside Images -Most popular technique
o Least-significant bit (LSB) modifications
o Masking and Filtering
o Algorithms and Transformations
• Hiding a Message inside Audio and Video Files
o Large amount of data that can be hidden inside
o Hard to recognize because of because of the continuous
flow of information (moving stream of images and sound)
Steganography applications

You might also like