Асиметрични алгоритам шифровања

Порекло

W.DiffieandM.Hellmanpublishedanarticle"NewDirectioninCryptography"inIEEETrans.onInformationin1976,andproposedthat"asymmetriccryptographyispublicTheconceptof"keycryptosystem"hascreatedanewdirectionincryptographyresearch

Принцип рада

1.AwantstosendinformationtoB,andAandBmusthaveapairoffunctions.Publicandprivatekeysforencryptionanddecryption.

2.А’сприватекеиискептсецрет, андА’спублицкеиистолдтоБ;Б’сприватекеиискептсецрет, иБ’спублицкеиистолдтоА.

3.ВхенАвантстосендамессагетоБ,АусесБ’спублицкеитоенцрипттхемессагебецаусеАкновсБ’спублицкеи.

4.Шаље ову поруку на Б(порука је шифрована са јавношћу Б).

5.AfterBreceivesthismessage,BuseshisprivatekeytodecryptA'smessage.Allotherpeoplewhoreceivethismessagecannotdecryptit,becauseonlyBhasB'sprivatekey.

Главна апликација

Asymmetricencryption(publickeyencryption):Referstoencryptionalgorithmsthatusedifferentkeysforencryptionanddecryption,alsoknownaspublicandprivatekeyencryption.Supposethattwouserswanttoencryptandexchangedata,andthetwopartiesexchangepublickeys.Whenusing,onepartyusestheotherparty'spublickeytoencrypt,andtheotherpartycanuseitsownprivatekeytodecrypt.Iftherearenusersinanenterprise,theenterpriseneedstogeneratenpairsofkeysanddistributenpublickeys.SupposeAusesB'spublickeytoencryptamessageandsignswithA'sprivatekey.Afterreceivingthemessage,BfirstverifiesthesignaturewithA'spublickey,andthendecryptsthemessagewithhisprivatekeyafterconfirmation.Sincethepublickeycanbedisclosed,usersonlyneedtokeeptheirprivatekeys,sothedistributionofencryptionkeyswillbecomeverysimple.Atthesametime,becauseeachuser'sprivatekeyisunique,otheruserscannotonlyusethesender'spublickeytoverifythesourceoftheinformation,butalsousedigitalsignaturestoensurethatthesendercannotdenythattheinformationhasbeensent.Thedisadvantageofasymmetricencryptionisthattheencryptionanddecryptionspeedismuchslowerthansymmetricencryption.Insomeextremecases,itcanevenbe1000timesslowerthansymmetricencryption.

ДСАЦриптоСервицеПровидерРСАЦриптоСервицеПровидер

//Енцриптион

УницодеЕнцодингенцодинг=невУницодеЕнцодинг();

бајт[]ПассвордБитес=енцодинг.ГетБитес(пассворд);//Претвори лозинкууабитеарраиРСАЦриптоСервицеПровидерцрипт=невРСАЦриптоСервицеПровидер();//РСАенцриптионалгоритхм,асимметрицПассвордБитес(пассворд),асимметрицПассвордБитес(пассворд);

stringkey=crypt.ToXmlString(true);//TheoutputkeyisastringinXMLformatandcontainstheprivatekey.Thisstringshouldbeplacedasafieldinthedatabasetablewiththeuser’spasswordTogether.

//Дешифровање

RSACryptoServiceProvidercrypt=newRSACryptoServiceProvider();//Akeypairhasbeenrandomlygenerated

црипт.Цлеар();//Дестроитхецурренткеипаир

црипт.ФромКсмлСтринг(кеи)//Ентертхеипаир,тхекеиистхеКСМЛформатстрингреад фром тхе датабасетаблефиелд,тхис,тхекеифиелдПассвордБитес=црипт.Децрипт(пассворд,фалсе);//Децрипттхебитеарраи анд ретурн тхе оригинал пассворд то тхеусер

Onefeatureoftheabovemethodisthateachusercorrespondstoakeypair(includingpublicandprivatekeys),Theyareallrandomlygenerated,sotheyarealldifferent.Buttheshortcomingisalsoveryobvious,thatis,thekeyisstoredinthedatabase,ifthedatabaseiscompromised,thekeywillbeleaked.

Anothermethodistorandomlygenerateakeypair(includingpublickeyandprivatekey)accordingtotheabovemethod,exportitthroughtheToXmlString(true)method,andthenputthekeyinXMLstringformatGototheAppSettingnodeoftheWeb.configfileofyourWebprogram,andthenreadthekeythroughtheFromXmlString(key)method,whichmeansthatalluserpasswordsareencryptedanddecryptedwiththesamekeypair.

Главне функције

Theasymmetricencryptionsystemdoesnotrequirethecommunicationpartiestopassthekeyinadvanceorhaveanyagreementtocompleteconfidentialcommunication,andthekeymanagementisconvenient,whichcanpreventcounterfeitinganddenialTherefore,itismoresuitablefortheconfidentialcommunicationrequirementsinnetworkcommunication.

Главни алгоритми

РСА,Елгамал,кнапсацкалгоритам,Рабин,Д-Х,ЕЦЦ(еллиптиццурвеенцриптионалгоритам).

ThemostwidelyusedistheRSAalgorithm.Elgamalisanothercommonlyusedasymmetricencryptionalgorithm.

ElgamalwasinventedbyTaherElgamalin1985.ItisbasedontheDiffieˉHellmankeyexchangealgorithm,whichenablesbothcommunicatingpartiestoderivethesecretkeyvaluethatonlytheyknowthroughpubliccommunication[DiffieˉHellman].DiffieˉHellmanwasinventedbyWhitfieldDiffieandMartinHellmanin1976.Itisregardedasthefirstasymmetricencryptionalgorithm.ThedifferencebetweenDiffieˉHellmanandRSAisthatDiffieˉHellmanisnotanencryptionalgorithm,itjustgeneratesasecretvaluethatcanbeusedasasymmetrickey..IntheDiffieˉHellmankeyexchangeprocess,thesenderandthereceiverrespectivelygenerateasecretrandomnumber,andderivethepublicvaluefromtherandomnumber,andthenthetwopartiesexchangethepublicvalue.ThebasisoftheDiffieˉHellmanalgorithmistheabilitytogenerateasharedkey.Aslongasthepublicvalueisexchanged,bothpartiescanusetheirownprivatenumberandtheother'spublicvaluetogenerateasymmetrickey,whichiscalledasharedkey.Forbothparties,thesymmetrickeyisthesameandcanbeusedtousesymmetricencryption.Algorithmtoencryptdata.

ComparedwithRSA,oneoftheadvantagesofDiffieˉHellmanisthatitusesanewsetofvalues​​eachtimethekeyisexchanged.WhenusingtheRSAalgorithm,iftheattackerobtainstheprivatekey,thenhecannotonlydecryptMessagesinterceptedbeforecanalsodecryptallmessagesafterwards.However,RSAcanpreventman-in-the-middleattacksthroughauthentication(suchasusingX.509digitalcertificates),butDiffieHellmanisveryvulnerabletoman-in-the-middleattacks.

Алгоритхмдифференце

NonSymmetricencryptionalgorithmDifferencefromsymmetricencryptionalgorithm

First,thekeyvalueusedformessagedecryptionisdifferentfromthekeyvalueusedformessageencryption;

Secondly,theasymmetricencryptionalgorithmisthousandsoftimesslowerthanthesymmetricencryptionalgorithm,butitprotectsIntermsofcommunicationsecurity,asymmetricencryptionalgorithmshavetheadvantagethatsymmetricencryptionisdifficulttoachieve.

Toillustratethisadvantage,anexampleofasymmetricencryptionalgorithmisusedtoemphasize:

AliceusesthekeyKtoencryptthemessageandsendsittoBob.AfterBobreceivestheencryptedmessage,UsethekeyKtodecryptittorestoretheoriginalmessage.Thereisaquestionhere,thatis,howdoesAlicesendthekeyvalueusedtoencryptthemessagetoBob?TheansweristhatwhenAlicesendsthekeyvaluetoBob,itmustpassthroughanindependentsecurecommunicationchannel(thatis,noonecanlistentothechannelCommunication).

Thisneedtouseanindependentsecurechanneltoexchangesymmetricencryptionalgorithmkeyswillcausemoreproblems:

First,thereisanindependentsecurechannel,butthebandwidthofthesecurechannelislimited.,Youcan’tdirectlyuseittosendtheoriginalmessage.

Secondly,AliceandBobcannotdeterminehowlongtheirkeyvaluecanbekeptwithoutrevealing(thatis,notknownbyothers)andwhentoexchangeanewkeyvalue

Ofcourse,TheseproblemsarenotonlyencounteredbyAlice,Bobandeveryoneelsewillencounterthem,theyallneedtoexchangekeysanddealwiththesekeymanagementproblems(infact,X9.17isaDESkeymanagementANSIstandard[ANSIX9.17]).IfAlicewantstosendmessagestohundredsofpeople,thenthingswillbeevenmoretroublesome.Shemustuseadifferentkeyvaluetoencrypteachmessage.Forexample,tosendanotificationto200people,Aliceneedstoencryptthemessage200timesandencryptthemessageonceforeachrecipient.Obviously,inthiscase,thecostofusingasymmetricencryptionalgorithmforsecurecommunicationisconsiderable.

Themainadvantageofasymmetricencryptionalgorithmsistousetwokeyvalues​​insteadofone:onekeyvalueisusedtoencryptthemessage,andtheotherkeyvalueisusedtodecryptthemessage.Thesetwokeyvalues​​aregeneratedinthesameprocessandarecalledakeypair.Thekeyusedtoencryptthemessageiscalledthepublickey,andthekeyusedtodecryptthemessageiscalledtheprivatekey.Messagesencryptedwithapublickeycanonlybedecryptedwiththecorrespondingprivatekey.Theprivatekeyisknowntonooneexcepttheholder,whilethepublickeycanbesentthroughaninsecurechannelorpublishedinadirectory.

AliceneedstosendaconfidentialdocumenttoBobviaemail.First,BobusesemailtosendhispublickeytoAlice.ThenAliceencryptsthedocumentwithBob'spublickeyandsendstheencryptedmessagetoBobviaemail.SinceanymessageencryptedwithBob'spublickeycanonlybedecryptedwithBob'sprivatekey,evenifthesnoopknowsBob'spublickey,themessageisstillsafe.AfterBobreceivestheencryptedmessage,hedecryptsitwithhisprivatekeytorestoretheoriginaldocument.

Related Articles
TOP