Securityofe-systemandComputerNetworksRSA算法编码学明文密文方法:密本系统:码本词典密表系统:密码算法密钥(可变)分类:分组密码:DES、RSA序列密码:RC-4内容1.密码算法的设计理论2.公钥密码学3.RSA算法4.RSA算法的攻击5.RSA算法应用一、密码算法的设计理论明文集合:P={p1,p2,…,pn}密文集合:C={c1,c2,…,cm}加密:C=E(p)映射E:PC是一对一的函数即:pipj则f(pi)f(pj)若f(pi)=f(pj)则pi=pjS:PCm(m-1)(m-2)…(m-n+1)映射总个数若m=n则S的秩为m!密钥集合V=(v1,v2,…vr)加密函数集E=(Ev1,Ev2…Evr)加密函数集D=(Dv1,Dv2…Dvr)|V||S|是理想的例DES|P|=|C|=2^64明文、密文64bit|S|=2^64!10^10^20|V|=2^56密钥56bit10^172^64!=256*2^56*(2^64-1)!2^56二、PublicKeyCryptographyEveryEgyptianreceivedtwonames,whichwereknownrespectivelyasthetruenameandthegoodname,orthegreatnameandthelittlename;andwhilethegoodorlittlenamewasmadepublic,thetrueorgreatnameappearstohavebeencarefullyconcealed.—TheGoldenBough,SirJamesGeorgeFrazerPrivate-KeyCryptographytraditionalprivate/secret/singlekeycryptographyusesonekeysharedbybothsenderandreceiverifthiskeyisdisclosedcommunicationsarecompromisedalsoissymmetric,partiesareequalhencedoesnotprotectsenderfromreceiverforgingamessage&claimingissentbysenderPublic-KeyCryptographyprobablymostsignificantadvanceinthe3000yearhistoryofcryptographyusestwokeys–apublic&aprivatekeyasymmetricsincepartiesarenotequalusescleverapplicationofnumbertheoreticconceptstofunctioncomplementsratherthanreplacesprivatekeycryptoPublic-KeyCryptographypublic-key/two-key/asymmetriccryptographyinvolvestheuseoftwokeys:apublic-key,whichmaybeknownbyanybody,andcanbeusedtoencryptmessages,andverifysignaturesaprivate-key,knownonlytotherecipient,usedtodecryptmessages,andsign(create)signaturesisasymmetricbecausethosewhoencryptmessagesorverifysignaturescannotdecryptmessagesorcreatesignaturesPublic-KeyCryptography公钥密码学产生的背景要求单向陷门函数密码分析应用1WhyPublic-KeyCryptography?developedtoaddresstwokeyissues:keydistribution–howtohavesecurecommunicationsingeneralwithouthavingtotrustaKDCwithyourkeydigitalsignatures–howtoverifyamessagecomesintactfromtheclaimedsenderpublicinventionduetoWhitfieldDiffie&MartinHellmanatStanfordUniin1976knownearlierinclassifiedcommunityPublic-KeyCharacteristicsPublic-Keyalgorithmsrelyontwokeyswiththecharacteristicsthatitis:computationallyinfeasibletofinddecryptionkeyknowingonlyalgorithm&encryptionkeycomputationallyeasytoen/decryptmessageswhentherelevant(en/decrypt)keyisknowneitherofthetworelatedkeyscanbeusedforencryption,withtheotherusedfordecryption(insomeschemes)2.要求:Diffie-Hellman提出1)参与方容易产生出一对密钥2)已知PK和明文M,容易计算出密文3)接收方使用SK和C容易恢复出明文4)敌方即使知道PK和C恢复出明文不可能5)敌方即使知道PK要确定SK不可行6)加、解密操作的次序可以互换3.单向陷门函数Y=f(x)4.SecurityofPublicKeychemeslikeprivatekeyschemesbruteforceexhaustivesearchattackisalwaystheoreticallypossiblebutkeysusedaretoolarge(512bits)securityreliesonalargeenoughdifferenceindifficultybetweeneasy(en/decrypt)andhard(cryptanalyse)problemsmoregenerallythehardproblemisknown,itsjustmadetoohardtodoinpractiserequirestheuseofverylargenumbershenceisslowcomparedtoprivatekeyschemes穷举数学分析可能报文攻击(特有):穷举明文5.Public-KeyCryptosystemsPublic-KeyApplicationscanclassifyusesinto3categories:encryption/decryption(providesecrecy)digitalsignatures(provideauthentication)keyexchange(ofsessionkeys)somealgorithmsaresuitableforalluses,othersarespecifictoone三、RSAbyRivest,Shamir&AdlemanofMITin1977bestknown&widelyusedpublic-keyschemebasedonexponentiationinafinite(Galois)fieldoverintegersmoduloaprimenb.exponentiationtakesO((logn)3)operations(easy)useslargeintegers(eg.1024bits)securityduetocostoffactoringlargenumbersnb.factorizationtakesO(elognloglogn)operations(hard)RSAKeySetupeachusergeneratesapublic/privatekeypairby:selectingtwolargeprimesatrandom-p,qcomputingtheirsystemmodulusN=p.qnoteø(N)=(p-1)(q-1)selectingatrandomtheencryptionkeyewhere1eø(N),gcd(e,ø(N))=1solvefollowingequationtofinddecryptionkeyde.d=1modø(N)and0≤d≤Npublishtheirpublicencryptionkey:KU={e,N}keepsecretprivatedecryptionkey:KR={d,p,q}RSAUsetoencryptamessageMthesender:obtainspublickeyofrecipientKU={e,N}computes:C=MemodN,where0≤MNtodecrypttheciphertextCtheowner:usestheirprivatekeyKR={d,p,q}computes:M=CdmodNnotethatthemessageMmustbesmallerthanthemodulusN(blockifneeded)WhyRSAWorksbecauseofEuler'sTheorem:aø(n)modN=1wheregcd(a,N)=1inRSAhave:N=p.qø(N)=(p-1)(q-1)carefullychosene&dtobeinversesmodø(N)hencee.d=1+k.ø(N)forsomekhence:Cd=(Me)d=M1+k.ø(N)=M1.(Mø(N))q=M1.(1)q=M1=MmodNRSAExample1.Selectprimes:p=17&q=112.Computen=pq=17×11=1873.Computeø(n)=(p–1)(q-1)=16×10=1604.Selecte:gcd(e,160)=1;choosee=75.Determined:de=1mod160andd160Valueisd=23since23×7=161=10×160+16.PublishpublickeyKU={7,187}7.KeepsecretprivatekeyKR={23,17,11}RSAExamplecontsampleRSAencryption/decryptionis:givenmessageM=88(nb.88187)encryption:C=887mod187=11decryption:M=1123mod187=88ExponentiationcanusetheSquareandMultiplyAlgorithmafast,efficientalgorithmforexponentiationconceptisbasedonrepeatedlysquaringbaseandmultiplyingintheonesthatareneededtocomputetheresultlookatbinaryrepresentationofexponentonlytakesO(log2n)multiplesfornumberneg.75=74.71=3.7=10mod11eg.3129=3128.31=5.3=4mod11Exponentiation加密举例:空白=00A=01,B=02,…,Z=26报文R