Sei sulla pagina 1di 54

Classical Encryption

Techniques
Lecture-2
Last lecture recap
• What is a security?
• CIA triad
• OSI security architecture
- Security attacks
- Security services
- Security mechanism
• Security model
Basic Terminology
• Plaintext - the original message
• Ciphertext - the coded/scrambled message
• Cipher - algorithm for transforming plaintext/ciphertext
• key - info used in cipher known only to sender/receiver
• Encipher (encrypt) - converting plaintext to ciphertext
• decipher (decrypt) - recovering ciphertext from plaintext
• Cryptography - study of encryption principles/methods
• Cryptanalysis (codebreaking) - the study of principles/ methods of
deciphering ciphertext without knowing key
• Cryptology - the field of both cryptography and cryptanalysis
Symmetric Cipher Model
 Systematic encryption
• Plaintext: The original intelligible message or data (input )
• Encryption algorithm: The encryption algorithm ( substitutions , transformations)
• Secret key: The secret key is also input to the encryption algorithm. ( key value
independent of the plaintext and algorithm.)
• Ciphertext: The scrambled message (output)
• Decryption algorithm: This is essentially the encryption algorithm run in reverse,
(produces the original plaintext)
Symmetric Cipher Model
Symmetric Cipher Model
Two requirements for secure use of conventional encryption
1. A Strong a strong encryption algorithm (keeping key secret )
- Opponent should be unable to decrypt ciphertext or discover the key, even if
s/he is in possession of a number of ciphertext with plaintext
• A secret key known only to sender / receiver
Y = E(K, X)
X = D(K,Y)

2. Sender and receiver must have obtained copies of the secret key in
a secure fashion and must keep the key secure.
Model of Symmetric Cryptosystem
• Generated key must be delivered to the destination through a
security channel.
Cryptography
Cryptographic systems categorization
1. Type of encryption operations used for transforming plaintext to ciphertext. ( substitution /
transposition / product systems)
2. Number of keys used:
- symmetric: single-key, secrete-key, conventional encryption; Sender and receiver use the same key

- asymmetric: double-keys, public key; Sender and receiver use different keys

3. The way in which plaintext is processed:


• Block cipher: process one block of elements a time
• Stream cipher: continuous input, output one element a time
Cryptography
Types of attacks on an encryption algorithm
• Cryptanalysis attack
- based on properties of the encryption algorithm
• brute-force attack
- involves trying all possible keys.
Cryptanalytic Attacks
 Types of Attacks on Encrypted Messages
Type of Attack Known to cryptanalyst
Ciphertext Only • Encryption algorithm
• Ciphertext
Known Plaintext • Encryption Algorithm
• Ciphertext
• One or more paintext-ciphertext with the secret key
Chosen Plaintext • Encryption algorithm
• ciphertext
• Plaintext message chosen by cryptanalyst, together
with its corresponding ciphertext generated with the
secret key
Cryptanalytic Attacks
 Types of Attacks on Encrypted
Messages Known to cryptanalyst
Type of Attack
Chosen Ciphertext Encryption algorithm
• Ciphertext
• Ciphertext chosen by cryptanalyst, together with its corresponding
decrypted
plaintext generated with the secret key
Chosen Text Encryption algorithm
• Ciphertext
• Plaintext message chosen by cryptanalyst, together with its
corresponding
ciphertext generated with the secret key
• Ciphertext chosen by cryptanalyst, together with its corresponding
decrypted
plaintext generated with the secret key
Brute-force attack
A brute-force attack involves trying every possible key until an
intelligible translation of the ciphertext into plaintext is obtained. On
average, half of all possible keys must be tried to achieve success.
Brute Force Search
• always possible to simply try every key
• most basic attack, proportional to key size
• assume either know / recognise plaintext
Unconditional and Computational
security
Unconditional security
• Generated ciphertext does not contain sufficient information to determine
corresponding plaintext.

Computational security
- The cost of breaking the cipher exceeds the value of the encrypted information.
- The time required to break the cipher exceeds the useful lifetime of the information
- If such criteria is/are met – computationally secure
Classical Ciphers
Examine a sampling of what might be called classical encryption
techniques.
The two basic building blocks of all encryption techniques :
- Substitution : Letter of plaintext replaced by other letters, numbers
or symbols
- Transposition: involves replacing plaintext bit patterns with
ciphertext bit patterns. ( a sequence of bits)
• Illustrate the basic approaches to symmetric encryption and the types
of cryptanalytic attacks that must be anticipated.
Substitution techniques
Caesar Cipher
The earliest known and simplest
Used by Julius Caesar
E.g. Replacing each letter by a letter three places down the alphabet
• example:
Plain: meet me after the toga party
Cipher PHHW PH DIWHU WKH WRJD SDUWB
Substitution techniques
Example:
Plain Cipher: (p = plain text letter, C= cipher letter)
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
C = E(p,3) = (p+3) mod 26
Caesar Cipher
Assign each letter with a number
Caesar Cipher
 Caesar cipher algorithm
• Encryption algorithm
 C = E(k,p) = (p+K) mod 26 ( where 1<= k <=25)

• Decryption Algorithm
 P = D(k,C) = (C-K) mod 26 ( where 1<= k <=25)
Cryptanalysis of Caesar Cipher
 Problem
• Only have 26 possible keys ( only 25 keys to try )
Could shift K = 0, 1, 2, …, 25 slots
• Could simply try each in turn
• Language of the plaintext is known and easily recognised
• Brute force search
- given ciphertext, just try all shifts of letters
- do need to recognize when have plaintext

• Is Caesar cipher secure?


Monoalphabetic Ciphers
• Rather than just shifting the alphabet (Caesar )
• Could shuffle the letters arbitrarily
• Each plaintext letter maps to a different random ciphertext letter
• The key for such a cipher is a table of the correspondence or a function
from which the correspondence is computed
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN

• Monoalphabetic ciphers are easy to break because they reflect the


frequency data of the original alphabet.
Monoalphabetic Ciphers
Permutation
A finite set of elements is an ordered sequence of all the elements of , with each
element appearing exactly once.
S= { a, b, c} .
-Permutation of S = abc, acb, bac, bca, cab, cba.
• Set of n elements , has n! permutations
26 alphabetic characters, then there are 26! or greater than 4 * 1026 possible keys.
Possible Attack.
If the cryptanalyst knows the nature of the plaintext (e.g., noncompressed English
text), then the analyst can exploit the regularities of the language.
Monoalphabetic Ciphers
• Example: The following cipher text to be solved
Example (cont.)
• English letters are not equally commonly used
• in English e is by far the most common letter
• then T,R,N,I,O,A,S
• other letters are fairly rare Z,J,K,Q,X
• have tables of single, double & triple letter frequencies
English Letter Frequencies Example (cont.)
Example (cont.)
• First- step : determine relative frequency of the letters and compare
to standard frequency distribution for English
• relative frequencies of the letters in the ciphertext (in percentages)
are as follows:
Example (cont.)
• it seems likely that cipher letters P and Z are the equivalents of plain
letters e and t, but it is not certain which is which
• letters S, U, O, M, and H are all of relatively high frequency and
probablycorrespond to plain letters from the set {a, h, i, n, o, r, s}.
• The letters with the lowest frequencies (namely, A, B, G, Y, I, J) are
likely included in the set {b, j, k, q, v, x, z}.
Example (cont.)
Powerful tool is to look at the frequency of two-letter combinations,
known as digrams. ( table can be created)
• most common such digram is th. While In our ciphertext, the
mostcommon digram is ZW
• So we make the correspondence of Z with t and W with h .[Then, by
our earlier hypothesis, we can equate P with e]
• ZWP appears in the ciphertext, - -> this can be translated that
sequence as “the”.
• Notice the sequence ZWSZ in the first line. We do not know that these
four letters form a complete word, but if they do, it is of the form th_t.
If so, S equates with a.
Example (cont.)

• Now we have

• The complete plaintext, with spaces added between words,


follows:

.
Monoalphabetic Ciphers
• Monoalphabetic ciphers are easy to break because they
reflect the frequency data of the original alphabet
• not even the large number of keys in a monoalphabetic cipher provides
security
• One approach to improving security was to encrypt multiple letters
- A countermeasure is to provide multiple substitutes, known as
homophones, for a single letter.
- For example, the letter e could be assigned a number of different cipher
symbols, such as 16, 74, 35, and 21, with
each homophone assigned to a letter in rotation or randomly.
Monoalphabetic Ciphers
Playfair Cipher
• A multiple-letter encryption cipher.
• Treats digrams in the plaintext as single units and translates these
units into ciphertext digrams
• Playfair algorithm is based on the use of a 5 × 5 matrix of letters
constructed using a keyword.
Playfair Key Matrix
• 5X5 matrix of letters based on a keyword
• The matrix is constructed by filling in the letters of the keyword
(minus duplicates)
• Left to right and from top to bottom,
• fill rest of matrix with other letters
Playfair Key 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
Playfair- Encrypting and Decrypting
Plaintext is encrypted two letters at a time, based on the following rules:
1. Repeating plaintext letters that are in the same pair are separated with
a filler letter, such as x.
- e.g. balloon would be treated as ba lx lo on.
2. Two 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
circularly following the last.
- e.g. ar is encrypted as RM.
Playfair -Encrypting and
Decrypting
3. Two plaintext letters that fall in the same column are each replaced
by the letter beneath, with the top element of the column circularly
following the last.
- e.g. mu is encrypted as CM.
4. Otherwise, each plaintext letter in a pair is replaced by the letter that
lies in its own row and the column occupied by the other plaintext
letter.
- Thus hs becomes BP and ea becomes IM (or JM, as the encipherer
wishes).
Security of the Playfair Cipher
• security much improved over monoalphabetic
• since have 26 x 26 = 676 digrams
• would need a 676-entry frequency table to analyse (verses 26 for a
monoalphabetic)
• was widely used for many years (eg. US & British military in WW1)
• Despite this level of confidence in its security, the Playfair cipher is
relatively easy to break, because it still leaves much of the structure of
the plaintext language intact.
Polyalphabetic Ciphers

• Another way to improve on the simple monoalphabetic technique is to use


different monoalphabetic substitution
• This process called polyalphabetic substitution ciphers
• Makes cryptanalysis harder with more alphabets to guess and flatter
frequency distribution
Used techniques has the following features
1. A set of related monoalphabetic substitution rules is used.
2. A key determines which particular rule is chosen for a given transformation
 One of the simplest, polyalphabetic ciphersis the Vigenère cipher.
Hill Cipher
Hill Cipher
• A multi-letter cipher, developed by the mathematician Lester Hill in 1929

• It 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, c, z = 25)
Hill Cipher ,

• suppose m=3, then system can be described as:


Hill Cipher
- .  C = PK mod 26
- where C and P are row vectors of length 3 representing the plaintext
and ciphertext
- K is a 3 * 3 matrix representing the encryption key

Hill system (general )


 
C = E( K,P) = PK mod 26
P= D(K,C) mode 26 = = P
Polyalphabetic Ciphers
Polyalphabetic substitution cipher : have the following features in
common:

• A set of related monoalphabetic substitution rules is used.


• A key determines which particular rule is chosen for a given
transformation
Polyalphabetic Ciphers
•  VIGENÈRE CIPHER

• Plaintext : …………..
• Key : …………..
• Cipher text : …………..
• Computation
= E(K,P)= E( …,),( …, )
= ( ) mod 26, ( ) mode26, ......, ( ) mod 26,
( ) mod 26, ( ) mod 26, ....., ( ) mod 26
Polyalphabetic Ciphers
• VIGENÈRE CIPHER
General equations:
=( + ) mod 26 (Encryption)
=( - ) mod 26 (Decryption
Vigenere Cipher
• The first letter of the key is added to the first letter of the plaintext,
mod 26.
• The second letters are added, and so on through the first letters of the
plaintext.
• For the next letters of the plaintext, the key letters are repeated.
Example
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Vigenere Cipher
Example: Expressed numerically
Key 3 4 2 4 15 19 8 21 4 3 4 2 4 15
plainText 22 4 0 17 4 3 8 18 2 14 21 4 17 4

Ciphertext 25 8 2 21 19 22 16 13 6 17 25 6 21 19

Key 19 8 21 4 3 4 2 4 15 19 8 21 4

plainText 3 18 0 21 4 24 14 20 17 18 4 11 5

Ciphertext 22 0 21 25 7 2 16 24 6 11 1 6 9
2
Vigenère cipher
• Autokey system.
A keyword is concatenated with the plaintext itself to provide a
running key.
Key : deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGKZEIIGASXSTSLVVWLA
One-Time Pad
• One-Time Pad
• a random key that is as long as the message
• 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.
• It produces random output that bears no statistical relationship to the
plaintext.
One-Time Pad
E.g Consider the ciphertext
ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS
We now show two different decryptions using two different keys:
• ciphertext: ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS
• key: pxlmvmsydofuyrvzwc tnlebnecvgdupahfzzlmnyih
• plaintext: mr mustard with the candlestick in the hall
• ciphertext: ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS
• key: pftgpmiydgaxgoufhklllmhsqdqogtewbqfgyovuhwt
• plaintext: miss scarlet with the knife in the library
One-Time Pad
• one-time pad offers complete security but, in practice, has two
fundamental difficulties:
• 1. There is the practical problem of making large quantities of random
keys. Any heavily used system might require millions of random
characters on a regular basis..
• 2. Key distribution and protection problem.
Transposition Techniques
Rail fence technique
Plaintext is written down as a sequence of diagonals and then read off
as a sequence of row
Plain text : meet me after the toga party
m e m a t r h t g p r y
e t e f e t e o a a t

MEMATRHTGPRYETEFETEOAAT
Transposition Techniques
• Columnar transposition
Steganography
Steganography.
Conceal the existence of the message
Techniques
• Character marking
• Invisible ink
• Pin punctures
• Typewriter correction ribbon
Summary
• Cryptographic systems categorization
• attacks on an encryption algorithm
• Unconditional and Computational security
• Caesar Cipher
• Playfair Cipher
• Polyalphabetic Ciphers
• Vigenere Cipher
Any Question?

Potrebbero piacerti anche