2-Basic Cryptography

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 37

Basic

Cryptography
Week - 2
Acknowledgement
Prepared by Nishanthi Herath – ATI, Kandy
Based on Cryptography and Network Security, 4th
Edition by William Stallings referring the
lecture slides by
Lawrie Brown
Classical Encryption
Techniques
Many savages at the present day regard their
names as vital parts of themselves, and
therefore take great pains to conceal their real
names, lest these should give to evil-disposed
persons a handle by which to injure their
owners. —The Golden Bough, Sir James
George Frazer
Symmetric Encryption
• or conventional / private-key / single-key
• sender and recipient share a common key
• all classical encryption algorithms are private-
key
• was only type prior to invention of public-key
in 1970’s
Basic Terminology
• plaintext - the original message
• ciphertext - the coded message
• cipher - algorithm for transforming plaintext
to ciphertext
• key - info used in cipher known only to
sender/receiver
• encipher (encrypt) - converting plaintext to
ciphertext
• decipher (decrypt) - recovering ciphertext
from plaintext
Basic Terminology – contd.
• 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
Requirements
• two requirements for secure use of symmetric
encryption:
– a strong encryption algorithm
– a secret key known only to sender / receiver
Y = EK(X)
X = DK(Y)
• assume encryption algorithm is known
• implies a secure channel to distribute key
Cryptography
• can characterize by:
– type of encryption operations used
• substitution / transposition / product
– number of keys used
• single-key or private / two-key or public
– way in which plaintext is processed
• block / stream
Brute Force Search
• always possible to simply try every key
• most basic attack, proportional to key size
• assume either know / recognise plaintext
More Definitions
• unconditional security
– no matter how much computer power is available,
the cipher cannot be broken since the ciphertext
provides insufficient information to uniquely
determine the corresponding plaintext
• computational security
– given limited computing resources (eg time
needed for calculations is greater than age of
universe), the cipher cannot be broken
Classical Substitution Ciphers
• where letters of plaintext are replaced by
other letters or by numbers or symbols
• or if plaintext is viewed as a sequence of bits,
then substitution involves replacing plaintext
bit patterns with ciphertext bit patterns
Caesar Cipher
• earliest known substitution cipher
• by Julius Caesar
• first attested use in military affairs
• replaces each letter by 3rd letter on
• example:
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
Caesar Cipher
• can define transformation as:
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
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
• then have Caesar cipher as:
C = E(p) = (p + k) mod (26)
p = D(C) = (C – k) mod (26)
Cryptanalysis of Caesar Cipher
• only have 26 possible ciphers
– A maps to A,B,..Z
• could simply try each in turn
• a brute force search
• given ciphertext, just try all shifts of letters
• do need to recognize when have plaintext
• eg. break ciphertext "GCUA VQ DTGCM"
Monoalphabetic Cipher
• rather than just shifting the alphabet
• could shuffle (jumble) the letters arbitrarily
• each plaintext letter maps to a different random
ciphertext letter
• hence key is 26 letters long

Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
Monoalphabetic Cipher Security
• now have a total of 26! = 4 x 1026 keys
• with so many keys, might think is secure
• but would be !!!WRONG!!!
• problem is language characteristics
Language Redundancy and Cryptanalysis
• human languages are redundant
• eg "th lrd s m shphrd shll nt wnt"
• 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
• cf. Z,J,K,Q,X
• have tables of single, double & triple letter
frequencies
English Letter Frequencies
Use in Cryptanalysis
• key concept - monoalphabetic substitution ciphers
do not change relative letter frequencies
• discovered by Arabian scientists in 9th century
• calculate letter frequencies for ciphertext
• compare counts/plots against known values
• if Caesar cipher look for common peaks/troughs
– peaks at: A-E-I triple, NO pair, RST triple
– troughs at: JK, X-Z
• for monoalphabetic must identify each letter
– tables of common double/triple letters help
One-Time Pad
• if a truly random key as long as the message is
used, the cipher will be secure
• called a One-Time pad
• is unbreakable since ciphertext bears no
statistical relationship to the plaintext
• since for any plaintext & any ciphertext there
exists a key mapping one to other
• can only use the key once though
• have problem of safe distribution of key
Transposition Ciphers
• now consider classical transposition or
permutation ciphers
• these hide the message by rearranging the
letter order
• without altering the actual letters used
• can recognise these since have the same
frequency distribution as the original text
Rail Fence cipher
• write message letters out diagonally over a
number of rows
• then read off cipher row by row
• eg. write message out as:
m e m a t r h t g p r y
e t e f e t e o a a t
• giving cipher text
MEMATRHTGPRYETEFETEOAAT
Row Transposition Ciphers
• a more complex scheme
• write letters of message out in rows over a
specified number of columns
• then reorder the columns according to some
key before reading off the rows
Key: 3 4 2 1 5 6 7
Plaintext: a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
Key : 3 4 2 1 5 6 7
Plain Text : Attack Postponed until tomorrow

a t t a c k p
o s t p o n e
d u n t i l t
o m o r r o w

Cipher text:
TTNAAPTMTSUOAODWCOIXKNLYPETZ
Product Ciphers
• ciphers using substitutions or transpositions are not
secure because of language characteristics
• hence consider using several ciphers in succession to
make harder, but:
– 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
Rotor Machines
• before modern ciphers, rotor machines were most
common product cipher
• were widely used in WW2
– German Enigma, Allied Hagelin, Japanese Purple
• implemented a very complex, varying substitution
cipher
• used a series of cylinders, each giving one
substitution, which rotated and changed after each
letter was encrypted
• with 3 cylinders have 263=17576 alphabets
Block Cipher Characteristics
• features seen in modern block ciphers are:
– variable key length / block size / no rounds
– mixed operators, data/key dependent rotation
– key dependent S-boxes
– more complex key scheduling
– operation of full data in each round
– varying non-linear functions
Blowfish
• a symmetric block cipher designed by Bruce
Schneier in 1993/94
• characteristics
– fast implementation on 32-bit CPUs
– compact in use of memory
– simple structure eases analysis/implemention
– variable security by varying key size
• has been implemented in various products
Stream Ciphers
• process the message bit by bit (as a stream)
• typically have a (pseudo) random stream key
• combined (XOR) with plaintext bit by bit
• randomness of stream key completely destroys any
statistically properties in the message
– Ci = Mi XOR StreamKeyi
• what could be simpler!!!!
• but must never reuse stream key
– otherwise can remove effect and recover messages
Stream Cipher Properties
• some design considerations are:
– long period with no repetitions
– statistically random
– depends on large enough key
– large linear complexity
– correlation immunity
– confusion
– diffusion
– use of highly non-linear boolean functions
RC4
• a proprietary cipher owned by RSA DSI
• another Ron Rivest design, simple but
effective
• variable key size, byte-oriented stream cipher
• widely used (web SSL/TLS, wireless WEP)
RC4 – contd.
• key forms random permutation of all 8-bit
values
• uses that permutation to scramble input info
processed a byte at a time
Block vs Stream Ciphers
• block ciphers process messages in into blocks,
each of which is then en/decrypted
• like a substitution on very big characters
– 64-bits or more
• stream ciphers process messages a bit or byte
at a time when en/decrypting
• many current ciphers are block ciphers
• hence are focus of course
Steganography
• an alternative to encryption
• hides existence of message
– using only a subset of letters/words in a longer
message marked in some way
– using invisible ink
– hiding in LSB in graphic image or sound file
• has drawbacks
– high overhead to hide relatively few info bits
2 6 5
7 7 9
o 4 4
5 1 8

Original Image
Encoded using
Steganography tools

2 6 4
7 5 4
2 4 3
5 1 8

Ciphered Image
Summary
• have considered:
– classical cipher techniques and terminology
– Mono alphabetic substitution ciphers
– cryptanalysis using letter frequencies
– transposition ciphers
– product ciphers and rotor machines
– Block and stream ciphers
– stenography

You might also like