Quick viewing(Text Mode)

Demonstration

Demonstration

Outline

• SomeMathEssentials&History • Asymmetricsignaturesandexchange ISA662 • Asymmetric InternetSecurityProtocols • SymmetricMACs

Lecture2

ISA662 1 2

BeautyofMathematics PrimeNumbers(I)

x Percentage Percentage x/(ln x - 1) Percentage Demonstration 1,000 168 16.8% 169 16.9% 10,000 1,229 12.3% 1,218 12.2% Pickanumberfrom10to99 100,000 9,592 9.6% 9,512 9.5% Atthe2digits,forexample: 1,000,000 78,498 7.8% 78,030 7.8% 10,000,000 664,579 6.6% 661,459 6.6% Ifyouchose51,youwouldadd5+1=6 100,000,000 5,761,455 5.8% 5,740,304 5.7% Thensubtracttheresultfromtheoriginalnumber 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% So516=45 • Primenumbers“thinout” asthenumbersgetlarger (Demonstrationshowninclass) • Thereare25primes<100,sodensityis1in4. • Tendigitnumber,densityis1in23. • Hundreddigitnumber,densityis1in230.

3 4

Division(I) Division(II)

(alsocalledcountingnumbers)

5 6

1 Division(III) CommonDivisors(I)

7 8

CommonDivisors(II) Euler’sTotient Function(I)

• LeonhardEuler – Swissmathematicianandphysicist – Firsttousethetermfunction. – Livedinthe1700’s

inZ

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

9 10

Euler’sTotient Function(II) Motivation1 KeyDistributionProblem • Examples: • Inasecretkey,thesecretkeymustbe ø(7)=7*(1(1/7))=6{1,2,3,4,5,6} transmittedviaasecurechannel Orø(7)=71=6,because7isprime • Inconvenient – npartieswanttocommunicatewitheachother,howmanykeys totalkeysareneededandhowmanyotherkeysmusteachn ø(10)=10*(1(1/2)*(1(1/5))=4{1,3,7,9} store? nentities– Therewillben(n1)/2keystotal ø(18)=18*(1(1/2)*(1(1/3))=6{1,5,7,11,13,17} Eachentityhastostoren1keys • Insecure ø(21)=21*(1(1/3)*(1(1/7))=12 – Isthesecurechannelreallysecure? {1,2,4,5,8,10,11,13,16,17,19,20} Orø(21)=ø(3.7)=ø(3).ø(7)=2.6=12 • Publickeycryptosystemsolvestheproblem – Publickeyknownbyeveryone– telephonedirectory – Privacykeyisnevertransmitted 11 12

2 HowmanySymmetricKeysneeded? Motivation2 DigitalSignature

AdministrationProblems: Total Keys n Keys Stored • Inasecretkeycryptosystem,authenticationand – Addingnewentities 2 2 1 nonrepudiationmaybedifficult – Removingexistingentities 3 3 2 4 6 3

– Changingkeys 5 10 4 • Authentication 6 15 5 – Youmustshareasecretkeywithsomeoneinorderto 7 21 6

8 28 7 verifyhissignature

9 36 8

10 45 9 • Nonrepudiation 11 55 10 – “Ididn’tsignit.Youdidsinceyoualsohavethekey” 12 66 11 13 78 12 • Publickeycryptosystemsolvestheproblem 14 91 13 15 105 14 – Verificationofsignatureneedsonlythepublickey – Oneissolelyresponsibleforhisprivatekey

13 14

PublicKeyAlgorithms RequirementsforPublicKeyAlgorithms

• Publickeyalgorithmscoveredinthisclass • Itiscomputationallyeasyto – RSA:encryptionanddigitalsignature – generatea(public,private)keypair. – togenerateausingthepublickey. – DiffieHellman:keyexchange – todecrypttheciphertextusingtheprivatekey. – DSA:digitalsignature – tosignwiththeprivatekey. • Numbertheoryunderliesmostofpublickey – toverifythesignaturewiththepublickey. algorithms. • Itiscomputationallyinfeasibleto – determinetheprivatekeyfromthepublickey. – recoverthemessagefromtheciphertextandthepublickey. – forgeasignature.

15 16

TheBigPicture TheBasicIdea • Confidentiality: encipherusingpublickey, decipherusingprivatekey Plain- Plain- • Integrity/authentication: encipherusingprivate text Encryption Ciphertext Decryption text key,decipherusingpublickey Algorithm INSECURE CHANNEL Algorithm A B Plain- Plain- A B text Encryption Ciphertext Decryption text B's Public Key B's Private Key Algorithm Algorithm RE ‘Signature’ LIA BL E C HA NN EL B's Public Key B's Private Key B's Public Key B 17 AA B18

3 PublicKeyModel PublicKeyEncryption

19 20

PublicKeySignatures UseofPublicKey

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

21 22

GoalsofPublicKey PublicKeyCryptanalysis

• Giventhepublickey,text,signature,to • Bruteforceattack – Tryallpossiblekeys – findouttheprivatekey • Derivationofprivatekeyfrompublickey – findoutthemessageencrypted – Trytofindtherelationshipbetweenthepublickeyandthe privatekeyandcomputetheprivatekeyfromthepublicone. – forgethesignature • Probablemessageattack – Thepublickeyisknown. – Encryptallpossiblemessages – Trytofindamatchbetweentheciphertextandoneoftheabove encryptedmessages. – Example:Prof.sendsencryptedmessagesoflettergradestohis studentsbasedontheirpublickey.

23 24

4 HistoryofPublicKeySchemes Revolutionin

• 1976– Diffie &Hellmansuggestedthepublickeymodel • Diffie &Hellmansoughttosolve2problems forencryptionandsignatures – Findasecurewaytodistributekeysinthepublic • 1976– Diffie &Hellmandevelopedpublickeyprotocol forkeyexchangebasedonDiscreteLogProblem – Providedigitalsignaturefordocument • 1977 Rivest,Shamir,Adelman developedRSApublic • Publickeycryptographyisbasedonrigorous keyschemeforencryptionandsignaturesbasedonthe mathematicaltheory,ratherthansubstitutionsand NumberFactoringProblem permutations. • 1980’s ElGamal developedpublickeyprotocolsfor encryptionandsignaturesbasedonDiscreteLogProblem • Itisasymmetric– requirestwodifferentkeys: privatekey&publickey

25 26

DiffieHellmanKeyExchange(I) DiffieHellmanKeyExchange(II)

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

27 28

DiffieHellmanKeyExchange(III) DiffieHellmanManinthemiddle

29 30

5 DiffieHellmanExample HardNumberTheoryProblems

AliceandBobwanttoestablishasharedsecretkey • T = gs mod p • Haveagreeonthevalue n=353(prime)and g=3 – Given T, g, p ,itiscomputationallyinfeasibletocomputethe • Selecttherandomsecretvalues: valueof s (discretelogarithm)

– AlicechoosesXa=97,BobchoosesXb=233 – ThisisthebasisoftheDiffieHellman,ElGamal,andDSS • Derivethepublickeys: PublicKeySchemes. Xa 97 –Ta= g mod n =3 mod353=40(Alice’s) • Anotherdifficultnumbertheoryproblem,itistocompute Xb 233 –Tb= g mod n =3 mod353=248(Bob’s) theproductoftwoprimes p and q toobtainn=pq.Butitis • Derivethesharedsecretkey difficulttofactorthecompositenumbernintoitstwo Xa 97 – K=Tb mod n =248 mod353=160(Alice’s) primefactorspandq. Xb 233 – K=Ta mod n =40 mod353=160(Bob’s) – ThisisthebasisoftheRSAPublicKeyscheme

31 32

DiffieHellmanScheme DiffieHellmaninPhoneBookMode

• Securityfactors • DHissubjecttoactivemaninthemiddleattack – Discretelogarithmverydifficult. becausetheirpublickeycomponentmaybeintercepted andsubstituted – Sharedkey(thesecret)itselfnevertransmitted. • Phonebookmodeallowseveryonetogeneratethe • Disadvantages: publickeycomponentinadvanceandpublishthem – Expensiveexponentialoperation throughotherreliablemeans – Cannotbeusedtoencryptanything. • Allcommunicatingpartiesagreeontheircommon< g, – Noauthentication,soyoucannotsignanything. p> • Essentialrequirement :authenticityofthepublickey.

33 34

RSA(Rivest,Shamir,Adleman) NumberFactoring

• 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. HowaboutTomorrow’scomputers?

35 36

6 QuantumComputing TheRSAAlgorithm

• Aclassicalcomputerhasamemorymadeupofbits,whereeachbitholdseither aoneorazero.Thedevicecomputesbymanipulatingthosebits, i.e.by • Togeneratekeypair: transportingthesebitsfrommemoryto(possiblyasuiteof)logicgatesand back.Aquantumcomputermaintainsasetofqubits. – Picklargeprimes p and q

• Aqubit canholdaone,orazero,orasuperpositionofthese.Aquantum – Let n = p*q,keep p and q toyourself! computeroperatesbymanipulatingthosequbits,i.e.bytransportingthesebits frommemoryto(possiblyasuiteof)quantumlogicgatesandback. – Forpublickey,choose e thatisrelativelyprimeto ø(n) =(p-1)(q-1). • Qubits foraquantumcomputercanbeimplementedusingparticleswithtwo spinstates:"up"and"down";infactanysystem,possessinganobservable publickey=< e,n > quantityAwhichisconservedundertimeevolutionandsuchthat Ahasatleast twodiscreteandsufficientlyspacedconsecutiveeigenvalues,isasuitable – Forprivatekey,find d thatisthemultiplicativeinverse candidateforimplementingaqubit. of e mod ø(n), i.e., e*d =1mod ø(n) InformationSource:Wikipedia – Privatekey=< d,n>.

37 38

HowDoesRSAWork? AnExample

• GivenpubKey =< e, n >andprivKey =< d, n > • Choose p =7and q =17. • Message=m • Compute n = p*q= 119 . • Compute φ(n)=( p1)( q1)=96. – encryption: c = me mod n, m < n • Select e =5,whichisrelativelyprimeto φ(n). d – decryption: m = c mod n • Compute d =_77_ suchthat e*d=1mod φ(n). d – signature: s = m mod n, m < n • Publickey:<5,119> – verification: m = se mod n • Privatekey:<77,119> • Message=19 • Encryption:19 5 mod119=66 • Decryption:66 77 mod119=19.

39 40

Example:Encryption Example:Decryption

• p =7, q =11, n =77 • Alicereceives 28 16 44 44 42 • Alicechooses e =17,making d =53 • Aliceusesprivatekey, d = 53 ,todecrypt • BobwantstosendAlicesecretmessage HELLO message: (07 04 11 11 14) – 28 53 mod77=07 – 07 17 mod77=28 – 16 53 mod77=04 – 04 17 mod77=16 – 44 53 mod77=11 – 11 17 mod77=44 – 44 53 mod77=11 – 11 17 mod77=44 – 42 53 mod77=14 – 14 17 mod77=42 • Alicetranslates 07 04 11 11 14 to HELLO • Bobsends 28 16 44 44 42 – Nooneelsecouldreadit,asonlyAliceknowsher privatekeyandthatisneededfordecryption 41 42

7 DigitalSignaturesinRSA DigitalSignaturesinRSA

• RSAhasanimportantproperty,notsharedby Plaintext M’ otherpublickeysystems Plaintext ? M Plaintext • Encryptionanddecryptionaresymmetric M M d mod n C e mod n – Encryptionfollowedbydecryptionyieldstheoriginal Ciphertext C message (signature) – (M e mod n) d mod n = M – Decryptionfollowedbyencryption also yieldsthe originalmessage A's Private Key d A's Public Key e – (Md mod n) e mod n = M – Because e and d aresymmetricin AA RELIABLE CHANNEL BB e*d = 1 mod (p-1)*(q-1) 43 44

ComparedToEncryptioninRSA SignatureandEncryption A B A Encrypted B Plaintext Plaintext Signed Signed Signed M M Plaintext Plaintext Plaintext M e mod n C d mod n Plain- Plain- Ciphertext C text text D E D E AA BB

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

A's Private B's Public B's Private A's Public RELIABLE CHANNEL Key Key Key Key

45 46

Example:Sign Example:Verify

• Take p =7, q =11, n =77 • Bobreceives3509444449 • Alicechooses e =17,making d =53 • BobusesAlice’spublickey, e =17, n =77,todecrypt • AlicewantstosendBobmessageHELLO(0704 message: 111114)soBobknowsitisfromAlice,andit – 35 17 mod77=07 hasnotbeenmodifiedintransit – 09 17 mod77=04 17 – 07 53 mod77=35 – 44 mod77=11 17 – 04 53 mod77=09 – 44 mod77=11 – 49 17 mod77=14 – 11 53 mod77=44 – 11 53 mod77=44 • Bobtranslates 07 04 11 11 14 to HELLO – 14 53 mod77=49 – (Assume)onlyAlicehasherprivatekey,sonooneelsecould havebeenabletocreateacorrectsignature • Alicesends3509444449 – The(deciphered)signaturematchesthetransmittedplaintext,so

47 theplaintextisnotaltered 48

8 Example:Both ClassExercise

• AlicewantstosendBobmessageHELLOboth 1. Findprimespandqsothat12bitplaintext encipheredandsigned blockscouldbeencryptedwithRSA. – Alice’skeys:public(17,77);private:53 – Bob’skeys:public:(37,77);private:13 2. Decrypttheciphertext C=4usingRSAwiththe • Alicedoes(doessheencipherfirstorsignfirst?) privatekey{d=7,p=3,q=7} – (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?

49 50

ClassExercise RSAKEYSIZE

1. Findprimespandqsothat12bitplaintext • InAugust1999agroupusing300workstationsandPCs blockscouldbeencryptedwithRSA. wasabletofactor512bitnumberin7months. – TheprimesP*Qmustbe>or=to2 12 =4096. • RSALaboratoriescurrentlyrecommendskeysizesof – Solet P=67 and Q=71 soPxQ= 4,757 1024bitsforcorporateuseand2048bitsforextremely 2. Decrypttheciphertext C=4usingRSAwiththe valuablekeysliketherootkeypairusedbyacertifying privatekey{d=7,p=3,q=7} authority(rsasecurity.com) – N=p*q • WhatdoesanRSA155numberlooklike? – N=7*3=21 – M=C^d modn – M=4^7mod21 – M=4

51 52

RSA155Number FindingLargePrimeNumbers

10263959282974110577205419657399759007165678080380668 • Goodnews 334193352190711307779 – Infinitenumberofprimenumbers ☺ * 1066034883801684548209272203600187867920795857598929 • Badnews 22270608237193062808643. – Theprimenumberratiodecreasesastheprimenumbergets = big 10941738641570527421809707322040357612003732945449 • Bruteforce 20599091384213147634998428893478471799725789126733 1/2 24976257528997818337970765372440271467435315933543 – Trytodividenby2,…,n 33897 – Impracticalforlargenumber!!! • Noknownpracticalmethodtodetermineifagivenlarge numberisprime • Howeverfastprobabilisticprimality testexists. Thatis,determineifalargernumberislikelytobeaprime.

53 54

9 FindingLargePrimeNumbers(Cont’d) TheSecurityofRSA

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

55 56

TheSecurityofRSA(Cont’d) RSAVersusDES • Factoringlargeintegerisveryhard! • FastestimplementationsofRSAcanencrypt • Butifyoucanfactorbignumber n thengivenpublickey ,youcanfind d,andhencetheprivatekeyby: kilobits/second – Knowingfactors p, q ,suchthat,n = p*q • FastestimplementationsofDEScanencrypt – Then ø(n) =(p-1)(q-1) – Then d suchthat e*d =1mod ø(n) megabits/second • Waystomake n difficulttofactor • ItisoftenproposedthatRSAbeusedforsecure – p and q shoulddifferinlengthbyonlyafewdigits exchangeofDESkeys – Both( p1)and( q1)shouldcontainalargeprimefactor – gcd( p1, q1)shouldbesmall. • This1000folddifferenceinspeedislikelyto – d > n1/4 . remainindependentoftechnologyadvances

57 58

DigitalSignatureStandard(DSS) Efficiencyofsignatureschemes

• ByNIST • RelatedtoElGamal • UseSHA(SHA1)togeneratethehashvalueand DigitalSignatureAlgorithm(DSA)togenerate thedigitalsignature. • Fasterforthesigner,butnotfortheverifier: Potentialapplication:smartcards

59 60

10 SummaryKeyrequiredlengths OnewayHashFunctions

• Alsoknownasmessagedigest • Afunction H(M) = m satisfies – (Fixedlength): M canbeofanylength,whereas m isof fixedlength – (Oneway):computing H(M)=m iseasy,but computing H-1(m)=M iscomputationallyinfeasible – (Collisionfree):intwoforms • Weakcollisionfreedom: givenany M,difficulttofind another M’ suchthat H(M)=H(M’) • Strongcollisionfreedom: difficulttofindany M and M’ suchthat H(M)=H(M’)

61 62

WhyThoseRequirements? “HashFunctionsBroken” ?

• Manyapplicationsstore H(p) insteadofapassword • Crypto2004Rumpsessionreportedattackson p MD4,MD5andSHA0 – Fixedlength: cannotguessthelengthof p from H(p) (and – MD4’sattacksaredonebyhands H(p) iseasiertostore) • Crypto2005reportedattacksonfullSHA1 – Oneway: theadministratorcannotlearn p ofothers • Shouldwepanic? – Collisionfree: cannotsubmitincorrect p matching H(p) • Mostapplicationssign H(M) insteadof M

63 Xiaoyun Wang ’s webpage: http://www.infosec.sdu.edu.cn/people/wangxiaoyun.htm 64

“HashFunctionsBroken” ?(Cont’d) MESSAGEAUTHENTICATIONCODES

• Natureoftheresults – Algorithmthatfindscollisionfasterthantheoreticbound INSECURE CHANNEL • MD5aboutonehour;SHA12 63 vs 280 (theoretically) Plaintext + MAC Plain- Yes/No – Yes,theresultsdisprovethosefunctionstobestrong text collisionfree MAC Verification Algorithm M Algorithm V – No,theydonotgiveyouapasswordfromitshash • Bruteforceattacksdo(referto http://passcracking.com/) A B • Whetheryoushouldpanicornotdependsonwhat A B youusethehashfunctionsfor K K

MAC = MD of plaintext + K

Xiaoyun Wang ’s webpage: http://www.infosec.sdu.edu.cn/people/wangxiaoyun.htm 65 66

11 HashFunctionsVsMAC HMAC

• SendamessageMtogetherwithitshash h=H(M) , • HMACisakeyedhashmessageauthenticationcode,which sotherecipientcanverifyMbycomparing H(M) isatypeofmessageauthenticationcode(MAC) withthereceived h • AswithanyMAC,itmaybeusedtosimultaneouslyverify – Attack: Ifanyoneinthemiddlecanreplace M with M’ boththedataintegrityandtheauthenticityofamessage. and h withh’=H(M’),therecipientwon’tdetectthis • Keyedhashfunctions • h : hashfunction – Alsoknownasmessageauthenticationcodes(MAC) • K :asecretkey k paddedwithextra0’stotheblocksizeof thehashfunction – Example: DESinCBCmode:useakeytoencipher messageinCBCmodeanduselast n bitsastheMAC • opad =0x5c5c..5c5c(outer)and value. • ipad =0x3636..3636( inner padding) are two one-block– long hexadecimal constants.

67 • ⊕ exclusiveor,||concatenation 68

ExampleofHMACuse KeyPoints

• Apizzarestaurantthatsuffersfromattackersthat • Publickeycryptosystemshastwokeys placebogusInternetordersmayinsistthatallits • DiffieHellmanexchangessecretkeyviainsecure customersdepositasecretkeywiththerestaurant. channel Alongwithanorder,acustomermustsupplythe • RSAcanbeusedforconfidentialityandintegrity order'sHMACdigest,computedusingthe customer'ssecretkey.Therestaurant,knowingthe • CryptographicChecksumsarekeyedhashfunctions customer'ssecretkey,canthenverifythattheorder originatedfromthestatedcustomerandhasnot beentamperedwith. (wiki example)

69 70

12