65
5/12/2014 1 JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOO

JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 1

JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOO

Page 2: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 2

Cryptology: Past & Present

Robert Campbell

<[email protected]>

Aka Two Millenia in 60 Minutes

Page 3: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 3

Caesar Cipher

Choose a key between 0 and 25

“Add” the key to each letter

DOO JDXO LV GLYLGHG - FDHVDU

ABCDEFGHIJKLMNOPQRSTUVWXYZ

key=3 ALL GAUL IS DIVIDED - CAESAR

Attacks:

- Exhaust – only 26 key choices

- Crib – Guess signature

Page 4: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 4

Monoalphabetic Subst

Create a mixed alphabet:

Encrypt:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

WASHINGTOBCDEFJKLMPQRUVXYZ

THIS MESSAGE IS ENCRYPTED

QTOP EIPPWGI OP IFSMYKQIH

Page 5: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 5

Monoalphabetic (cont)

Key Size = 26! = 26*25*...*3*2*1 =

403,291,461,126,605,635,584,000,000

Attacks:

Crib – Guess a word

Statistics – ETNORIAS

Guess and fill out N OZET TFXIACSTU SONV GTVVZPT RVNFP Z ITETIVTU

ZHCOZYTS ZFU SOT JTAKDIU KZHJTIVENHHT

I OZET TFXIACSTU SONV GTVVZPT RVNFP A ITETIVTU

ZHCOZYTS ZFU SOT JTAKDIU KZHJTIVENHHT

I OAET TFXIACSTU SOIV GTVVAPT RVIFP A ITETIVTU

AHCOZYTS AFU SOT JTAKDIU KAHJTIVEIHHT

I OAET TNXIACSTD SOIV GTVVAPT RVINP A ITETIVTD

AHCOZYTS AND SOT JTAKDID KAHJTIVEIHHT

I OAEE ENXIACSED SOIV GEVVAPT RVINP A IEEEIVED

AHCOZYES AND SOE JEAKDID KAHJEIVEIHHE

ABCDEFGHIJKLMNOPQRSTUVWXYZ

Z UT N F

I HAVE ENCRYPTED THIS MESSAGE USING A REVERSED

ALPHABET AND THE KEYWORD WALKERSVILLE

ABCDEFGHIJKLMNOPQRSTUVWXYZ

ZYXUTQPONMJHGFDCBIVSREKLAW

Page 6: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 6

Solving Monoalphabetic

Al-Kindi, 801-873 AD, Iraq

“A Manuscript on Deciphering

Cryptographic Messages”

Frequency Analysis

Black Chambers

France – Rossignol (1600’s)

England – Wallis (1600’s)

Austria – 1700’s

Page 7: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 7

Letter Counts

Gettysburg Address

FOURXSCOREXANDXSEVENXYEARS

XAGOXOURXFOREFATHERS…

ETNORIAS

Letter Frequencies

Ciphers & Frequencies

Caesar

Monalphabetic

Page 8: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 8

Breaking the Pattern I

Encrypt each letter differently

Polyalphabetic ciphers

Vigenere Cipher

Stream & Machine Ciphers

ENIGMA

SSL/RC4

Page 9: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 9

Polyalphabetic - Vigenère

Vigenere – Simple Polyalphabetic

Choose a key word

“Add” the key word to the plain

THISXSIMPLEXMESSAGEXISXENCRYPTEDXWITHXVIGENERE

CATCATCATCATCATCATCATCATCATCATCATCATCATCATCATC

VHBUXLKMINEQOELUAZGXBUXXPCKAPMGDQYIMJXOKGXPEKG

A+C=C

B+C=D

A+A=A

B+A=B

A+T=T

B+T=U

Add mod 26

Page 10: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 10

Vigenère (cont)

Key size = 26*26*...*26=26len

Attacks:

Recover keyword length

Statistical

Crib

Guess and fill out

Page 11: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 11

Vigenere w/ Keyword DO Vigenere w/ Keyword DONUT

Page 12: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 12

Babbage/Kasiski Attack I ZAWOKSXGONMXLDNYQPARTQSJPXRDPRJQKEGNQHDRDOWCRTXFAKIBDDRXQLSUO

ESTGNXFAKGKSTIKKMTSKPLHRZMSNKLKSMHKGQUKVKCLRXMWAFDTGTNDPVKYKQ

KAKYXSTGNXGAKVKCLRXMWAFDPVAADMVAKIBDDRXQWOKVNHTBTQOTJOWHDKUYL

BVBXLWFDMVAKQXMSBXWLDNYQTEIKQZAGZXFO

ZAWOKSXGONMXLDNYQPARTQSJPXRDPRJQKEGNQHDRDOWCRTXFAKIBDDRXQLSUO

ESTGNXFAKGKSTIKKMTSKPLHRZMSNKLKSMHKGQUKVKCLRXMWAFDTGTNDPVKYKQ

KAKYXSTGNXGAKVKCLRXMWAFDPVAADMVAKIBDDRXQWOKVNHTBTQOTJOWHDKUYL

BVBXLWFDMVAKQXMSBXWLDNYQTEIKQZAGZXFO

LDNY 190

XFAK 20

IBDD 105

STGN 65

KVKC 35

DMVA 40

GCD = 5

So key is 5 chars (probably)

ZAWOKSXGONMXLDNYQPARTQSJPXRDPRJQKEGNQHDRDOWCRTXFAKIBDDRXQLSUO

ESTGNXFAKGKSTIKKMTSKPLHRZMSNKLKSMHKGQUKVKCLRXMWAFDTGTNDPVKYKQ

KAKYXSTGNXGAKVKCLRXMWAFDPVAADMVAKIBDDRXQWOKVNHTBTQOTJOWHDKUYL

BVBXLWFDMVAKQXMSBXWLDNYQTEIKQZAGZXFO

Page 13: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 13

Babbage/Kasiski Attack II ZAWOKSXGONMXLDNYQPARTQSJPXRDPRJQKEGNQHDRDOWCRTXFAKIBDDRXQLSUO

ESTGNXFAKGKSTIKKMTSKPLHRZMSNKLKSMHKGQUKVKCLRXMWAFDTGTNDPVKYKQ

KAKYXSTGNXGAKVKCLRXMWAFDPVAADMVAKIBDDRXQWOKVNHTBTQOTJOWHDKUYL

BVBXLWFDMVAKQXMSBXWLDNYQTEIKQZAGZXFO

K 11%

D,X 7%

A 6%

Q,T 5.6%

Alpha 1

D,X 14%

K 12%

Alpha 2

Q 23%

X 19%

K,M 12%

Alpha 3

L,S 14%

W 12%

V 9%

Alpha 4

A 26%

T 16%

D 14%

Alpha 5

K 26%

R 21%

N,G 9%

ZHBLXSELLAMEQAAYXUXETXXGCXYIMEJXPBTNXMAEDVBZETEKXXIIIAEXXQPHO

LXQTNEKXXGRXQVKRRQFKWQEEZTXKXLRXJUKNVRXVRHIEXTBXSDALQADWAHLKX

PXXYEXQTNELXXVRHIEXTBXSDWAXNDTAXXIIIAEXXBLXVUMQOTXTQWODMAXUFQ

YIBEQTSDTAXXQERPOXDQAAYXYBVKXEXTZEKL

Guess #1:

Spacers (X) are: X, Q, S, A, K

Keyword is ATVDN

Guess #2:

Spacers (X) are: D, Q, L, A, K

Keyword is GTODN

THILXMESLAGEXAASXBXENXEGCRYPMEDXWBTHXTAEXVIZENERXXCIPAERXXPHI

LEQTHERXXAREQVERYQFEWXEETTEKXFREJUENCRXPROIERTIXSXASQAXWHHLEX

WXXSEEQTHESXXPROIERTIXSXWHXNXTHXXCIPAERXILXPUTQONXAQWIDTAXOFX

YIVEXTSXTHXXKEYPORDXAASXFBVEXLXTTERL

THIL_MESLAGE_AAS_BXEN_EGCRYPMED_WBTH_TAE_VIZENERX_CIPAER__PHI

LEQTHERX_AREQVERYQFEW_EETTEK_FREJUENCR_PROIERTIXS_ASQA_WHHLE_

WX_SEEQTHESX_PROIERTIXS_WHXN_THX_CIPAER_IL_PUTQON_AQWIDTA_OF_

YIVE_TS_THX_KEYPORD_AAS_FBVE_LXTTERL

THIS_MESSAGE_HAS_BEEN_ENCRYPTED_WITH_THE_VIGENERE_CIPHER__WHI

LE_THERE_ARE_VERY_FEW_LETTER_FREQUENCY_PROPERTIES_AS_A_WHOLE_

WE_SEE_THESE_PROPERTIES_WHEN_THE_CIPHER_IS_PUT_ON_A_WIDTH_OF_

FIVE_AS_THE_KEYWORD_HAS_FIVE_LETTERS

Solution:

Spacers (X) are: D, Q, L, T, K

Keyword is GTOWN

Alpha 1

D,X X,R

K E

Alpha 2

Q X

X E

K,M R,T

Alpha 3

L,S X,E

W I

V H

Alpha 4

A E

T X

D H

Alpha 5

K X

R E

N,G A,T

Page 14: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 14

Breaking the Pattern II

Use several letters per encryption

Digraphic

Hill’s Cipher

Playfair Cipher

Codebooks

DES, AES, et al

Page 15: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 15

Playfair

Digraphic cipher

2-letter blocks encrypt to 2-letter blocks

Confuses letter counts (monographics)

To Encrypt:

Both letters on same row - move right

Both in same column - move down

Otherwise - Opposite corners, same row

Example:

WH EA TS TO NE DE SI GN ED IT

AQ HP NT NQ UN IM NC EO MI DN

P L A Y F

I R B C D

E G H K M

N O Q S T

U V W X Z

Page 16: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 16

Polyalphabetic (alt view)

Another way of looking at it:

SAGEXISXENCRYPTEDXWITHXVIGENERE

+

CATCATCATCATCATCATCATCATCATCATC

VHBUXLKMINEQOEL

Page 17: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 17

Machine Ciphers

A Vigenere cipher with a long keyword

Page 18: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 18

Enigma

German military & police, 1930-45

Daily Key = 15896255521782636000 ~ 264

Total Key ~ (112 digits) ~ 2372

Page 19: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 19

Enigma: Basic Design

A

S

D

F

A

S

D

F

Page 20: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 20

Enigma - Key Space

Rotor Choice & Order: 6, 60, 1680

Rotor Wiring: 26! = 288.4 (27 digits)

Ring Settings: 263 = 17576 = 214.1

Plug/Stecker Settings: 150738274937250 = 247.1 (14 digits)

Page 21: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 21

Enigma: Attacks

Polish Work - 1930’s

Recovered wheel wiring from cipher

Bombe

British Work - 1940’s

Turing-Welchman bombe

Production scale recoveries

Rotor wiring - captures

Settings - bombe

Pluggings - crib loops &

diagonal board

Page 22: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 22

Codebooks, Playfair & Electronic Codebooks

P L A Y F

I R B C D

E G H K M

N O Q S T

U V W X Z

EA

HP

DES

This_is_

T@3a*bA1

AES

Now_is_the_time_

A#$0an^a]ci21+Ea

Codebook

X

Retreat

AB2236

Page 23: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 23

DES: Data Encrypt Standard

Developed by IBM

Adopted by NIST for Govt

Released 1976

64 bit (8 char) blocks

56 bit key space ~ 72057594037927936

1000 years on 1 GHz Pentium (very roughly)

3 days on EFF “Deep Crack” (1998)

No other (known) effective attacks

Page 24: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 24

AES: Advanced Encryption

Rijndael developed by Daemen & Rijmen

Catholic Univ of Leuven, Belgium

Adopted as AES by US Govt (2000)

128 bit (16 char) blocks

128 bit key space ~ 340282366920938463463374607431768211456

4722366482869645213696000 years on 1GHz Pentium

Page 25: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 25

Public-Private Keys

Key has two parts: Public & Private

Anyone can encrypt with the Public Key

Only owner has Private key to decrypt

RSA (1977) - Factoring

El Gamal (1985) – Discrete Logarithm

(1973)

Page 26: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 26

Diffie-Hellman

Key Agreement

Developed 1976 by Diffie, Hellman & Merkle

Based on “Discrete Logarithm” problem:

Computing gx(mod p) is easy

Given y, finding x so that y= gx(mod p) is hard

Developed by Malcolm Williamson, GCHQ, 1975

Page 27: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 27

Diffie-Hellman (cont)

Agree (openly) on g, p Say g=2, p=101

Choose secret xA, say xA = 37

Compute yA=gxA=237=55 (mod 101)

Alice Bob

Charlie

Choose secret xB, say xB = 15

Compute yB=gxB=215=44 (mod 101)

yA=55 yB=44

Compute yBxA=4437=69 (mod 101) Compute yA

xB=5515=69 (mod 101)

So the shared secret is 69

Page 28: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 28

WWW – An example

Go to an SSL-encrypted site

e.g. https://www.fortify.net/sslcheck.html

Little lock appears in browser

What Happened?

Server sent its public keys (certificate)

You used them to send key to server

Communicate, encrypted w/ shared key

Alice

Page 29: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 29

References (Selected)

- The Code Book, S. Singh, 1999

- The Codebreakers, D. Kahn, 1967 (2nd Ed, 1996)

- Codes and Ciphers, Churchhouse, 2001

- Elementary Cryptanalysis: A Mathematical Approach, A. Sinkov, 1966

- Making, Breaking Codes: An Introduction to Cryptology, P. Garrett

- Basic Cryptanalysis, http://www.fas.org/irp/doddir/army/fm34-40-2/

- Handbook of Applied Cryptography, Menezes, van Oorschot & Vanstone, 1996 http://www.cacr.math.uwaterloo.ca/hac/

- Wikipedia, http://en.wikipedia.org/wiki/Cryptography

- These Slides, http://www.umbc.edu/~rcampbel/MEPP/Cryptology

Page 30: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 30

Backup Slides

Page 31: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 31

Is E more common than T?

20 chars 100 chars

1000 chars

Page 32: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 32

Overview

Past

Substitution Ciphers

Permutations

Machine Ciphers

Present

Codebooks: DES & AES

Public Key

Page 33: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 33

Depth Reading

What if a very long keyword is used?

Book cipher

Page 34: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 34

Conclusions

Modern Cryptography can be used by

anyone, but…

Without some understanding, it can be

abused by anyone

Page 35: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 35

Permutation Ciphers

Rail-fence: TIIAALECCPEHSSRIFNEIHR

Used together with ciphers

Codes

Navajo code:

Ship = TOH-DINEH-IH

September = GHAW-JIH

JN-25 (Japanese Navy) Code:

SUBMARINE = 97850

Other Classical Crypto

TIIAALECCPE

HSSRIFNEIHR

T I I A A L E C C P E

H S S R I F N E I H R THISISARAILFENCECIPHER

Page 36: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 36

Enigma Details

Page 37: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 37

Cycles in Permutations ABCDEFGHIJKLMNOPQRSTUVWXYZ

WASHINGTOBCDEFJKLMPQRUVXYZ PWASH =

ABCDEFGHIJKLMNOPQRSTUVWXYZ

VWXYZBURLINGTOACDEFHJKMPQS PB5 =

GG and FNF and CSPKC

(AWVURMEIOJB)(DHTQL)(CSPK)(FN)(G)(X)(Y)(Z)

(BWMTHREZSF)(AVKNO)(GUJIL)(CXP)(DYQ)

G

G

F

N

N

F

C

S

S

P

P

K

K

C

Cycles of length 11, 5, 4, 2, 1, 1, 1 and 1

Page 38: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 38

Cycles in Permutations ABCDEFGHIJKLMNOPQRSTUVWXYZ

WASHINGTOBCDEFJKLMPQRUVXYZ PWASH =

(AWVURMEIOJB)(DHTQL)(CSPK)(FN)(G)(X)(Y)(Z)

ABCDEFGHIJKLMNOPQRSTUVWXYZ

VWXYZBURLINGTOACDEFHJKMPQS PB5 =

(BWMTHREZSF)(AVKNO)(GUJIL)(CXP)(DYQ)

ABCDEFGHIJKLMNOPQRSTUVWXYZ

MVFRLOUHAWXYZBINGTCDEJKPQS PB5 PWASH =

(AMZSCFOI)(BVJWKXPN)(ELYQGU)(DRT)(H)

P-1WASH PB5 PWASH =

ABCDEFGHIJKLMNOPQRSTUVWXYZ

RWNUQIVDBAXYZJEFGHKLMOPSTC (ARHDUMZCNJ)(BWPFI)(EQGVO)(LYT)(KXS)

Page 39: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 39

Cycles in Enigma

Given cycle type of Enigma permutation

Try all the 6*26*26*26 wheel settings

Check the cycle type

If it matches, we found wheel setting

Then pluggings are just monoalphabetic

Page 40: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 40

Indicators & Cycles

Message Indicators:

Start with a fixed daily setting

Choose random “indicator”: (i1i2i3) AQP

Encrypt it: AQPAQP YALSWY

See many examples over day:

p1: i1Y and p4: i1S, so p4 p1: YS

Also p5 p2: AW and p6 p3: LY

From SJEZSX get p4 p1: SZ, etc

Eventually, get p4 p1: [7,5,5,3,3,2,1]

Page 41: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 41

Enigma: Crib Loops

Encryption: P*W(t)*P

Guess a crib

Find a “loop”: ABCA

P*W(1)*P*P*W(2)*P*P*W(3)*P = Id

W(1)*W(2)*W(3) = Id

Example:

ZMGERFEWMLKMTAWXTSW - cipher

OBERKOMMANDODERWEHR - crib

AMEA (in W(9)*W(7)*W(14))

Page 42: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 42

References - Enigma

Enigma, W. Kozaczuk, 1984 – Technical

details in appendices

Seizing the Enigma, D. Kahn, 1991 – History

of Naval Enigma

http://www.codesandciphers.org.uk/enigma/

http://en.wikipedia.org/wiki/Enigma_machine

Enigma Notes, A. Biryukov

[http://www.wisdom.weizmann.ac.il/~albi/cryptanalysis/lectures.htm]

Page 43: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 43

Public Key

Page 44: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 44

Public Key aka Non-Secret Encryption

The Key Management Problem

Agree on a secret key without meeting

The digital signature problem

How do I know this is from him?

Generally based on “hard” problem

Factoring Problem

Discrete Logarithm Problem

Page 45: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 45

Public-Key Developing the Concepts

Diffie & Hellman - New Directions in

Cryptography, Nov 1976

Merkle - Secure Communications over

Insecure Channels, 1975-78

Ellis – The Possibility of Non-Secret

Encryption, Jan 1970

Bell Labs - Final Report on Project C43,

October 1944

Page 46: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 46

Public-Key Concepts One-Way Functions

One-Way Function:

Computing y=F(x) is “hard”

Computing x=F-1(y) is “easy”

Trap-Door Function:

Computing y=F(x) is “hard”

Unless, you know some secret S, in which case

computing y=F (x) is “easy”

Example: Table lookup is easy, reverse lookup

is hard

Need good definition of “easy” and “hard”

Page 47: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 47

RSA Choose secret primes p, q

Compute public modulus N= pq

Choose public encrypt exponent e

Compute secret decrypt exponent:

d=e-1(mod (p-1)(q-1))

Secret Key = {d}

Alice Bob Charlie

Choose secret (plaintext) message, P

Encrypt message: C = Pe (mod N)

Public Key = {N,e}

Encrypted Message = C

Compute Cd (mod N)

Note that the result is P

So the secret message, P, has

been passed from Bob to Alice

Page 48: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 48

RSA Worked Example Choose secret primes p=17 q=23

Compute modulus N= pq=391

Choose encrypt exponent e=3

Compute secret decrypt exponent:

d =e-1(mod (p-1)(q-1)) = 3-1 (mod

(17-1)(23-1)) =3-1(mod 351) = 235

Secret Key = {d=235}

Alice Bob Charlie

Choose secret message, 10

Encrypt message: C = Pe (mod N) =

103 (mod 391) = 218

Public Key = {391,3}

Encrypted Message = 218

Compute Cd (mod N) = 218235 (mod 391)

Note that the result is P = 10

So the secret message, P=10, has

been passed from Bob to Alice

Page 49: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 49

Modular Arithmetic

Page 50: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 50

Modular Arithmetic I

Binary Arithmetic (mod 2)

Addition:

Even + Even = Even [0 + 0 = 0 (mod 2)]

Even + Odd = Odd [0 + 1 = 1 (mod 2)]

Odd + Odd = Even [1 + 1 = 0 (mod 2)]

Multiplication:

Odd * Odd = Odd [1 * 1 = 1 (mod 2)]

Even * Odd = Even [0 * 1 = 0 (mod 2)]

Even * Even = Even [0 * 0 = 0 (mod 2)]

Division:

Odd/Odd = Odd [1/1 = 1 (mod 2)]

Even/Odd = Even [0/1 = 0 (mod 2)]

Anything/Even = ??? [X/0 = ? (mod 2)]

Page 51: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 51

Modular Arithmetic II

Arithmetic mod 101 (Note: 101 is prime) Addition:

35 – 56 = -21 = 80 (mod 101)

Multiplication: 23 * 52 = 1196 = 85 + (11 * 101) = 85 (mod 101)

Division: 85/23 = 52 (mod 101) (as 23*52 = 85)

(Extended Euclidean Algorithm)

Exponentiation: 534 = 88 (mod 101)

Russian Peasant Algorithm: • 52 = 25

• 54 = (52)2 = (25)2 = 625 = 19

• 58 = (54)2 = (19)2 = 361 = 58

• 516 = (58)2 = (58)2 = 3364 = 31

• 532 = (516)2 = (31)2 = 961 = 52

• So 534 = (52+32) = (52)(532) = (25)(52) = 1300 = 88 (mod 101)

Page 52: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 52

Modular Arithmetic III

Arithmetic mod 26 (Note: 26 = 2*13) Addition:

25 + 5 = 30 = 4 (mod 26)

10 – 22 = -12 = 14 (mod 26)

Multiplication: 5 * 12 = 60 = 8 + (2 * 26) = 8 (mod 26)

6 * 13 = 78 = 0 + (3 * 26) = 0 (mod 26)

(Product of non-zeros can be zero)

Division: 12/5 = 18 (mod 26) (as 5*18 = 12)

21/2 = ?? (mod 26)

(Can’t divide by any multiple of 2 or 13)

Page 53: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 53

Fast Exponentiation I

Compute 232(mod 41) Hard Way:

Compute 232, then reduce mod 41

232 = 2*...*2= 4294967296 = 37 (mod 41)

Better:

Reduce at each step

2*2*2*2*2*2 = 64 = 23 (mod 41)

23*2 = 46 = 5 (mod 41) … etc

Best (almost):

232(mod 41) = (((((22)2)2)2)2) (mod 41)

Page 54: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 54

Fast Exponentiation II Russian Peasant Arithmetic

Compute 337 (mod 51) Note: 37 = 1001012

37 = ((((((1)2+0)2+0)2+1)2+0)2+1)

So 337 = 3(((((2)2)2+1)2)2+1)

= (((((3)2)2)2)*3)2)2*3)

So ….

(3)2 = 9, then ((3)2)2 = 92 = 81 = 30

((((3)2)2)2) = 302 = 900 = 33 ((((3)2)2)2)*3 = 33*3 = 99 = 48

(((((3)2)2)2)*3)2 = 482 = 2304 = 9

((((((3)2)2)2)*3)2)2 = 92 = 81 = 30

((((((3)2)2)2)*3)2)2*3) = 30*3 = 90 = 39

Page 55: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 55

Hill Cipher

Page 56: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 56

Hill’s Cipher

Matrix Multiply: C = P*M (mod 26)

21

32M

Example:

HI LL CI PH ER

(7,8)(11,11)(2,8)(15,7)(4,17)

(22,37)(33,55)(12,22)(37,59)(25,46)

(22,11)(7,3)(12,22)(11,7)(25,20)

WL HD MW LH ZU

26mod

225

2321

-M

Page 57: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 57

A Toy Hill

C = aP + b (mod 26)

Example: a = 3; b = 2

AXHILLXCIPHERXTOY

CTXAJJTIAVXOBTHSW

e.g. X23

so (3)(23)+2=71-(2)(26)=19 (mod 26)

And 19T

Problems?

If a=6; b=5 then AF and NF

If a=13; b=3 then AD, CD, ED, …

Why?

Page 58: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 58

Breaking Hill Given a Crib …

Cipher: WL HD = (22,11)(7,3)

Plaintext guessed: HI LL = (7,8)(11,11)

wz

yxM

26mod1111

87

37

1122

wz

yx

PMC

Get Equations:

22 = 7x + 8z (mod 26)

11 = 7y + 8w (mod 26)

7 = 11x + 11z (mod 26)

3 = 11y + 11w (mod 26)

Solve: x=2; y=3; z=1; w=2

Page 59: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 59

Vigenere w/ Keyword DONUT

Hill Cipher

Page 60: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 60

Topics in Crypto & Math

Combinatorics

Statistics

Group Theory

Algebra

Number Theory

Page 61: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 61

Combinatorics

Keyspace of a scrambled alphabet

How many ways can I scramble a 26-letter alphabet?

26! = (26)(25)(24)…(3)(2)(1) = 403,291,461,126,605,635,584,000,000

Keyspace of the Enigma

Choosing Wheels

Example: 3 Wheels out of 5 – (5)(4)(3) = 60

Steckerboard Keyspace

Example: 5 Cables – (26)(25)(24)(23)(22)(21)(20)(19)(18)(17)/((25)(5!)) = 6425074656

Page 62: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 62

Statistics

Language Statistics

Monographic: ETNORIAS

Digraphic: QU, ED, etc

Statistical Tests

f-Test – Test for Monoalphabetic

2-Test

IC (Index of Coincidence) Test

Page 63: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 63

Group Theory

Permutation Groups

Enigma

Bombe Cribs & Loops – Cycle structure

is constant in a conjugacy class.

Page 64: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 64

Algebra

Cribs

Cipher = Plain + Key

If we see Cipher and can guess Plain

Then we recover Key = Cipher - Plain

Diffie-Hellman Public Key

(ga)b = (gb)a

Hill Cipher

C = MP

Given a crib, solve as a linear system

Page 65: JRRG PRUQLQJ, PB QDPH LV UREHUW FDPSEHOOcampbell/MEPP/Cryptology/Cryptology-Past-Present.pdfRail-fence: TIIAALECCPEHSSRIFNEIHR Used together with ciphers Codes Navajo code: Ship =

5/12/2014 65

Number Theory

Diffie-Hellman

RSA Public Key

Fermat’s Little Thm & the f-Function

Finite Fields

Used in AES construction