Date post: | 05-Jan-2016 |
Category: |
Documents |
Upload: | molly-matthews |
View: | 230 times |
Download: | 5 times |
Basic Encryption & Decryption
Codebreaking 101Codebreaking 101
Copyright © 2000 by the Trustees of Indiana University except as
noted
CRYPTOGRAPHY
• Encryption:• a means of attaining secure communications over
insecure channels• protection of data by transformations that turn useful
and comprehensible plain text into scrambled andmeaningless cipher text under control of secret keys
• Classical methods: substitution, transposition• Modern methods:
• Composite• Data Encryption Standard (DES)• Public Key Cryptosystems
10020
Copyright © 2000 by the Trustees of Indiana University except as
noted
Possible Intruder Goals
• Intercept message in order to:
– Interrupt it– Modify it– Fabricate an authentic looking message– Block it (deny access to)
Copyright © 2000 by the Trustees of Indiana University except as
noted
Encryption Processes
PlaintextPlaintext CiphertextCiphertextEncryptionEncryption DecryptionDecryption
OriginalOriginalPlaintextPlaintext
Basic Encryption Process
Copyright © 2000 by the Trustees of Indiana University except as
noted
Keyed Encryption Processes
Key
Plaintext CiphertextEncryption Decryption
OriginalPlaintext
Symmetric Cryptosystem
Plaintext CiphertextEncryption Decryption
OriginalPlaintext
KE KD
Asymmetric Cryptosystem
Copyright © 2000 by the Trustees of Indiana University except as
noted
CRYPTANALYSIS TOOLS
• encrypted messages
• known encryption algorithms
• intercepted plaintext
• data known or suspected to bein enciphered messages
• math and statistical techniques
• properties of languages
• computers
• ingenuity and luck
3560
Source: Lance J. Hoffman
Copyright © 2000 by the Trustees of Indiana University except as
noted
The Alphabet & Modular Arithmetic
A B C D E F G H I J K L M0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z13 14 15 16 17 18 19 20 21 22 23 24 25
Arithmetic operation mod 26 = [0,25]
Copyright © 2000 by the Trustees of Indiana University except as
noted
Caesar Cipher ~ Simple Shift
• This is a cipher algorithm that transforms each Plaintext character into a Ciphertext character shifted a fixed distance down the alphabet – The key is the distance of the shift– For example, a key of 3 would replace each
Plaintext “a” with “d”, each “b” with “e”, etc.
• Easy for children to use as a secret code, but obvious pattern is its major weakness
Copyright © 2000 by the Trustees of Indiana University except as
noted
Caesar Cipher Example
• If the key is 5 then the Plaintext alphabet becomes the Ciphertext alphabet shown below:
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 zf g h i j k l m n o p q r s t u v w x y z a b c d e
t h i s
y m n xSource: Spillman
Copyright © 2000 by the Trustees of Indiana University except as
noted
DECRYPTING CAESAR CIPHERS
• Break between words. Blank translatedto self reveals small words
• Double letter. No QQ pairs in English!
• Repeated letters translating to same thing
wuhdwb lpsrvvleoh
Source: Lance J. Hoffman
Copyright © 2000 by the Trustees of Indiana University except as
noted
10090
0
2
4
6
8
10
12
14
16
18
a c e g i k m o q s u w y
Pe
rce
nt Cipher
English
Frequency Distribution
Source: Hoffman & Pfleeger
Copyright © 2000 by the Trustees of Indiana University except as
noted
Keyword Substitutions
• Choose a “key word” such as count
• Write out the alphabet; then write the keyword directly below the first few letters of the alphabet
• Complete the second row by writing (in order) the unused letters
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
c o u n t a b d e f g h i j k l m p q r s v w x y z
Letter:
Code:
Copyright © 2000 by the Trustees of Indiana University except as
noted
Starting Position
• The keyword does not have to start at the beginning of the plaintext alphabet– it could start at any letter– for example, “count” could start at “k”
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 zm p q r s v w x y z c o u n t a b d e f g h i j k l
Note: the alphabet wraps aroundSource: Spillman
Copyright © 2000 by the Trustees of Indiana University except as
noted
Key Word Example
• If the keyword is “visit” (note, the second “i” is visit is dropped below) starting at “a” and the plaintext is “next”, the application is:
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 zv i s t a b c d e f g h j k l m n o p q r u w x y z
n e x t
k a x qSource: Spillman
Copyright © 2000 by the Trustees of Indiana University except as
noted
Frequency Table
a 3312 7.49 n 2982 6.74b 573 1.29 o 3261 7.37c 1568 3.54 p 1074 2.43d 1602 3.62 q 116 0.26e 6192 14 r 2716 6.14f 966 2.18 s 3072 6.95g 769 1.74 t 4358 9.85h 1869 4.22 u 1329 3i 2943 6.65 v 512 1.16j 119 0.27 w 748 1.69k 206 0.47 x 123 0.28l 1579 3.57 y 727 1.64
m 1500 3.39 z 16 0.04
Letter Frequency Pct. Letter Frequency Pct.
n = 44232
Copyright © 2000 by the Trustees of Indiana University except as
noted
Ciphertext Example
• hqfubswlrq lv d phdqv ri dwwdlqlqj vhfxuh
frpsxwdwlrq ryhu lqvhfxuh fkdqqhov
Copyright © 2000 by the Trustees of Indiana University except as
noted
Ciphertext Example
• hqfubswlrq lv d phdqv ri dwwdlqlqj vhfxuh
frpsxwdwlrq ryhu lqvhfxuh fkdqqhov
Encryption is a means of attaining secure
computation over insecure channels
Copyright © 2000 by the Trustees of Indiana University except as
noted
Polyalphabetic Substitutions• Monoalphabetic ciphers produce the same distributions
as plaintext. To flatten the ciphertext distribution, try combining two ciphers so that letters of high and low frequency will map to the same cipher letter.
• ABCDEFGHIJKLMNOPQRSTUVWXYZADGJMPSVYBEHKNQTWZCFILORUX
• 3a mod 26 above for odd positions
• ABCDEFGHIJKLMNOPQRSTUVWXYZNSXCHMRWBQLQVAFKPUZEJOTYDI
• (5a + 13) mod 26 above for even positions
• TREAT YIMPO SS I BL E encrypts toFUMNF DYVTF CZYSH H
Copyright © 2000 by the Trustees of Indiana University except as
noted
Vigenère Cipher
• This is an example of a polyalphabetic cipher where the substitution pattern varies– that is, a plaintext “e” may be replaced by a
ciphertext “p” one time and a ciphertext “w” another
– the Vigenère cipher does this using a Vigenère table
Copyright © 2000 by the Trustees of Indiana University except as
noted
Vigenère Table
• The table lists the keycharacters ontop and theplaintextcharacters onthe side
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 za 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 zb 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 an 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 bd 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 ce 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 df 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 e g g h i j k l m n o p q r s t u v w x y z a b c d e f h h i j k l m n o p q r s t u v w x y z a b c d e f g i i j k l m n o p q r s t u v w x y z a b c d e f g h j j k l m n o p q r s t u v w x y z a b c d e f g h i k k l m n o p q r s t u v w x y z a b c d e f g h i j l l m n o p q r s t u v w x y z a b c d e f g h i j k m m n o p q r s t u v w x y z a b c d e f g h i j k l n n o p q r s t u v w x y z a b c d e f g h i j k l m o o p q r s t u v w x y z a b c d e f g h i j k l m n p p 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 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 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 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 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 a 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
Copyright © 2000 by the Trustees of Indiana University except as
noted
Vigenère Cipher Steps
• A keyword is selected and it is repeatedly written above the plaintext– EXAMPLE: using the keyword “hold”
– Each column forms a keyword/plaintext letter pair which is used in the Vigenère table to determine the ciphertext letter
h o l d h o l d h o l d h o l dt h i s t h e p l a i n t e x t
Copyright © 2000 by the Trustees of Indiana University except as
noted
Vigenère Example
• Using the keyword “hold”
h o l d h o l d h o l d h o l dt h i s t h e p l a i n t e x t
a b c d e f g h i . . .a a b c d e f g h ib b c d e f g h i j . . .n c d e f g h i j k . . .d d e f g h i j k l . . .e e f g h i j k l m . . .f f g h i j k l m n . . .g g h i j k l m n o . . .h h i j k l m n o p . . .i i j k l m n o p q . . .j j k l m n o p q r . . . k k l m n o p q r s . . .l l m n o p q r s t . . .m m n o p q r s t u . . .n n o p q r s t u v . . .o o p q r s t u v w . . .p p q r s t u v w x . . .q q r s t u v w x y . . .r r s t u v w x y z . . .s s t u v w x y z a . . .t t u v w x y z a b . . .u u v w x y z a b c . . .
a
So, “t” becomes “a” butat the end “t” becomes “w”
w
Copyright © 2000 by the Trustees of Indiana University except as
noted
Example
Encrypt the following message
But soft, what light through yonder window breaks
using the keyword Juliet
Copyright © 2000 by the Trustees of Indiana University except as
noted
Cryptanalysis of Polyalphabetics
• While difficult, these are not immune
• Basic strategy is to determine the number of alphabets used to encrypt, and then…– break message into its monoalphabetic
components and– solve each of these as before
Copyright © 2000 by the Trustees of Indiana University except as
noted
KASISKI METHODfor repeated patterns
• Relies on frequency of letter patterns such as-th, -ing, in-, un-, re-, of, and, to
• If message enciphered with n alphabets in cyclicrotation and a word appears k times in plaintext,it should be enciphered approximately k/n timesfrom same alphabet
Copyright © 2000 by the Trustees of Indiana University except as
noted
KASISKI METHODExample using Dickens' work
dicke nsdic kensd icken sdick ensdi ckens dickeitwas thebe stoft imesi twast hewor stoft imesi
nsdic kensd icken sdick ensdi ckens dicke nsdictwast heage ofwis domit wastn eageo ffool ishne
kensd icken sdick ensdi ckens dicke nsdic kensdssitw asthe epoch ofbel iefit wasth eepoc hofin
IT WAS THE is encrypted using keyword nsdicken three timesabove, once in the first line, twice in the third line
These all appear as identical 8-character ciphertextpatterns. Distance between repeated patterns is a multipleof keyword length. Any repeated pattern over 3 characters
is probably not accidental.
Copyright © 2000 by the Trustees of Indiana University except as
noted
Kasiski Method cont’d
Although many 2-letter combinations are coincidental, the probability of 4-letter coincidences is only 0.0000021Once a repeated phrase has been found, compute the distance to the next occurrence and determine the factors for that distance.Repeat as necessary and determine most likely factors
Starting Distance from Factors
Position Previous
20 ----------- -------------
83 63 (83-20) 3, 7, 9, 21, 63
104 21 (104-83) 3, 7, 21
3 or 7
Copyright © 2000 by the Trustees of Indiana University except as
noted
Steps in the Kasiski Method
• Identify repeated patterns of 3 or more characters
• For each pattern, note the position at which eachinstance of the pattern begins
• Note the difference between starting points ofsuccessive instances
• Compute factors of each difference; key length islikely to be one of the factors that appears often
• Then try to divide message into pieces encipheredwith same alphabet
Copyright © 2000 by the Trustees of Indiana University except as
noted
Index of Coincidence
• Once a key length is selected (3 or 7), divide the encrypted message into that number of sub-messages.
• Compare frequency distributions to English to determine whether a particular set was used to encrypt.
M1 = {c1,c4,c7,… } M2 = {c2,c5,c8,… } M3 = {c3,c6,c9,… }
Copyright © 2000 by the Trustees of Indiana University except as
noted
ROUGHNESS OF DISTRIBUTION OF ENGLISH TEXTbased on Pfleeger, C., Security in Computing (2nd Ed.), Figure 2.6
IC measures variations between frequencies in a distribution
10170
0
2
4
6
8
10
12
14
16
a c e g i k m o q s u w y
Per
cen
t Flat 1/26English
Peaks: Relative frequencies > 1/26 = 3.86%
Valleys: Relative frequencies < 1/26
Copyright © 2000 by the Trustees of Indiana University except as
noted
INDEX OF COINCIDENCEIf we have lots of ciphertext AND underlying plaintext has a fairly
standard distribution of letters, THEN can use IC:
NUMBER OFALPHABETS
INDEX OFCOINCIDENCE
1 0.068
2 0.052
3 0.047
4 0.044
5 0.044
10 0.041
large 0.038
10160
z
ai
ii
nn
FreqFreqIC
)1(
)1(
Copyright © 2000 by the Trustees of Indiana University except as
noted
DECRYPTING POLYALPHABETICS
• Use Kasiski method to predict likelynumber of enciphering alphabets. Ifit does not work, then encryption isprobably not simply a polyalphabeticsubstitution.
• Separate ciphertext into appropriatesubsets and independently compute ICfor each subset (should be near 0.068)
• Use frequency analysis on each subset
13170
Copyright © 2000 by the Trustees of Indiana University except as
noted
The Perfect Substitution Cipher
• Use many alphabets to produce a perfectly flat distribution with no recognizable pattern for the choice of any alphabet at any given point.
• Suppose the Vigenère Tableau were extended infinitely with a random key
• Would defy the Kasiski Method. Any repeat encryptions would be purely coincidental
• IC = 0.038 suggesting a totally random encryption.
Copyright © 2000 by the Trustees of Indiana University except as
noted
One-time Pads
• Called the perfect cipher because it uses an arbitrarily long encryption key
• Sender and receiver are provided a book of keys and encryption tableaus. If each key has length = 20, then a 300 letter message would require 15 keys pasted adjacently. After encryption and subsequent decryption, both sender and receiver destroy the keys.
• No key is ever used twice.
Copyright © 2000 by the Trustees of Indiana University except as
noted
Problems with One-time Pads
• Requires absolute synchronization between sender and receiver
• Need exists for an unlimited number of keys
• Publishing, distributing and securing keys is a major problem - an administrative burden
Copyright © 2000 by the Trustees of Indiana University except as
noted
Use Of Random Numbers
• Approximates one-time pads– computer generated random numbers must be
scaled to the interval [0, 25]
• Requires complete synchronization between sender and receiver
• RN Generators are not truly random, and given enough ciphertext, they can be broken
Copyright © 2000 by the Trustees of Indiana University except as
noted
INFINITE KEYSUsing Long PRN Sequences
• RANDNOi+1 = c RANDNOi + b mod w
where w is a large integer, typically 2x
• Short messages are generally pretty secure; long messages are vulnerable to probableword attacks
13210
Copyright © 2000 by the Trustees of Indiana University except as
noted
The Vernam Cipher
• Named after its developer, Gilbert Vernam who worked for AT&T
• Vernam used a punched paper tape containing a long series of non-algorithmic random numbers to produce the ciphertext
• Keys destroyed after a single use to make them immune to analysis
Copyright © 2000 by the Trustees of Indiana University except as
noted
Vernam Model
Plaintext
Long Random Number Sequence
CiphertextOriginalPlaintext
Encryption Decryption
denotes an XOR or other combining function
Copyright © 2000 by the Trustees of Indiana University except as
noted
Vernam Example
V E R N A M C I P H E R21 4 17 13 0 12 2 8 15 7 4 1776 48 16 82 44 3 58 11 60 5 48 8897 52 33 95 44 15 60 19 75 12 52 10519 0 7 17 18 15 8 19 23 12 0 1T A H R S P I T X M A B
plaintextnumeric equivalent+ random number= sum mod 26ciphertext
Copyright © 2000 by the Trustees of Indiana University except as
noted
Characteristics of RNGs
• Many encryption algorithms rely on random numbers
• RNGs produce long period sequences but the cycle eventually repeats
• The linear congruential RNG is the most common type - requires a seed value
NEW_RANDNO := (A*OLD_RANDNO + B) mod N
A, B and N are constants; seed number and N must be prime relative to N
Copyright © 2000 by the Trustees of Indiana University except as
noted
Probable Word Attacks
• Given the structure of the linear congruential RNG, assume the first few ciphertext characters represent some likely word such as ‘MEMO,’ ‘DATE’ or ‘FROM’
• Inserting the numeric equivalents for the plaintext probable words, a system of simultaneous equations can be developed and solved
Copyright © 2000 by the Trustees of Indiana University except as
noted
Long Sequences from Books
• Use the phone book (middle two digits of a telephone number make a good RN)– RN mod 26 defines the Vigenère key column
• Use a novel for a nonrepeating key– Problem is that both key and plaintext have the same
frequency distribution
– also {a,e,i,n,o,t} make up 50% of all letter occurrences in English. Probability that they map to same subset is 0.25
– leads to a reduced Vigenère Tableau and some effective guessing
Copyright © 2000 by the Trustees of Indiana University except as
noted
Dual Message Entrapment
• Consider the following two messages:– disregard this message– this message is crucial
• Both have the same length
• If one serves as the key for the other the same ciphertext will be generated and a successfully decrypted message still has a 50% chance of being the wrong message
Copyright © 2000 by the Trustees of Indiana University except as
noted
CRYPTOANALYTIC TOOLSFOR SUBSTITUTION CIPHERS
• Frequency distribution
• Index of coincidence
• Consideration of highly likely lettersand probable words
• Pattern analysis and Kasiski approach
• Persistence, organization, ingenuity, and luck
13236