<<

ISA562 InformationSecurityTheory&Practice

Introductionto

Agenda

• Basics&Definitions • ClassicalCryptography • Symmetric(Secret)Cryptography • DES(DataStandard) • Multiple • ModesofBlockOperations • MathEssential • Asymmetric(PublicKey)Cryptography

2

1 Basics& Definitions

SecurityConcepts(I)

• Confidentiality – Preventinformationfrombeingexposedtounintendedparty – Ex:Anemployeeshouldnotcometoknowthesalaryofhis manager • Integrity – Assurethattheinformationhasnotbeentempered – Ex:Anemployeeshouldnotbeabletomodifytheemployee's ownsalary • Identity – Assurethatthepartyofconcernisauthentic itiswhatitclaims tobe – Ex:Anemployeeshouldbeabletouniquelyidentifyand authenticatehimself/herself

4

2 SecurityConcepts(II)

• Availability – Assurethatunusedserviceorresourceisavailableto legitimateusers – Ex:Paychecksshouldbeprintedontimeasstipulatedby law • Anonymity – Assurethattheidentityofsomepartyisremainanonymous – Ex:Themanagershouldnotknowwhohadacritical reviewofhim • NonRepudiation – Assurethatauthenticatedpartyhasindeeddonesomething thatcannotbedenied – Ex:Oncetheemployeehascashedhispaycheck,hecan’t denyit. 5

Cryptography

=secret • Graph =writing

• Cryptography isthescience/artoftransforming meaningfulinformationintounintelligibletext Becomingasciencethatreliesonmathematics (numbertheory,algebra) • isthescience/artofbreaking cryptographiccodes • Cryptology isthescience/art/studyofboth cryptographyandcryptanalysis

6

3 ApplicationsofCryptography

• Assuringdocumentintegrity • Assuringdocumentconfidentiality • Authenticatingparties • Documentsignature • Nonrepudiation • Securetransactions • Exchangingkeys • SharingSecrets • Digitalcash • Preservinganonymity • Copyrightprotection • More...

7

CryptographicServices(I)

StartFromTheBasics

AB AB

C a) SourceIntegrity b) DataConfidentiality NormalFlow Eavesdropping

AB AB

C C c) DataIntegrity d) Source Authentication Modification Fabrication

8

4 CryptographicServices(II)

AB AB

C e) Drop f) Replay

AB

C g) DenialofService

9

Encryption/DecryptionBasicDefinitions

plaintext plaintext encryption decryption

key key

• Plaintext: amessageinitsoriginalform • Ciphertext: amessageinthetransformed,unrecognizedform • Encryption: theprocessthattransformsaplaintextintoaciphertext • Decryption: theprocessthattransformsaciphertexttothecorresponding plaintext • Key: thevalueusedtocontrolencryption/decryption.

10

5 CryptanalyticAttackDefinitions

• KnownCipehrtext – Onlytheciphertext isknowntoattacker – Cryptanalysisaimsatrevealingtheplaintextand/orthekey • KnownPlaintext – Pairsof<plaintext,ciphertext >areknowntoattacker – Cryptanalysisaimsatrevealingthekey – Relevantwhenplaintextisknown/canbeobtained • ChosenPlaintext – Attackerchoosestheplaintextandreceivestheciphertext – Cryptanalysisaimsatrevealingthekey – Relevantwhenattackercan“inject” plaintextmessages

11

ClassicalCryptography

6 AlittleHistory

• Cryptographywasfirstusedbyearlycivilizations (includingEgyptians,Greeks,Romans)forSecrecy (Confidentiality )… nowevolvedtoinclude Integrity , Authentication & Authenticity ,andinsomecases NonRepudiation . • Earlyuseofcryptographyconsistedofencryptionby substitution methods and/or transposition methods – Theywererathersimplebecauseofthelackof sophisticatedcomputingengines – Canbeeasilyattacked • Samemethodsareinusetoday,butwithstronger propertiesandmorepowerfulcomputingengines

13

SubstitutionMethods

• Methodsinwhichthelettersofthealphabetarereplacedwith otherletters/numbers/symbols. • Examples: – CaesarCipher – fixedpermutation – ShiftCipher – fixedpermutation – MonoAlphabetic – oneofmanypermutations – PolyAlphabeticCiphers – changingpermutations – Vig`enere Cipher – multipleMonoAlphabeticCiphers – *RunningKeyCipher – Simpleyeteffective • Algorithmisknown– Keyis“index” ofpermutation,butnotfor *RunningKeyCipher

14

7 CaesarCipher

• NamedafterJuliusCaesar,whosupposedlyinventedithimself • Cyclicshiftofthe26lettersofthealphabetby3:

abcdefghijklmnopqrstuvwxyz DEFGHIJKLMNOPQRSTUVWXYZABC • Inmathematicalterms: C=ENC(P)=P+3(mod26) • Forexample:GMU → JPX • Thesecrecyisinthealgorithm(!!!!) • Thereisonekey(fixedpermutation) • Easytobreak(ifalgorithmisknown)

15

AShiftCipher

• AShiftCipherissimilartoaCaesarCipher,butthereisa cyclicshiftofthe26lettersofthealphabetbykeyK,where 0≤ K<26. • Inmathematicalterms:

C=ENC K(P)=P+K(mod26) • Algorithmisknown • Thereare26differentkeys • Easytobreak– checkwhichof26possiblekeysreturnsthe unintelligibleciphertext toameaningfulplaintext • DecipherHAL(thecomputerfromthemovie2001: A Space Odyssey )usingashiftcipherofone. – Sotheshiftvariablen=1. • HAL ?

16

8 MonoAlphabeticCiphers

• Generalization:arbitrarymappingofoneletterto another • OneofN!permutationsonNlettersofthealphabet • Thekeyistheindexofthepermutation • Algorithmisknown(monoalphabeticcipher) • Keyissecret(oneofN!options) • Example: – N=26lettersoftheEnglishalphabet – N!=26!≈ 4• 10 26 ≈ 288 permutationsor 309 Septillion – ≈ 309,485,009,821,345,000,000,000,000permutations • ISITSECURE? 17

NotwithFrequencyAnalysis

• Cryptanalysisformallybeganinlaterpartofthefirst millenniumADintheMiddleEast. • Frequencyanalysisisthestudyofthefrequencyof occurrenceofletters.(statistics) • Firsttreatiseonfrequencyanalysiswaswrittenby Ab‾uY‾us‾uf Ya‘q‾ub ibn Ish‾aq ibn asSabb‾ah ibn ‘omr‾an ibn Isma‾il alKind‾i,the“philosopher oftheArabs.”

18

9 AttackingMonoAlphabeticCiphers(I)

• Englishishighlyredundant,asshowninthenext slide,ithasanonuniformdistributionofletters. • Eachsymbolofciphertext dependsononlyone symbolofplaintextandonevalueofthepermutation key,soguessingpartofthekeygivespartofthe plaintext. • Attackproceedsbyguessingpartsofkey correspondingtomostcommonletters,whichmakes itpossibletodecipherentiremessage.

19

Theproblem:LetterFrequencies

20

10 AttackingMonoAlphabeticCiphers(II)

• Appearancefrequencyofletters(inlongenoughtexts)inthe languageiswelldeterminedasshownbythepreviousslide. • Appearancefrequencyofpairsoflettersinthelanguageiswell defined: th,ee,oo,tt,qu,is,ae,... • Appearancefrequencyofcertainwordsinthelanguageiswell definedaswell: the≈ 6.4% a≈ 2.1% i≈ 0.9% of≈ 4.0% in≈ 1.8% it≈ 0.9% and≈ 3.2% that≈ 1.2% for≈ 0.8% to≈ 2.4% is≈ 1.0% as≈ 0.8%

21

AttackingMonoAlphabeticCiphers(III)

• Usingtheappearancefrequenciesofletters,words, andpairsofletters– acceleratestheidentificationof certainlettersubstitutions(whicharepartofthekey) • Identificationofwordpatterns,vowels,and consonantshelpsinfindingpartsofthetext • Theidentificationoftheremainingpartsofthekey nowreducesthesearchspacedramatically(fromN!) • Usingheuristicsandassociativewordcompletions, therestofthekeycanbeeasilyrevealed

22

11 SummaryofEnglishLanguageFacts

1. mostcommonletters:E,T,A,O,I,N,S,H. 2. morethanhalfofallwordsendinE,T,D,S. 3. QisalwaysfollowedbyU. 4. mostcommonword:“THE.” 5. mostcommondoublets:EE,TT,OO,SS,LL,FF. 6. mostcommon2lettercombos:HE,RE,AN,TH, ER,IN. 7. mostcommon3lettercombos:ION,AND,ING, THE,ENT.

23

Possiblesolutions

• Youcantrynottouseredundantletters,liketheletter “e”,aswasdonebyaFrenchwriternamedGeorges Perec in1969.Hepublisheda300pagenovel La Disparition (TheDisappearance).Itwastranslated intoenglish byGilbertAdairandiscalled“AVoid”. • OryoucanyouagroupofdifferentMonoAlphabetic Ciphersatdifferentpartsoftheplaintext called PloyAlphabeticCiphers. • Oryoucangrouptheplaintextintoblocksthatwill thengothroughsometransformation.

24

12 PolyAlphabetic Ciphers

• UsedifferentMonoAlphabeticCiphersatdifferentpartsofthe plaintext • UsingmanyMonoAlphabeticCipherswillmoreorless equatetheappearancefrequenciesofletters • Welldesigned,andsufficientlylong,PolyAlphabeticCiphers canbe quite strong • AcommonschemetobuildaPolyAlphabeticCipher: – UseacollectionofrelatedMonoAlphabeticCiphers – UseakeytodeterminewhichoneoftheMonoAlphabetic Ciphersinthecollectiontouseateachstage

25

Vig`enere Cipher(I)

• Blaise deVig`enere:(1523)CreatestheVig`enere cipher. • Thoughttobetooslowandcumbersomeforwarfare,the Vig`enere cipherwasunusedalmost200years. • Vig`enere Cipherisonetypeof Poly-Alphabetic Cipher • ThecollectionofMonoAlphabeticCiphersconsistsofthe26 optionsforCaesarCipher(withK=0,1,2,...,25) • Eachofthe26CaesarCiphersisdenotedbyaletter,whichis theciphertext letterthatreplacestheletter‘a’ • Inpractice: – Atableof26rowsby26columnsisbuilt.Rowiinthetable containsthe26lettersofthealphabetcircularlyshiftedbyi. – Akeywordisused(overandoveragain)toselectwhichofthe monoalphabeticcipherstouse.Thecipherusedisselectedby thecurrentletterinthekeyword.

26

13 Vig`enere Cipher(II)

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 F 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 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

27

ClassExerciseusingVig`enere Cipher

• Keyword: GMU • Plaintext:SECURITY • Ciphertext:

28

14 Vig`enere Cipher(III)

• ThestrengthofVig`enere Cipherisbasedonthefact thattherearemultipleciphertext letterstowhicheach plaintextlettercanbemapped • Question : Tohowmanypossibleciphertext letters canasingleplaintextletterbemapped?

29

AttackingVig`enere Cipher

• CheckwhetherthecipherisMonoAlphabetic – Checkwhethertheappearancefrequencyoflettersinthe ciphertext complieswiththatofaMonoAlphabeticcipher • Determinethelengthofthekeyword – Iftwoidenticalsequencesofplaintextlettersoccuratadistance thatisanintegermultipleofthekeywordlength– thanthetwo correspondingsequencesofciphertext letterswillbeidentical – Detectidenticalsequencesofciphertext letters – ConjecturethatthekeywordlengthistheGCD(greatest commondivisor)ofdistancesbetweenidenticalsequencesof ciphertext • NeutralizeshiftsandbreakeachofthesuspectedMono AlphabeticCiphersindependently

30

15 RunningKeyCipher

• Doesn’tusemathematicalformulas,insteadeveryday items. • Forexampleasetofbooks – Numbersaresentrepresentingbooknumber,page number,linenumber,andwordnumber.

31

TranspositionMethods

• Generalization:Lettersarerearrangedinaparticularfashion. • PlaintextisbufferedinabufferofsizeNcharacters • Plaintextisscrambledbyafixedtranspositiononthelocations of thecharactersinthebuffer

• Algorithmisknown • Keyistheindicationofthetranspositionmapping

32

16 Spartan

• Scytale (5fhCenturyBC)– Usespaperorleatherandiswrappedaroundrod (cylinder).Thetextiswrittenalongthelengthofthescytale,andthenthestripis unwounded.Theresultisalongmeaninglessstring.

33

RailFenceCipher

• Method – Plaintextiswrittendownasasequenceofdiagonals andthenreadofasasequenceofrows • Example: mematrhtgpry etefeteoaat • Plaintext: – meetmeafterthetogaparty

34

17 RowColumnCipher

• Plaintextiswritteninarectangle,rowbyrow,and ciphertext isreadfromtherectangle,columnby column,inapermutedcolumnorder • Example: Key: 24153 Plaintext: attac kfrom easta tdawn • Ciphertext: trsaaketcmantfadaotw

35

AttackingTranspositionMethods

• ApureTranspositionCiphercanbeeasily recognized,becauseithasthesameletterappearance frequenciesastheoriginaltext • Appearancefrequenciesofdigramsortrigramsmay alsobeusefulinbreakingthe • Frequentplaintextwords(orcombinationsofletters) mayrepeatatsamelocationsinmanybuffers,which willresultinrepetitionofcertainlettercombinations intheciphertext • Keycanbedeterminedbyplacingtheciphertext ina rectangleandplayingwiththerowsandthecolumns

36

18 Rotor Machines (I)

• RotorMachinescombineprinciplesofSubstitution Methods andTranspositionMethods • RotorMachinesproduceciphersthatareverydifficult tobreak • RotorMachinesinWorldWarII: – “Enigma” usedbytheGerman – “Purple” usedbytheJapanese • ThebreakingofbothRotorMachinesbytheAllies wasasignificantfactorintheoutcomeofthewar

37

RotorMachineExample

38

19 ConcealmentCipher

• ConcealmentCipher – Isamessagewithinamessage. – Forexamplethe3 rd wordfromthefollowingsentences isthekey:

GMUstudentstake securityclassveryseriously. Theystudya goodeighthoursaday,everyday. Theycanbreak manyoftheclassicalciphers.

39

Symmetric(SecretKey) Cryptography

20 ConditionalCryptography

• Cryptographicschemes,forwhichwedonothavea mathematicalproofthattheyare100%secure • Anopponentcanbreakthescheme: – ifunlimitedtextisavailable – ifunlimitedtimeisavailable – ifunlimitedcomputingpowerisavailable • Strengthofsuchaschemereliesontheassumptionthatthe opponentdoesnothavesufficientresources(text,time, computers,money,etc.)tobreakthescheme • Allmodernpracticalcryptographicschemesareonly conditionallysecure

41

Xor Basics

42

21 Notations

• A– Alice (oneparty) • B– Bob (anotherparty) • E– Eve (eavesdropper/attacker) • M– Message (plaintext,sometimessecret) • K– Key (highlysecret) • C– Cipher (ciphertext,seenbyattacker) • ENC–Encryption (secret/known) • DEC– Decryption (secret/known) • AUTH– Authentication (secret/known) • VER– Verification (secret/known)

43

SymmetricCryptography

• Samekeyisusedonbothsides • Algorithmsareusuallysimilaronbothsides

44

22 SymmetricEncryption

• AencryptsthemessageMusingthealgorithmENCwiththe keyKtoobtainthecipherC • BdecryptsthecipherCusingthealgorithmDECwiththekey KtoobtainthemessageM • KeyKissymmetric,secret,andknownonlytoAandB

45

DES(DataEncryptionStandard)

23 DES(DataEncryptionStandard)History

• In1973,NBS(NationalBureauofStandards)came outwithanRFP(RequestforProposals)fora commercialencryptionstandard • IBMproposeditsstrongLuciferalgorithm (developedbyFeistel andothers) • NSA(NationalSecurityAgency)requestedtoweaken thestrengthofLucifer(byshorteningthekey) • NSAalsomadechangestoIBM’sLuciferalgorithm • DataEncryptionStandard(DES)acceptedin1976 anditexpired22yearslater,in1998.

47

DESDesignCriteria

• NBShadsetthefollowingdesigncriteriaforDES: – Algorithmmustprovidehighlevelofsecurity – Algorithmmustbecompletelyspecified – Securityofthealgorithmmustresideinthekey – Algorithmmustbeavailabletoallusers – Algorithmmustbeadaptableforuseindiverseapplications – Algorithmmustbeefficientlyimplementedinhardware – Algorithmmustbeefficienttouse – Algorithmmustbeabletobevalidated – Algorithmmustbeexportable

48

24 DES

• DESisawidelyusedmethodofdataencryption usinga(secret)keythatwasjudgedsodifficultto breakbytheU.S.governmentthatitwasrestricted forexportationtoothercountries. • Thereare72,000,000,000,000,000(72quadrillion) ormorepossibleencryptionkeysthatcanbeused. Foreachgivenmessage,thekeyischosenat randomfromamongthisenormousnumberofkeys. • Likeotherprivatekeycryptographicmethods,both thesenderandthereceivermustknowandusethe sameprivatekey.

49

DESStructure

• Blocksize– 64bits • Keysize– 64bitquantity=(8bitparity)+(56bitkey) – Every8thbitisaparitybit. – 16roundkeys(48bits)derivedfromkey(56bits) • 16iterationseachconsistingofscramblingtheroundblock(64bits)with theroundkey(48bits) • 64bitinput,64bitoutput.

64bitM 64bitC DES Encryption

56bits

50

25 DemoTime

• TheDemoisasummaryofthenext 15 slides.

51

DESOverview 56bitKey 64bitInput Generatekeys Permutation InitialPermutation 48bitK1 Round1 48bitK2 Round2 …... 48bitK16 Round16

Swap Swap32bithalves

Permutation FinalPermutation

64bitOutput

52

26 InitialandFinalPermutations

• Initialpermutation(IP) • ViewtheinputasM:8 × 8bitmatrix • TransformMintoM1intwosteps – Transposerowxintocolumn(9x),1 ≤x ≤8( equivalent to90º clockwiseturnofthematrix ) – Applypermutationontherows: • Forevenrowy,itbecomesrowy/2 • Foroddrowy,itbecomesrow(5+y/2) • Note:FinalpermutationFP=IP 1

53

InitialBitPermutation(1to1)

1234 64 ……. Input: b1 b2 b3 b4 b64

1bit

Output …….. b58 b50 b42 b34 b7 58504234 7

54

27 PerRoundKeyGeneration

• InitialKeyhas64bits • RemoveEvery8 th bit: – Remove8,16,24,32,40,48(paritycheck) • Endupwith56bits: – Nowdoaninitialpermutationofthe56bitkey: – Firsthalf(28bits)=Co

– Secondhalf(28bits)=D 0

55

PerRoundKeyGeneration InitialPermutationofDESkey

C i1 28bitsD i1 28bits

CircularLeftShift CircularLeftShift

Permutation Round1,2,9,16: withDiscard singleLshift Others:twoRbits 48 bitsKi

C i 28bitsD i 28bits

56

28 Round(i)

• 64bitinputbrokendownintotwohalfs

•Li andRi (32bitseach) • Recursivelydefine:

•Li+1 =Ri

•Rn+1 =mangler(R n,k n)(+)L n

Pictorially

57

ADESRound(i)

32bits Li 32bits Ri

E

OneRound 48bits Ki Encryption Mangler Function SBoxes

P

32bits

32bits Li+1 32bits Ri+1 58

29 Mangler Function

4 4 4 4 4 4 4 4 subkey 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6

+ + + + + + + +

S1 S2 S3 S4 S5 S6 S7 S8 Thepermutationproduces “spread” amongthe 4 4 4 4 4 4 4 4 chunks/Sboxes!

Permutation

59

BitsExpansionintheMangler Function

12345 32 Input: 00101……. 1

Output

10010101…….. 10 12345678 48

60

30 EBoxofDES

• HowistheEBoxdefined?

32 1234 5 4 5678 9 8 9101112 13 12 13141516 17 16 17181920 21 20 21222324 25 24 25262728 29 28 29303132 1

61

SBox(SubstituteandShrink)

• 48bits==>32bits.(8*6==>8*4) • 2bitsusedtoselectamongst4permutationsforthe restofthe4bitquantity

2bits I1 row I2 I3 O1 Si O2 I4 O3 I5 O4 anintegerbetween 4bits I6 0and15. column i =1,…8.

62

31 SBox(Cont’d)

Eachrowandcolumncontaindifferentnumbers.

012 3 456… 15

014413121511

10157414213

2 411481362

3151282491

Example:input: 10011 0 output:???

63

DESStandard

• CipherIterativeAction • KeyGenerationBox – Input: 64bits – Input: 56bits – Key: 48 bits – Output: 48 bits – Output: 64bits

Oneround(Total16rounds)

64

32 Feistel CipherEncryption

Ln Rn

mangler Kn

Ln+1 Rn+1

65

Feistel CipherDecryption

Ln Rn

mangler Kn

Ln+1 Rn+1

66

33 ImportantPropertiesofDESRound

• ThedecryptioninaDESrounddoesNOTrequirethe mangler functiontobereversible! • Thedecryptionof64bitblockinaDESroundis equivalenttoencryptionofthe64bitblock(by swappingthe32bithalves)withthesamekey

67

AvalancheEffect

• Asmallchangeineithertheplaintextorthekeyshould produceasignificantchangeintheciphertext. • DEShasastrongavalancheeffect. • Example – Plaintexts:0X0000000000000000and0X8000000000000000 – Samekey:0X016B24621C181C32 – 34bitsdifferenceinciphertexts – Similarresultwithsameplaintextandslightlydifferentkeys

68

34 ConcernsAboutDES

• Keyspaceproblem:56bitkey(2 56 ) – DESCHALLrecoveredRSAchallengeIkeyonJune 17,1997(6monthintothecontest) – $.25m(totalcost),July15,1998,RSADESchallenge IIkeyrecoveredin56hours – Presumably,mostnationalsecurityagencieshavethe hardwareandsoftwaretocrackDESinhours

69

DESSummary

• Simple,easytoimplement: – Hardware/gigabits/second,software/megabits/second • 56bitkeyDESmaybeacceptablefornoncritical applicationsbuttripleDES(3DES)shouldbesecure formostapplicationstoday • Supportsseveraloperationmodes:ECBCBC,OFB, CFB

70

35 Rijndael Demo

Timepermitting

71

MultipleEncryption

36 MultipleEncryption

• MajorlimitationofDES – Keylengthistooshort(56bits). • Question:CanweapplyDESmultipletimesto increasethestrengthofencryption? – Advantage:preservetheexistinginvestmentin softwareandequipment.

73

DoubleDES(I)

• ApplytwoiterationsofDESwithtwokeysK1and K2

• WhatifDEShasastructureofanalgebraicgroup, suchthatforeachK1andK2thereisaK3withthe property:

Ek2 (E k1 (P))=E k3 (P) • Thisisnotthecase(provedin1992) • BUT isthesecuritylevelO(2 112 )?

74

37 DoubleDES(II)

MeetintheMiddleAttack: • ForgivenMandC– searchonlyO(256)pairsofkeysK1and K2attheintermediatepointI

56 • EncryptMunderall2 optionsforK 1 56 – DenotetheresultsbyX 1,X 2,...,X 2 56 • DecryptCunderall2 optionsforK 2 56 – DenotetheresultsbyY 1,Y 2,...,Y 2

75

DoubleDES(III)

MeetintheMiddleAttack(continued): 56 • SortthevaluesX 1,X 2,...,X 2 56 • SortthevaluesY 1,Y 2,...,Y 2 • FindcollisionsbetweenvaluesofX i andYj – there shouldbeabout(2 112 /2 64 )=2 48 suchcollisions 48 • Markthe2 potentialcandidatesforkeypairK 1 and K2 • TakeanotherpairM’ andC’,andrepeattheabove testwiththenewpairandthesuspected2 48 keypairs • ThesecondtestwillpindownthecorrectpairK1and K2(sincethesuccessratewillbe(2 48 /2 64)=2 16 )

76

38 DoubleDES(IV)

MeetintheMiddleAttack(continued): • Timerequirementofattack– forencryptions, decryptions,sorting,andcomparing: aboutO(2 64 )steps • Spacerequirementofattack– forkeepingthe encryptionanddecryptionvalues: aboutO(2 60 )bytes • Althoughattackisnotverypractical– itis sufficientlyintriguingtoconsiderDoubleDESnot secureenough

77

TripleDES(I)

• EEEMode:

– DESEncryptEncryptEncryptwiththreekeysK 1,K 2,andK 3

• Properties: – Threekeys(168bits) – StrengthaboutO(2 110 )againstMeetintheMiddle – NotcompatiblewithregularDES

78

39 TripleDES(II)

• EDEMode:

– DESEncryptDecryptEncryptwithtwokeysK 1,&K 2

• Properties: – Twokeys(112bits) – StrengthaboutO(2 110 )againstMeetintheMiddle

– CompatiblewithregularDESwhenK 1=K 2

79

EDEvs EEE

• WhyEDE? – Initialandfinalpermutationswouldcanceleachother outwithEEE(minoradvantagetoEDE) – EDEcompatiblewithsingleDESifK1=K2=K3. – What’sanotheradvantage?

80

40 EDEvs EEE Solution

• WhyEDE? – Initialandfinalpermutationswouldcanceleachother outwithEEE(minoradvantagetoEDE) – EDEcompatiblewithsingleDESifK1=K2=K3. – What’sanotheradvantage? • Only2differentKeysneededwithEDE

81

TripleDES

Encryption P E D E C

K1 K2 K1 Decryption P D E D C

• ApplyDESencryption/decryptionthreetimes. – Withtwokeysorthreekeys • WhyEDE? – Initialandfinalpermutationswouldcanceleachotherout withEEE(minoradvantagetoEDE) – EDEcompatiblewithsingleDESifK1=K2=K3. – What’sanotheradvantage?

82

41 TripleDESIsNotIdeal...

• Efficiencydemandsschemeswithlongerkeysto beginwith! • TripleDESrunsonethirdasfastasDESonthesame platform • Newcandidatesarenumerous RC5,IDEA,two, CAST,etc • NewAES

83

ModesofBlockCipherOperations

42 EncryptingaLargeMessage

• Modesofblockcipheroperations – ECB(ElectronicCodeBook) – CBC(CipherBlockChainingMode) – OFB(OutputFeedbackMode) – CFB(CipherFeedbackMode)

85

EncryptingLargeMessages

• Thebasicalgorithmsencryptafixedsizeblock • Obvioussolutionistoencryptablockatatime.This iscalledElectronicCodeBook(ECB) • Repeatedplaintextblocksyieldrepeatedciphertext blocks • Othermodes“chain” toavoidthis(CBC,CFB,OFB) • Encryptiondoesnotguaranteeintegrity!

86

43 ElectronicCodeBook(ECB)

• Divideandconquer! • (M1==M3)=>(C1==C3) givingsomeinformationto eavesdroppers

87

ECBProperties(Cont’d)

Disadvantage:

• Ifci=cJ,thenyouknowp i=pJ 1. Canreorderblocks 2. Cansubstitute(fabricatedinformation)blocksto affectplaintext • SalaryExample Advantage: • Advantage:Noerrorpropagation. Twoseriousflaws,oneadvantage!

88

44 ExampleofECBIssue

89

Considerthis

M1 M2 M3 M4

r1 r2 r3 r4

E E E E

C1 C2 C3 C4 transmitr1,c1,r2,c2,r3,c3,r4,c4

90

45 Problemswithpreviousslide

• Needtosendtwiceasmuchdata • Canstillrearrangeblocks • Iftwociphertext blocksareequal,youknowXORoftwo plaintextblocks=XORofthecorrespondingtworandom numbers • CBCgeneratesitsown“randomnumbers” byusing previousciphertext block,plusoneadditionalblock(the “IV”,initializationvector)

91

CipherBlockChaining(CBC)

(M 1 ==M 3)veryunlikelyleadsto(C 1 ==C 3)

92

46 CBCDecryption

93

CBCProperties

• Chainingdependency – Eachciphertextblockdependsonallprecedingplaintextblocks

– Tochangeaparticularbitinm i ,changethecorrespondingbitin ci1.Thesideeffectisthatm i1 willbegarbled. • Errorpropagation

– Eacherrorincj affectsdeciphermentofmj andm j+1 . • Errorrecovery

– Anerrorincj doesn’tpropagatebeyondc j+1 . – Canrecoverfromlossofciphertextblocks.

94

47 OutputFeedbackMode(OFB)

95

OFBProperties

• (OFB)streamgenerated: – IV(transmittedintheclear)

– pad 1=e(IV,key)

– pad 2=e(pad 1,key)

– pad i=e(pad i1,key) • Chainingdependencies – Keystreamisplaintextindependent – Allowprecomputingofpseudorandomstream(OneTimePad);XOR canbeimplementedveryefficiently • NoerrorpropagationproblemasinCBC • Whatifciphertext isgarbledorlost? – Ifgarbled,onlythoseplaintextbitsaregarbled. – Iflostorduplicated,youlosesynchronizationsoeverythingis lost.

96

48 CipherFeedbackMode (CFB)

97

CFBProperties

• Chainingdependencies

– Ciphertextblockcj dependsonallpreceding plaintextblocks. • Errorpropagation – Biterrorinoneciphertextblockaffectsthenext severalblocks • Errorrecovery – Canrecoverfrombiterrorsafterseveralblocks – Canresynchronizeafterlossofblocks.

98

49 MathEssentials

BeautyofMathematics Demonstration Pickanumberfrom10to99 Atthe2digits,forexample: Ifyouchose51,youwouldadd5+1=6 Thensubtracttheresultfromtheoriginalnumber So516=45 (Demonstrationshowninclass)

100

50 PrimeNumbers(I)

x Percentage Percentage x/(ln x - 1) Percentage 1,000 168 16.8% 169 16.9% 10,000 1,229 12.3% 1,218 12.2% 100,000 9,592 9.6% 9,512 9.5% 1,000,000 78,498 7.8% 78,030 7.8% 10,000,000 664,579 6.6% 661,459 6.6% 100,000,000 5,761,455 5.8% 5,740,304 5.7% 1,000,000,000 50,847,534 5.1% 50,701,542 5.1% 10,000,000,000 455,052,511 4.6% 454,011,971 4.5% • Primenumbers“thinout” asthenumbersgetlarger • Thereare25primes<100,sodensityis1in4. • Tendigitnumber,densityis1in23. • Hundreddigitnumber,densityis1in230.

101

Division(I)

(alsocalledcountingnumbers)

102

51 Division(II)

103

Division(III)

104

52 CommonDivisors(I)

105

CommonDivisors(II)

inZ

106

53 Euler’sTotient Function(I)

• LeonhardEuler – Swissmathematicianandphysicist – Firsttousethetermfunction. – Livedinthe1700’s

* • Totient functionø(n):|Zn | – numberofintegerslessthan n andrelativelyprimeto n – If n isprime,ø(n)= n1 – If n=p∗q,and p, q areprimes,ø(n)=( p1)( q1) – If p isprimeand k>0,ø(pk)=( p1) pk1

107

Euler’sTotient Function(II)

• Examples: ø(7)=7*(1(1/7))=6{1,2,3,4,5,6} Orø(7)=71=6,because7isprime

ø(10)=10*(1(1/2)*(1(1/5))=4{1,3,7,9} ø(18)=18*(1(1/2)*(1(1/3))=6{1,5,7,11,13,17}

ø(21)=21*(1(1/3)*(1(1/7))=12 {1,2,4,5,8,10,11,13,16,17,19,20} Orø(21)=ø(3.7)=ø(3).ø(7)=2.6=12

108

54 Motivation1 KeyDistributionProblem • Inasecretkey,thesecretkeymustbe transmittedviaasecurechannel • Inconvenient – npartieswanttocommunicatewitheachother,howmanykeys totalkeysareneededandhowmanyotherkeysmusteachn store? nentities– Therewillben(n1)/2keystotal Eachentityhastostoren1keys • Insecure – Isthesecurechannelreallysecure?

• Publickeycryptosystemsolvestheproblem – Publickeyknownbyeveryone– telephonedirectory – Privacykeyisnevertransmitted

109

HowmanySymmetricKeysneeded?

AdministrationProblems: n Total Keys Keys Stored – Addingnewentities 2 2 1 3 3 2

– Removingexistingentities 4 6 3 – Changingkeys 5 10 4 6 15 5

7 21 6

8 28 7

9 36 8

10 45 9

11 55 10

12 66 11

13 78 12

14 91 13

15 105 14

110

55 Motivation2 DigitalSignature • Inasecretkeycryptosystem,authenticationandnon repudiationmaybedifficult • Authentication – Youmustshareasecretkeywithsomeoneinorderto verifyhissignature • Nonrepudiation – “Ididn’tsignit.Youdidsinceyoualsohavethekey” • Publickeycryptosystemsolvestheproblem – Verificationofsignatureneedsonlythepublickey – Oneissolelyresponsibleforhisprivatekey

111

Asymmetric(PublicKey) Cryptography

56 PublicKeyAlgorithms

• Publickeyalgorithmscoveredinthislecture: – RSA:encryptionanddigitalsignature – DiffieHellman:keyexchange • Numbertheoryunderliesmostofpublickey algorithms.

113

RequirementsforPublicKeyAlgorithms

• Itiscomputationallyeasyto – generatea(public,private)keypair. – togenerateaciphertextusingthepublickey. – todecrypttheciphertextusingtheprivatekey. – tosignwiththeprivatekey. – toverifythesignaturewiththepublickey. • Itiscomputationallyinfeasibleto – determinetheprivatekeyfromthepublickey. – recoverthemessagefromtheciphertextandthepublickey. – forgeasignature.

114

57 TheBigPicture

Plain- Plain- text Encryption Ciphertext Decryption text Algorithm INSECURE CHANNEL Algorithm AA BB B's Public Key B's Private Key

RE LIA BL E C HA NN EL B's Public Key 115

TheBasicIdea

• Confidentiality: encipherusingpublickey,decipher usingprivatekey • Integrity/authentication: encipherusingprivatekey, decipherusingpublickey

Plain- Plain- text Encryption Ciphertext Decryption text Algorithm Algorithm ‘Signature’

B's Public Key B's Private Key B AA 116B

58 PublicKeyModel

117

PublicKeyEncryption

118

59 PublicKeySignatures

119

UseofPublicKey

• Encryption/decryption – Thesenderencryptsamessagewiththereceiver’spublickey – Onlythereceivercandecryptthemessage. • Digitalsignature – Thesendersignsamessagewithitsprivatekey. – Authenticationandnonrepudiation • Keyexchange – Twosidescooperatetoexchangeasessionkey. – Secretkeycryptosystemsareoftenusedwiththesessionkey.

120

60 PublicKeyCryptanalysis

• Bruteforceattack – Tryallpossiblekeys • Derivationofprivatekeyfrompublickey – Trytofindtherelationshipbetweenthepublickeyandthe privatekeyandcomputetheprivatekeyfromthepublicone. • Probablemessageattack – Thepublickeyisknown. – Encryptallpossiblemessages – Trytofindamatchbetweentheciphertextandoneoftheabove encryptedmessages. – Example:Prof.sendsencryptedmessagesoflettergradestohis studentsbasedontheirpublickey.

121

HistoryofPublicKeySchemes

• 1976– Diffie &Hellmansuggestedthepublickeymodelfor encryptionandsignatures • 1976– Diffie &Hellmandevelopedpublickeyprotocolfor keyexchangebasedonDiscreteLogProblem • 1977 Rivest,Shamir,Adelman developedRSApublickey schemeforencryptionandsignaturesbasedontheNumber FactoringProblem • 1980’s ElGamal developedpublickeyprotocolsfor encryptionandsignaturesbasedonDiscreteLogProblem

122

61 RevolutioninCryptography

• Diffie &Hellmansoughttosolve2problems – Findasecurewaytodistributekeysinthepublic – Providedigitalsignaturefordocument • Publickeycryptographyisbasedonrigorous mathematicaltheory,ratherthansubstitutionsand permutations. • Itisasymmetric– requirestwodifferentkeys:private key&publickey

123

DiffieHellman KeyExchange(I)

• Publishedin – W.Diffie andMEHellman," NewDirectionsinCryptography ", inIEEETransactionsonInformationTheory,IT22no6 (November1976)p.644654 • Thefirstpublickeyalgorithm • Allowstwouserstoagreeonasecretkeyoverpublicchannel • Noencryption,decryption,norauthentication • What’sinvolved? – p isalargeprimenumber(about512bits), g < p and g isa primitiverootof p. – p and g arepubliclyknown

124

62 DiffieHellman KeyExchange(II)

125

DiffieHellman KeyExchange(III)

126

63 DiffieHellman Example

AliceandBobwanttoestablishasharedsecretkey • Haveagreeonthevalue n=353(prime)and g=3 • Selecttherandomsecretvalues:

– AlicechoosesXa=97,BobchoosesXb=233 • Derivethepublickeys: Xa 97 –Ta= g mod n =3 mod353=40(Alice’s) Xb 233 –Tb= g mod n =3 mod353=248(Bob’s) • Derivethesharedsecretkey Xa 97 – K=Tb mod n =248 mod353=160(Alice’s) Xb 233 – K=Ta mod n =40 mod353=160(Bob’s)

127

DiffieHellman Maninthemiddle

128

64 HardNumberTheoryProblems

• T = gs mod p – Given T, g, p ,itiscomputationallyinfeasibleto computethevalueof s (discretelogarithm) – ThisisthebasisoftheDiffieHellman,ElGamal,and DSSPublicKeySchemes. • Anotherdifficultnumbertheoryproblem;Itistrivial tocomputetheproductoftwoprimes p and q to obtainn=pq;Butitisdifficulttofactorthecomposite numbernintoitstwoprimefactorspandq. – ThisisthebasisoftheRSAPublicKeyscheme

129

DiffieHellman Scheme

• Securityfactors – Discretelogarithmverydifficult. – Sharedkey(thesecret)itselfnevertransmitted. • Disadvantages: – Expensiveexponentialoperation – Cannotbeusedtoencryptanything. – Noauthentication,soyoucannotsignanything.

130

65 DiffieHellman inPhoneBookMode

• DHissubjecttoactivemaninthemiddleattackbecause theirpublickeycomponentmaybeinterceptedand substituted • Phonebookmodeallowseveryonetogeneratethepublic keycomponentinadvanceandpublishthemthroughother reliablemeans • Allcommunicatingpartiesagreeontheircommon< g, p> • Essentialrequirement :authenticityofthepublickey.

131

RSA(Rivest,Shamir,Adleman)

• Publishedin – R.Rivest,A.Shamir,andL.Adleman," AMethodforObtaining DigitalSignaturesandPublicKeyCryptosystems ",CACM21, pp.120126,Feb.1978 – Thefirstpublickeyencryptionandsignaturesystem • Supportbothpublickeyencryptionanddigitalsignature. • Assumption/theoreticalbasis: – Factorizationoflargeprimesishard. • Variablekeylength(usually1024bits). • Variableplaintextblocksize. – Plaintextmustbe“smaller” thanthekey. – Ciphertextblocksizeisthesameasthekeylength.

132

66 NumberFactoring

HowaboutTomorrow’scomputers?

133

QuantumComputing

• Aclassicalcomputerhasamemorymadeupofbits,whereeachbitholdseithera oneorazero.Thedevicecomputesbymanipulatingthosebits,i.e.bytransporting thesebitsfrommemoryto(possiblyasuiteof)logicgatesandback.Aquantum computermaintainsasetofqubits.

• Aqubit canholdaone,orazero,orasuperpositionofthese.Aquantumcomputer operatesbymanipulatingthosequbits,i.e.bytransportingthesebitsfrommemory to(possiblyasuiteof)quantumlogicgatesandback.

• Qubits foraquantumcomputercanbeimplementedusingparticleswithtwospin states:"up"and"down";infactanysystem,possessinganobservablequantityA whichisconservedundertimeevolutionandsuchthatAhasatleasttwodiscrete andsufficientlyspacedconsecutiveeigenvalues,isasuitablecandidatefor implementingaqubit.

InformationSource:Wikipedia

134

67 TheRSAAlgorithm

• Togeneratekeypair: – Picklargeprimes p and q – Let n = p*q,keep p and q toyourself! – Forpublickey,choose e thatisrelativelyprimeto ø(n) =(p-1)(q-1). publickey=< e,n > – Forprivatekey,find d thatisthemultiplicativeinverse of e mod ø(n), i.e., e*d =1mod ø(n) – Privatekey=< d,n>.

135

HowDoesRSAWork?

• GivenpubKey =< e, n >andprivKey =< d, n > • Message=m – encryption: c = me mod n, m < n – decryption: m = cd mod n – signature: s = md mod n, m < n – verification: m = se mod n

136

68 AnExample

• Choose p =7and q =17. • Compute n = p*q= 119 . • Compute φ(n)=( p1)( q1)=96. • Select e =5,whichisrelativelyprimeto φ(n). • Compute d =_77_ suchthat e*d=1mod φ(n). • Publickey:<5,119> • Privatekey:<77,119> • Message=19 • Encryption:19 5 mod119=66 • Decryption:66 77 mod119=19.

137

Example:Encryption

• p =7, q =11, n =77 • Alicechooses e =17,making d =53 • BobwantstosendAlicesecretmessage HELLO (07 04 11 11 14) – 07 17 mod77=28 – 04 17 mod77=16 – 11 17 mod77=44 – 11 17 mod77=44 – 14 17 mod77=42 • Bobsends 28 16 44 44 42

138

69 Example:Decryption

• Alicereceives 28 16 44 44 42 • Aliceusesprivatekey, d = 53 ,todecryptmessage: – 28 53 mod77=07 – 16 53 mod77=04 – 44 53 mod77=11 – 44 53 mod77=11 – 42 53 mod77=14 • Alicetranslates 07 04 11 11 14 to HELLO – Nooneelsecouldreadit,asonlyAliceknowsher privatekeyandthatisneededfordecryption

139

DigitalSignaturesinRSA

• RSAhasanimportantproperty,notsharedbyother publickeysystems • Encryptionanddecryptionaresymmetric – Encryptionfollowedbydecryptionyieldstheoriginal message – (M e mod n) d mod n = M – Decryptionfollowedbyencryption also yieldsthe originalmessage – (Md mod n) e mod n = M – Because e and d aresymmetricin e*d = 1 mod (p-1)*(q-1) 140

70 DigitalSignaturesinRSA

Plaintext M’ Plaintext ? M Plaintext M M d mod n C e mod n Ciphertext C (signature)

A's Private Key d A's Public Key e

AA RELIABLE CHANNEL BB

141

ComparedToEncryptioninRSA

Plaintext Plaintext M M M e mod n C d mod n Ciphertext C AA BB

B's Public Key e B's Private Key d

RELIABLE CHANNEL

142

71 SignatureandEncryption A B A Encrypted B Signed Signed Signed Plaintext Plaintext Plaintext Plain- Plain- text text D E D E

A's Private B's Public B's Private A's Public Key Key Key Key

143

Example:Sign

• Take p =7, q =11, n =77 • Alicechooses e =17,making d =53 • AlicewantstosendBobmessageHELLO(070411 1114)soBobknowsitisfromAlice,andithasnot beenmodifiedintransit – 07 53 mod77=35 – 04 53 mod77=09 – 11 53 mod77=44 – 11 53 mod77=44 – 14 53 mod77=49 • Alicesends3509444449

144

72 Example:Verify

• Bobreceives3509444449 • BobusesAlice’spublickey, e =17, n =77,todecrypt message: – 35 17 mod77=07 – 09 17 mod77=04 – 44 17 mod77=11 – 44 17 mod77=11 – 49 17 mod77=14 • Bobtranslates 07 04 11 11 14 to HELLO – (Assume)onlyAlicehasherprivatekey,sonooneelsecould havebeenabletocreateacorrectsignature – The(deciphered)signaturematchesthetransmittedplaintext,so theplaintextisnotaltered 145

Example:Both

• AlicewantstosendBobmessageHELLObothencipheredand signed – Alice’skeys:public(17,77);private:53 – Bob’skeys:public:(37,77);private:13 • Alicedoes(doessheencipherfirstorsignfirst?) – (07 53 mod77) 37 mod77=07 – (04 53 mod77) 37 mod77=37 – (11 53 mod77) 37 mod77=44 – (11 53 mod77) 37 mod77=44 – (14 53 mod77) 37 mod77=14 • Alicesends0737444414 • WhatwouldBobdouponreceivingthemessage?

146

73 ClassExercise

1. Findprimespandqsothat12bitplaintextblocks couldbeencryptedwithRSA. 2. Decrypttheciphertext C=4usingRSAwiththe privatekey{d=7,p=3,q=7}

147

RSAKEYSIZE

• InAugust1999agroupusing300workstationsandPCswas abletofactor512bitnumberin7months. • RSALaboratoriescurrentlyrecommendskeysizesof1024 bitsforcorporateuseand2048bitsforextremelyvaluable keysliketherootkeypairusedbyacertifyingauthority (rsasecurity.com) • WhatdoesanRSA155numberlooklike?

148

74 RSA155Number

10263959282974110577205419657399759007165678080380668 334193352190711307779 * 1066034883801684548209272203600187867920795857598929 22270608237193062808643. = 10941738641570527421809707322040357612003732945449 20599091384213147634998428893478471799725789126733 24976257528997818337970765372440271467435315933543 33897

149

FindingLargePrimeNumbers

• Goodnews – Infinitenumberofprimenumbers ☺ • Badnews – Theprimenumberratiodecreasesastheprimenumbergets big • Bruteforce – Trytodividenby2,…,n1/2 – Impracticalforlargenumber!!! • Noknownpracticalmethodtodetermineifagivenlargenumber isprime • Howeverfastprobabilisticprimality testexists. Thatis,determineifalargernumberislikelytobeaprime.

150

75 FindingLargePrimeNumbers(Cont’d)

• Primality test – Randomlypick0< a0suchthat an1 mod n=1forall0< a

151

TheSecurityofRSA

• AttacksagainstRSA – Bruteforce:Tryallpossibleprivatekeys • Canbedefeatedbyusingalargekeyspace – Mathematicalattacks • Factor n into n=p*q. • Determineø(n)directly:equivalenttofactoring n. • Determine d directly:atleastasdifficultasfactoring n.

152

76 TheSecurityofRSA(Cont’d)

• Factoringlargeintegerisveryhard! • Butifyoucanfactorbignumber n thengivenpublickey ,youcanfind d,andhencetheprivatekeyby: – Knowingfactors p, q ,suchthat,n = p*q – Then ø(n) =(p-1)(q-1) – Then d suchthat e*d =1mod ø(n) • Waystomake n difficulttofactor – p and q shoulddifferinlengthbyonlyafewdigits – Both( p1)and( q1)shouldcontainalargeprimefactor – gcd( p1, q1)shouldbesmall. – d > n1/4 .

153

RSAVersusDES • FastestimplementationsofRSAcanencrypt kilobits/second • FastestimplementationsofDEScanencrypt megabits/second • ItisoftenproposedthatRSAbeusedforsecure exchangeofDESkeys • This1000folddifferenceinspeedislikelytoremain independentoftechnologyadvances

154

77