tÌm hiỂu mẬt mà hỌc vÀ Ứng dỤng trong xÁc thỰc chỮ kÝ ĐiỆn tỬ

129
TRƯỜNG ĐẠI HỌC SƯ PHẠM HÀ NỘI KHOA CÔNG NGHỆ THÔNG TIN ------------------------ NGHIÊN CỨU KHOA HỌC Đề tài: TÌM HIỂU MẬT MÃ HỌC VÀ ỨNG DỤNG TRONG XÁC THỰC CHỮ KÝ ĐIỆN TỬ Giáo viên hướng dẫn:PGS.TS.Vũ Đình Hòa Sinh viên thực hiện:Trịnh Mai Hương

Upload: thien-nguyen-hoang

Post on 28-Jul-2015

2.591 views

Category:

Documents


6 download

TRANSCRIPT

TRNG I HC S PHM H NIKHOA CNG NGH THNG TIN ------------ ------------

NGHIN CU KHOA HC ti: TM HIU MT M HC V NG DNG TRONG XC THC CH K IN T

Gio vin hng dn:PGS.TS.V nh Ha Sinh vin thc hin:Trnh Mai Hng

H ni ,2008

Mc lc Li ni u..............................................................................................................4 Chng 1.Tng quan v mt m hc....................................................................5 1.1.Lch s pht trin ca mt m........................................................................51.1.1.Mt m hc c in........................................................................................................5 1.1.2.Thi trung c.................................................................................................................6 1.1.4.Mt m hc trong Th chin II......................................................................................8 1.1.5.Mt m hc hin i....................................................................................................11 1.2.Mt s thut ng s dng trong h mt m........................................................................16 1.3.nh ngha mt m hc.......................................................................................................19 1.4.Phn loi h mt m hc.....................................................................................................21 1.4.1.Mt m c in (ci ny ngy nay vn hay dng trong tr chi tm mt th). Da vo kiu ca php bin i trong h mt m c in, ngi ta chia h mt m lm 2 nhm: m thay th (substitution cipher) v m hon v (permutation/ transposition cipher)...................................................................................................................................21 1.4.2.Mt m hin i...........................................................................................................23

Chng 2.H mt m c in..............................................................................282.1.H m Caesar......................................................................................................................28 2.2.H m Affinne....................................................................................................................29 2.3.H m Vigenre..................................................................................................................31 2.4.H mt Hill.........................................................................................................................33 2.5. H mt Playfair..................................................................................................................34

Chng 3. Mt s cng c h tr cho thuyt mt m.......................................363.1.L thuyt s........................................................................................................................36 3.1.1.Kin thc ng d thc...............................................................................................36 3.1.2.Mt s nh l s dng trong thut m ha cng khai................................................38 3.2.L thuyt phc tp.........................................................................................................44

Chng 4. H mt m cng khai.........................................................................474.1.Gii thiu mt m vi kha cng khai................................................................................47 4.1.1.Lch s.........................................................................................................................47 4.1.2.L thuyt mt m cng khai........................................................................................49 4.1.3.Nhng yu im, hn ch ca mt m vi kha cng khai.........................................51 4.1.4.ng dng ca mt m..................................................................................................52 4.2.H mt RSA........................................................................................................................54 4.2.1.Lch s.........................................................................................................................54 4.2.2.M t thut ton...........................................................................................................55 b. M ha..............................................................................................................................57 c. Gii m..............................................................................................................................57 V d.....................................................................................................................................58 4.2.3.Tc m ha RSA.....................................................................................................59 4.2.4. an ton ca RSA....................................................................................................60 4.2.5.S che du thng tin trong h thng RSA...................................................................63 4.3.H mt Rabin......................................................................................................................66 4.3.1.M t gii thut Rabin.................................................................................................66 4.3.2.nh gi hiu qu........................................................................................................68

4.4.Ch k in t....................................................................................................................68 4.4.1.nh ngha...................................................................................................................70 4.4.2.Hm bm......................................................................................................................71 4.4.3.Mt s s ch k in t........................................................................................75

Chng 5. Xy dng phn mm ng dng........................................................815.1.nh ngha bi ton.............................................................................................................81 5.2.Phn tch v thit k............................................................................................................82 5.2.1. Qu trnh k trong Message........................................................................................83 5.2.2. Qu trnh kim tra xc nhn ch k trn ti liu........................................................84 5.3.Chng trnh ci t...........................................................................................................87 Chng trnh chy trn hu ht cc h iu hnh ca windows. Ci t bng ngn ng C# trn mi trng Visual Studio 2005. .......................................................................................87

Li ni uHin nay , cng ngh thng tin, cng ngh Internet, cng ngh E-mail, Ebusiness pht trin nh v bo.Vit Nam , ang tng bc p dng cng ngh mi tin hc ha x hi tc l a tin hc vo cc lnh vc ca x hi ci thin hot ng th cng trc y.Tin hc ha gii phng sc lao ng ca con ngi bng cch sng ch my ht bi, my git , my ra bt, cc con robot lm vic trong hm m-ni rt nguy him v c hi cho sc khe ca con ngi Ngoi ra,Tin hc cn c a vo qun l hnh chnh Nh nc.Trong giai on 2001-2005, Th tng Phan Vn Khi ph duyt nhiu n tin hc ha qun l hnh chnh Nh nc vi mc tiu quyt tm xy dng mt Chnh ph in t Vit Nam.Nu n ny thnh cng th ngi dn c th tm hiu thng tin cn thit vn mang tnh giy t nh giy khai sinh, khai t, ng k lp hc, xin thnh lp doanh nghip,xin cp h chiu, xin bo h tc quyn hay quyn s hu cng nghipthng qua a ch mng m khng cn phi n c quan hnh chnh.Nh vy chng ta c th trao i mi thng tin qua mng.Thng tin m chng ta gi i c th l thng tin qun s, ti chnh, kinh doanh hoc n gin l mt thng tin no mang tnh ring tiu ny dn ti mt vn xy ra l Internet l mi trng khng an ton, y ri ro v nguy him, khng c g m bo rng thng tin m chng ta truyn i khng b c trm trn ng truyn. Do , mt bin php c a ra nhm gip chng ta t bo v chnh mnh cng nh nhng thng tin m chng ta gi i l cn phi m ha thng tin.Ngy nay bin php ny c nhiu ni s dng nh l cng c bo v an ton cho bn thn.Mt v d in hnh cc ngn hng li dng tnh nng ca m ha tch hp cng ngh ch k s vo cc giao dch thng mai in t trc tuyn, m bo tnh ton vn cua d liu, tnh bi mt, tnh chng chi bo giao dich (bng chng) trong cc giao dch thng mai in t online V l mc ch chnh ca lun vn l tm hiu l thuyt mt m a l thuyt ng dng vo thc t.

Chng 1.Tng quan v mt m hc 1.1.Lch s pht trin ca mt mMt m hc l mt ngnh c lch s t hng nghn nm nay. Trong phn ln thi gian pht trin ca mnh (ngoi tr vi thp k tr li y), lch s mt m hc chnh l lch s ca nhng phng php mt m hc c in - cc phng php mt m ha vi bt v giy, i khi c h tr t nhng dng c c kh n gin. Vo u th k XX, s xut hin ca cc c cu c kh v in c, chng hn nh my Enigma, cung cp nhng c ch phc tp v hiu qu hn cho vic mt m ha. S ra i v pht trin mnh m ca ngnh in t v my tnh trong nhng thp k gn y to iu kin mt m hc pht trin nhy vt ln mt tm cao mi. S pht trin ca mt m hc lun lun i km vi s pht trin ca cc k thut ph m (hay thm m). Cc pht hin v ng dng ca cc k thut ph m trong mt s trng hp c nh hng ng k n cc s kin lch s. Mt vi s kin ng ghi nh bao gm vic pht hin ra bc in Zimmermann khin Hoa K tham gia Th chin 1 v vic ph m thnh cng h thng mt m ca c Quc x gp phn lm y nhanh thi im kt thc th chin II. Cho ti u thp k 1970, cc k thut lin quan ti mt m hc hu nh ch nm trong tay cc chnh ph. Hai s kin khin cho mt m hc tr nn thch hp cho mi ngi, l: s xut hin ca tiu chun mt m ha DES v s ra i ca cc k thut mt m ha kha cng khai.1.1.1.Mt m hc c in

Nhng bng chng sm nht v s dng mt m hc l cc ch tng hnh khng tiu chun tm thy trn cc bc tng Ai Cp c i (cch y khong 4500). Nhng k hiu t ra khng phi phc v mc ch truyn thng tin b mt m c v nh l nhm mc ch gi nn nhng iu thn b, tr t m hoc thm ch to s thch th cho ngi xem. Ngoi ra cn rt nhiu v d khc v nhng ng dng ca mt m hc hoc l nhng iu tng t. Mun hn, cc hc

gi v ting Hebrew c s dng mt phng php m ha thay th bng ch ci n gin chng hn nh mt m ha Atbash (khong nm 500 n nm 600). Mt m hc t lu c s dng trong cc tc phm tn gio che giu thng tin vi chnh quyn hoc nn vn ha thng tr. V d tiu biu nht l "s ch k th ca Cha" (ting Anh: Number of the Beast) xut hin trong kinh Tn c ca C c gio. y, s 666 c th l cch m ha ch n ch La M hoc l n hong Nero ca ch ny. Vic khng cp trc tip s gy rc ri khi cun sch b chnh quyn ch . i vi C c gio chnh thng th vic che du ny kt thc khi Constantine ci o v chp nhn o C c l tn gio chnh thng ca ch. Ngi Hy Lp c i cng c bit n l s dng cc k thut mt m (chng hn nh mt m scytale). Cng c nhng bng chng r rng chng t ngi La M nm c cc k thut mt m (mt m Caesar v cc bin th). Thm ch c nhng cp n mt cun sch ni v mt m trong qun i La M; tuy nhin cun sch ny tht truyn. Ti n , mt m hc cng kh ni ting. Trong cun sch Kama Sutra, mt m hc c xem l cch nhng ngi yu nhau trao i thng tin m khng b pht hin.1.1.2.Thi trung c

Nguyn do xut pht c th l t vic phn tch bn kinh Quran, do nhu cu tn gio, m k thut phn tch tn sut c pht minh ph v cc h thng mt m n k t vo khong nm 1000. y chnh l k thut ph m c bn nht c s dng, mi cho ti tn thi im ca th chin th II. V nguyn tc, mi k thut mt m u khng chng li c k thut phn tch m (cryptanalytic technique) ny cho ti khi k thut mt m a k t c Alberti sng to (nm 1465). Mt m hc ngy cng tr nn quan trng di tc ng ca nhng thay i, cnh tranh trong chnh tr v tn gio. Chng hn ti chu u, trong v sau

thi k Phc hng, cc cng dn ca cc thnh bang thuc , gm c cc thnh bang thuc gio phn v Cng gio La M, s dng v pht trin rng ri cc k thut mt m. Tuy nhin rt t trong s ny tip thu c cng trnh ca Alberti (cc cng trnh ca h khng phn nh s hiu bit hoc tri thc v k thut tn tin ca Alberti) v do hu nh tt c nhng ngi pht trin v s dng cc h thng ny u qu lc quan v an ton. iu ny hu nh vn cn ng cho ti tn hin nay, nhiu nh pht trin khng xc nh c im yu ca h thng. Do thiu hiu bit cho nn cc nh gi da trn suy on v hy vng l ph bin. Mt m hc, phn tch m hc v s phn bi ca nhn vin tnh bo, ca ngi a th, u xut hin trong m mu Babington din ra di triu i ca n hong Elizabeth I dn n kt cc x t n hong Mary I ca Scotland. Mt thng ip c m ha t thi "ngi di mt n st" (Man in the Iron Mask) (c gii m vo khong 1900 bi tienne Bazeries) cho bit mt s thng tin v s phn ca t nhn ny (ng tic thay l nhng thng tin ny cng cha c r rng cho lm). Mt m hc, v nhng lm dng ca n, cng l nhng phn t lin quan n mu dn ti vic x t Mata Hari v m mu qu quyt dn n tr h trong vic kt n Dreyfus v b t hai ngi u th k 20. May mn thay, nhng nh mt m hc (cryptographer) cng nhng tay vo vic phi by mu dn n cc khc mc ca Dreyfus; Mata Hari, ngc li, b bn cht. Ngoi cc nc Trung ng v chu u, mt m hc hu nh khng c pht trin. Ti Nht Bn, mi cho ti 1510, mt m hc vn cha c s dng v cc k thut tin tin ch c bit n sau khi nc ny m ca vi phng Ty (thp k 1860). 1.1.3.Mt m hc t nm 1800 n Th chin II Tuy mt m hc c mt lch s di v phc tp, mi cho n th k 19 n mi c pht trin mt cch c h thng, khng ch cn l nhng tip cn nht thi, v t chc. Nhng v d v phn tch m bao gm cng trnh ca Charles Babbage trong k nguyn ca Chin tranh Krim (Crimean War) v ton phn tch mt m n k t. Cng trnh ca ng, tuy hi mun mng, c Friedrich

Kasiski, ngi Ph, khi phc v cng b. Ti thi im ny, hiu c mt m hc, ngi ta thng phi da vo nhng kinh nghim tng tri (rules of thumb); xin xem thm cc bi vit v mt m hc ca Auguste Kerckhoffs cui th k 19. Trong thp nin 1840, Edgar Allan Poe xy dng mt s phng php c h thng gii mt m. C th l, ng by t kh nng ca mnh trong t bo hng tun Alexander's Weekly (Express) Messenger Philadelphia, mi mi ngi trnh cc phng php m ha ca h, v ng l ngi ng ra gii. S thnh cng ca ng gy chn ng vi cng chng trong vi thng. Sau ny ng c vit mt lun vn v cc phng php mt m ha v chng tr thnh nhng cng c rt c li, c p dng vo vic gii m ca c trong Th chin II. Trong thi gian trc v ti thi im ca Th chin II, nhiu phng php ton hc hnh thnh (ng ch l ng dng ca William F. Friedman dng k thut thng k phn tch v kin to mt m, v thnh cng bc u ca Marian Rejewski trong vic b gy mt m ca h thng Enigma ca Qun i c). Sau Th chin II tr i, c hai ngnh, mt m hc v phn tch m, ngy cng s dng nhiu cc c s ton hc. Tuy th, ch n khi my tnh v cc phng tin truyn thng Internet tr nn ph bin, ngi ta mi c th mang tnh hu dng ca mt m hc vo trong nhng thi quen s dng hng ngy ca mi ngi, thay v ch c dng bi cc chnh quyn quc gia hay cc hot ng kinh doanh ln trc .1.1.4.Mt m hc trong Th chin II

Trong th chin II, cc h thng mt m c kh v c in t c s dng rng ri mc d cc h thng th cng vn c dng ti nhng ni khng iu kin. Cc k thut phn tch mt m c nhng t ph trong thi k ny, tt c u din ra trong b mt. Cho n gn y, cc thng tin ny mi dn c tit l do thi k gi b mt 50 nm ca chnh ph Anh kt thc, cc bn lu ca Hoa K dn c cng b cng vi s xut hin ca cc bi bo v hi k c lin quan.

Ngi c s dng rng ri mt h thng my rto c in t, di nhiu hnh thc khc nhau, c tn gi l my Enigma. Vo thng 12 nm 1932, Marian Rejewski, mt nh ton hc ti Cc mt m Ba Lan (ting Ba Lan: Biuro Szyfrw), dng li h thng ny da trn ton hc v mt s thng tin c c t cc ti liu do i y Gustave Bertrand ca tnh bo qun s Php cung cp. y c th coi l t ph ln nht trong lch s phn tch mt m trong sut mt nghn nm tr li. Rejewski cng vi cc ng s ca mnh l Jerzy Rycki v Henryk Zygalski tip tc nghin cu v bt nhp vi nhng tin ha trong cc thnh phn ca h thng cng nh cc th tc mt m ha. Cng vi nhng tin trin ca tnh hnh chnh tr, ngun ti chnh ca Ba Lan tr nn cn kit v nguy c ca cuc chin tranh tr nn gn k, vo ngy 25 thng 7 nm 1939 ti Warszawa, cc mt m Ba Lan, di ch o ca b tham mu, trao cho i din tnh bo Php v Anh nhng thng tin b mt v h thng Enigma. Ngay sau khi Th chin II bt u (ngy 1 thng 9 nm 1939), cc thnh vin ch cht ca cc mt m Ba Lan c s tn v pha ty nam; v n ngy 17 thng 9, khi qun i Lin X tin vo Ba Lan, th h li c chuyn sang Romania. T y, h ti Paris (Php). Ti PC Bruno, gn Paris, h tip tc phn tch Enigma v hp tc vi cc nh mt m hc ca Anh ti Bletchley Park lc ny tin b kp thi. Nhng ngi Anh, trong bao gm nhng tn tui ln ca ngnh mt m hc nh Gordon Welchaman v Alan Turing, ngi sng lp khi nim khoa hc in ton hin i, gp cng ln trong vic pht trin cc k thut ph m h thng my Enigma. Ngy 19 thng 4 nm 1945, cc tng lnh cp cao ca Anh c ch th khng c tit l tin tc rng m Enigma b ph, bi v nh vy n s to iu kin cho k th b nh bi c s ni rng h "khng b nh bi mt cch sng phng" (were not well and fairly beaten). Cc nh mt m hc ca Hi qun M (vi s hp tc ca cc nh mt m hc Anh v H Lan sau 1940) xm nhp c vo mt s h thng mt m ca Hi qun Nht. Vic xm nhp vo h thng JN-25 trong s chng mang li chin thng v vang cho M trong trn Midway. SIS, mt nhm trong qun i

M, thnh cng trong vic xm nhp h thng mt m ngoi giao ti mt ca Nht (mt my c in dng "b chuyn mch dch bc" (stepping switch) c ngi M gi l Purple) ngay c trc khi th chin II bt u. Ngi M t tn cho nhng b mt m hc tm c t vic thm m, c th c bit l t vic ph m my Purple, vi ci tn "Magic". Ngi Anh sau ny t tn cho nhng b mt m h tm ra trong vic thm m, c bit l t lung thng ip c m ha bi cc my Enigma, l "Ultra". Ci tn Anh trc ca Ultra l Boniface. Qun i c cng cho trin khai mt s th nghim c hc s dng thut ton mt m dng mt ln (one-time pad). Bletchley Park gi chng l m Fish, v ng Max Newman cng ng nghip ca mnh thit k ra mt my tnh in t s kh lp trnh (programmable digital electronic computer) u tin l my Colossus gip vic thm m ca h. B ngoi giao c bt u s dng thut ton mt m dng mt ln vo nm 1919; mt s lung giao thng ca n b ngi ta c c trong Th chin II, mt phn do kt qu ca vic khm ph ra mt s ti liu ch cht ti Nam M, do s bt cn ca nhng ngi a th ca c khng hy thng ip mt cch cn thn. B ngoi giao ca Nht cng cc b xy dng mt h thng da trn nguyn l ca "b in c chuyn mch dch bc" (c M gi l Purple), v ng thi cng s dng mt s my tng t trang b cho mt s ta i s Nht Bn. Mt trong s chng c ngi M gi l "My-M" (M-machine), v mt ci na c gi l "Red". Tt c nhng my ny u t nhiu b pha ng Minh ph m. SIGABA c miu t trong Bng sng ch ca M 6.175.625, trnh nm 1944 song mi n nm 2001 mi c pht hnh

Cc my mt m m phe ng minh s dng trong th chin II, bao gm c my TypeX ca Anh v my SIGABA ca M, u l nhng thit k c in dng rto trn tinh thn tng t nh my Enigma, song vi nhiu nng cp ln. Khng c h thng no b ph m trong qu trnh ca cuc chin tranh. Ngi Ba Lan s dng my Lacida, song do tnh thiu an ninh, my khng tip tc c dng. Cc phn i trn mt trn ch s dng my M-209 v cc my thuc h M-94 t bo an hn. u tin, cc nhn vin mt v trong C quan c v ca Anh (Special Operations Executive - SOE) s dng "mt m th" (cc bi th m h ghi nh l nhng cha kha), song nhng thi k sau trong cuc chin, h bt u chuyn sang dng cc hnh thc ca mt m dng mt ln (one-time pad).1.1.5.Mt m hc hin i

Nhiu ngi cho rng k nguyn ca mt m hc hin i c bt u vi Claude Shannon, ngi c coi l cha ca mt m ton hc. Nm 1949 ng cng b bi L thuyt v truyn thng trong cc h thng bo mt (Communication Theory of Secrecy Systems) trn tp san Bell System Technical Journal - Tp san k thut ca h thng Bell - v mt thi gian ngn sau , trong cun Mathematical Theory of Communication - L thuyt ton hc trong truyn thng - cng vi tc gi Warren Weaver. Nhng cng trnh ny, cng vi nhng cng trnh nghin cu khc ca ng v l thuyt v tin hc v truyn thng (information and communication theory), thit lp mt nn tng l thuyt c bn cho mt m hc v thm m hc. Vi nh hng , mt m hc hu nh b

thu tm bi cc c quan truyn thng mt ca chnh ph, chng hn nh NSA, v bin mt khi tm hiu bit ca cng chng. Rt t cc cng trnh c tip tc cng b, cho n thi k gia thp nin 1970, khi mi s c thay i. Thi k gia thp nin k 1970 c chng kin hai tin b cng chnh ln (cng khai). u tin l s cng b xut Tiu chun mt m ha d liu (Data Encryption Standard) trong "Cng bo Lin bang" (Federal Register) nc M vo ngy 17 thng 3 nm 1975. Vi c ca Cc Tiu chun Quc gia (National Bureau of Standards - NBS) (hin l NIST), bn xut DES c cng ty IBM (International Business Machines) trnh tr thnh mt trong nhng c gng trong vic xy dng cc cng c tin ch cho thng mi, nh cho cc nh bng v cho cc t chc ti chnh ln. Sau nhng ch o v thay i ca NSA, vo nm 1977, n c chp thun v c pht hnh di ci tn Bn Cng b v Tiu chun X l Thng tin ca Lin bang (Federal Information Processing Standard Publication - FIPS) (phin bn hin nay l FIPS 46-3). DES l phng thc mt m cng khai u tin c mt c quan quc gia nh NSA "tn sng". S pht hnh bn c t ca n bi NBS khuyn khch s quan tm ch ca cng chng cng nh ca cc t chc nghin cu v mt m hc. Nm 2001, DES chnh thc c thay th bi AES (vit tt ca Advanced Encryption Standard - Tiu chun m ha tin tin) khi NIST cng b phin bn FIPS 197. Sau mt cuc thi t chc cng khai, NIST chn Rijndael, do hai nh mt m ngi B trnh, v n tr thnh AES. Hin nay DES v mt s bin th ca n (nh Tam phn DES (Triple DES); xin xem thm trong phin bn FIPS 46-3), vn cn c s dng, do trc y n c gn lin vi nhiu tiu chun ca quc gia v ca cc t chc. Vi chiu di kho ch l 56-bit, n c chng minh l khng sc chng li nhng tn cng kiu vt cn (brute force attack - tn cng dng bo lc). Mt trong nhng cuc tn cng kiu ny c thc hin bi nhm "nhn quyn cyber" (cyber civil-rights group) tn l T chc tin tuyn in t (Electronic Frontier Foundation) vo nm 1997, v ph m thnh cng trong 56 ting ng h -- cu chuyn ny c nhc n trong cun Cracking DES (Ph v DES), c xut bn bi "O'Reilly and Associates".

Do kt qu ny m hin nay vic s dng phng php mt m ha DES nguyn dng, c th c khng nh mt cch khng nghi ng, l mt vic lm mo him, khng an ton, v nhng thng ip di s bo v ca nhng h thng m ha trc y dng DES, cng nh tt c cc thng ip c truyn gi t nm 1976 tr i s dng DES, u trong tnh trng rt ng lo ngi. Bt chp cht lng vn c ca n, mt s s kin xy ra trong nm 1976, c bit l s kin cng khai nht ca Whitfield Diffie, ch ra rng chiu di kha m DES s dng (56-bit) l mt kha qu nh. c mt s nghi ng xut hin ni rng mt s cc t chc ca chnh ph, ngay ti thi im hi by gi, cng c cng sut my tnh ph m cc thng ip dng DES; r rng l nhng c quan khc cng c kh nng thc hin vic ny ri. Tin trin th hai, vo nm 1976, c l cn t ph hn na, v tin trin ny thay i nn tng c bn trong cch lm vic ca cc h thng mt m ha. chnh l cng b ca bi vit phng hng mi trong mt m hc (New Directions in Cryptography) ca Whitfield Diffie v Martin Hellman. Bi vit gii thiu mt phng php hon ton mi v cch thc phn phi cc kha mt m. y l mt bc tin kh xa trong vic gii quyt mt vn c bn trong mt m hc, vn phn phi kha, v n c gi l trao i kha Diffie-Hellman (Diffie-Hellman key exchange). Bi vit cn kch thch s pht trin gn nh tc thi ca mt lp cc thut ton mt m ha mi, cc thut ton cha kha bt i xng (asymmetric key algorithms). Trc thi k ny, hu ht cc thut ton mt m ha hin i u l nhng thut ton kha i xng (symmetric key algorithms), trong c ngi gi v ngi nhn phi dng chung mt kha, tc kha dng trong thut ton mt m, v c hai ngi u phi gi b mt v kha ny. Tt c cc my in c dng trong th chin II, k c m Caesar v m Atbash, v v bn cht m ni, k c hu ht cc h thng m c dng trong sut qu trnh lch s na u thuc v loi ny. ng nhin, kha ca mt m chnh l sch m (codebook), v l ci cng phi c phn phi v gi gn mt cch b mt tng t.

Do nhu cu an ninh, kha cho mi mt h thng nh vy nht thit phi c trao i gia cc bn giao thng lin lc bng mt phng thc an ton no y, trc khi h s dng h thng (thut ng thng c dng l 'thng qua mt knh an ton'), v d nh bng vic s dng mt ngi a th ng tin cy vi mt cp ti liu c kha vo c tay bng mt cp kha tay, hoc bng cuc gp g mt i mt, hay bng mt con chim b cu a th trung thnh... Vn ny cha bao gi c xem l d thc hin, v n nhanh chng tr nn mt vic gn nh khng th qun l c khi s lng ngi tham gia tng ln, hay khi ngi ta khng cn cc knh an ton trao i kha na, hoc lc h phi lin tc thay i cc cha kha - mt thi quen nn thc hin trong khi lm vic vi mt m. C th l mi mt cp truyn thng cn phi c mt kha ring nu, theo nh thit k ca h thng mt m, khng mt ngi th ba no, k c khi ngi y l mt ngi dng, c php gii m cc thng ip. Mt h thng thuc loi ny c gi l mt h thng dng cha kha mt, hoc mt h thng mt m ha dng kha i xng. H thng trao i kha Diffie-Hellman (cng nhng phin bn c nng cp k tip hay cc bin th ca n) to iu kin cho cc hot ng ny trong cc h thng tr nn d dng hn rt nhiu, ng thi cng an ton hn, hn tt c nhng g c th lm trc y. Ngc li, i vi mt m ha dng kha bt i xng, ngi ta phi c mt cp kha c quan h ton hc dng trong thut ton, mt dng m ha v mt dng gii m. Mt s nhng thut ton ny, song khng phi tt c, c thm c tnh l mt trong cc kha c th c cng b cng khai trong khi ci kia khng th no (t nht bng nhng phng php hin c) c suy ra t kha 'cng khai'. Trong cc h thng ny, kha cn li phi c gi b mt v n thng c gi bng mt ci tn, hi c v ln xn, l kha 'c nhn' (private key) hay kha b mt. Mt thut ton thuc loi ny c gi l mt h thng 'kha cng khai' hay h thng kha bt i xng. i vi nhng h thng dng cc thut ton ny, mi ngi nhn ch cn c mt cp cha kha m thi (bt chp s ngi gi l bao nhiu i chng na). Trong 2 kha, mt kha lun c gi b mt v mt c cng b cng khai nn khng cn phi dng n mt knh an ton trao i kha. Ch cn m bo kha b mt khng b l th an ninh ca h

thng vn c m bo v c th s dng cp kha trong mt thi gian di. c tnh ng ngc nhin ny ca cc thut ton to kh nng, cng nh tnh kh thi, cho php vic trin khai cc h thng mt m c cht lng cao mt cch rng ri, v ai cng c th s dng chng c. Cc thut ton mt m kha bt i xng da trn mt lp cc bi ton gi l hm mt chiu (one-way functions). Cc hm ny c c tnh l rt d dng thc hin theo chiu xui nhng li rt kh (v khi lng tnh ton) thc hin theo chiu ngc li. Mt v d kinh in cho lp bi ton ny l hm nhn hai s nguyn t rt ln. Ta c th tnh tch s ca 2 s nguyn t ny mt cch kh d dng nhng nu ch cho bit tch s th rt kh tm ra 2 tha s ban u. Do nhng c tnh ca hm mt chiu, hu ht cc kha c th li l nhng kha yu v ch cn li mt phn nh c th dng lm kha. V th, cc thut ton kha bt i xng i hi di kha ln hn rt nhiu so vi cc thut ton kha i xng t c an ton tng ng. Ngoi ra, vic thc hin thut ton kha bt i xng i hi khi lng tnh ton ln hn nhiu ln so vi thut ton kha i xng. Bn cnh , i vi cc h thng kha i xng, vic to ra mt kha ngu nhin lm kha phin ch dng trong mt phin giao dch l kh d dng. V th, trong thc t ngi ta thng dng kt hp: h thng mt m kha bt i xng c dng trao i kha phin cn h thng mt m kha i xng dng kha phin c c trao i cc bn tin thc s. Mt m hc dng kha bt i xng, tc trao i kha Diffie-Hellman, v nhng thut ton ni ting dng kha cng khai / kha b mt (v d nh ci m ngi ta vn thng gi l thut ton RSA), tt c hnh nh c xy dng mt cch c lp ti mt c quan tnh bo ca Anh, trc thi im cng b ca Diffie and Hellman vo nm 1976. S ch huy giao thng lin lc ca chnh ph (Government Communications Headquarters - GCHQ) - C quan tnh bo Anh Quc - c xut bn mt s ti liu qu quyt rng chnh h xy dng mt m hc dng kha cng khai, trc khi bi vit ca Diffie v Hellman c cng b. Nhiu ti liu mt do GCHQ vit trong qu trnh nhng nm 1960 v 1970, l nhng bi cui cng cng dn n mt s k hoch i b phn tng t nh

phng php mt m ha RSA v phng php trao i cha kha Diffie-Hellman vo nm 1973 v 1974. Mt s ti liu ny hin c pht hnh, v nhng nh sng ch (James H. Ellis, Clifford Cocks, v Malcolm Williamson) cng cho cng b (mt s) cng trnh ca h. 1.2.Mt s thut ng s dng trong h mt m Sender/Receiver: Ngi gi/Ngi nhn d liu. Vn bn (Plaintext -Cleartext): Thng tin trc khi c m ho. y l d liu ban u dng r. Thng tin gc c ghi bng hnh nh m thanh, ch s, ch vitmi tn hiu u c th c s ha thnh cc xu k t s Ciphertext: Thng tin, d liu c m ho dng m Kha (key): Thnh phn quan trng trong vic m ho v gii m. Kha l i lng b mt, bin thin trong mt h mt. Kha nht nh phi l b mt. Kha nht nh phi l i lng bin thin. Tuy nhin, c th c trng hp i lng bin thin trong h mt khng phi l kha. V d: vector khi to (IV = Initial Vector) ch CBC, OFB v CFB ca m khi. CryptoGraphic Algorithm: L cc thut ton c s dng trong vic m ho hoc gii m thng tin H m (CryptoSystem hay cn gi l h thng m): H thng m ho bao gm thut ton m ho, kho, Plaintext,Ciphertext K thut mt m (cryptology) l mn khoa hc bao gm hai lnh vc: mt m (crytography) v m thm (cryptoanalysis). Mt m (cryptography) l lnh vc khoa hc v cc phng php bin i thng tin nhm mc ch bo v thng tin khi s truy cp ca nhng ngi khng c thm quyn. M thm (cryptoanalysis) l lnh vc khoa hc chuyn nghin cu, tm kim yu im ca cc h mt t a ra phng php tn cng cc h mt . Mt m v m thm l hai lnh vc i lp nhau nhng gn b mt thit vi nhau. Khng th xy dng mt h mt tt nu khng hiu bit su v m thm. M thm

ch ra yu im ca h mt. Yu im ny c th c s dng tn cng h mt ny nhng cng c th c s dng ci tin h mt cho tt hn. Nu ngi xy dng h mt khng c hiu bit rng v m thm, khng kim tra an ton ca h mt trc cc phng php tn cng th h mt ca anh ta c th t ra km an ton trc mt phng php tn cng no m anh ta cha bit. Tuy nhin, khng ai c th khng nh l c nhng phng php thm m no c bit n. c nhim ca cc nc lun gi b mt nhng kt qu thu c trong lnh vc m thm: k c phng php thm m v kt qa ca vic thm m. S mt m l tp hp cc thut ton m ha, gi m, kim tra s ton vn v cc chc nng khc ca mt h mt. Giao thc mt m l tp hp cc quy tc, th tc quy nh cch thc s dng s mt m trong mt h m. C th thy rng "giao thc mt m" v "s mt m" khng i lin vi nhau. C th c nhiu giao thc khc mt m khc nhau quy nh cc cch thc s dng khc nhau ca cng mt s mt m no . Lp m (Encrypt) l vic bin vn bn ngun thnh vn bn m Gii m (Decrypt) l vic a vn bn m ha tr thnh dng vn bn ngun. nh m (encode/decode) l vic xc nh ra php tng ng gia cc ch v s - Tc m c c trng bi s lng php tnh (N) cn thc hin m ha (gii m) mt n v thng tin. Cn hiu rng tc m ch ph thuc vo bn thn h m ch khng ph thuc vo c tnh ca thit b trin trin khai n (tc my tnh, my m...). an ton ca h m c trng cho kh nng ca h m chng li s thm m; n c o bng s lng php tnh n gin cn thc hin thm h m trong iu kin s dng thut ton (phng php) thm tt nht. Cn phi ni thm rng c th xy dng nhng h mt vi an tan bng v cng (tc l khng th thm c v mt l thuyt). Tuy nhin cc h mt ny khng thun tin cho vic s dng, i hi chi ph cao. V th, trn thc t, ngi ta s dng nhng h mt c gii hn i vi an tan. Do bt k h mt no cng c th b thm trong thi gian no (v d nh sau... 500 nm chng hn). Kh nng chng nhiu ca m l kh nng chng li s pht tn li trong bn tin sau khi gii m, nu trc xy ra li vi bn m trong qu trnh bn m c truyn t ngi gi n ngi nhn. C 3 loi li l:

li thay th k t: mt k t b thay i thnh mt k t khc. V d: abcd atcd li chn k t: mt k t c chn vo chui k t c truyn i. V d: abcd azbcd li mt k t: mt k t trong chui b mt. V d: abcd abd.

Nh vy khi nim kh nng chng nhiu trong mt m c hiu khc hn so vi khi nim ny trong lnh vc truyn tin. Trong truyn tin kh nng chng nhiu l mt trong nhng c trng ca m chng nhiu (noise combating code) - kh nng pht hin v sa li ca m chng nhiu. V d: m (7,4) ca Hemming c th pht hin 2 li v sa 1 li trong khi 7 bits (4 bits thng tin c ch v 3 bits dng kim tra v sa li). M dng (Stream cipher) l vic tin hnh m ha lin tc trn tng k t hay tng bit. M khi (Block cipher) l vic tin hnh m trn tng khi vn bn. Mc ch ca m ha l che du thng tin trc khi truyn trn knh truyn. C nhiu phng php mt m khc nhau, tuy vy tt c chng c hai php ton thc hin trong mt m l php m ha v gii m. C th biu th php m ha v php ton gii m nh cc hm ca hai bin s, hoc c th nh mt thut ton, c ngha l mt th tc i xng tnh kt qu khi gi tr cc tham s cho. Bn tin r y l tp hp cc d liu trc khi thc hin m ha. Kt qu ca php m ha l bn tin c m ha. Vic gii m bn tin c m ha s thu c bn tin r ban u. C biu thc bn tin r v bn tin m ha u c lin quan n mt mt m c th. Cc ch ci vit hoa D (Decipherment) v E (Encipherment) l k hiu cho cc hm gii m v m ha tng ng. K hiu x l l bn tin v y l bn tin m ha th biu thc ton hc ca php m ha l: y= Ek(x) v ca php gii m l:

x=Dk(y) Trong tham s ph k l kha m Kha m l mt c tnh quan trng ca thut ton mt m.V nguyn l nu hm y=E(x) khng c mt kha m no, th cng c th che du c gi tr ca x Tp hp cc gi tr ca kho k c gi l khng gian cc kha. Trong mt mt m no , nu kha m c 20 s thp phn s cho khn gian cc kha l 10 20 . Nu kha no c 50 s nh phn th khng gian cc kha s l 250. Nu kha l mt hon v ca 26 ch ci A,B,CZ th khng gian cc kha s l 26! K hiu chung: P l thng tin ban u, trc khi m ho. E() l thut ton m ho. D() l thut ton gii m. C l thng tin m ho. K l kho. Chng ta biu din qu trnh m ho v gii m nh sau: Qu trnh m ho c m t bng cng thc: Ek(P)=C Qu trnh gii m c m t bng cng thc: Dk(C)=P

1.3.nh ngha mt m hc i tng c bn ca mt m l to ra kh nng lin lc trn mt knh khng mt cho hai ngi s dng (tm gi l Alice v Bob) sao cho i phng (Oscar) khng th hiu c thng tin truyn i. Knh ny c th l mt ng dy in thoi hoc mt mng my tnh. Thng tin m Alice mun gi cho Bob (bn r) c th l bn ting anh, cc d liu bng s hoc bt k ti liu no c cu trc ty . Alice s m ha bn r bng mt kha c xc nh trc v gi bn m kt qu trn knh. Osar c bn m thu trm c trn knh song khng th xc nh ni dung ca bn r, nhng Bob (ngi bit kha m) c th gii m v thu c bn r. Ta s m t hnh thc ha ni dung bng cch dng khi nim ton hc nh sau Mt h mt m l mt b 5 thnh phn (P,C,K,E,D) tha mn cc tnh cht sau: 1.P l mt tp hu hn cc bn r c th 2.C l mt tp hu hn cc bn m c th 3.K(khng gian kha) l tp hu hn cc kha c th

4.i vi mi kK c mt quy tc m ek: PC v mt quy tc gii m tng ng dkD. Mi ek:PC v dk :CP l nhng hm Dk(ek(x))=x vi mi bn r xP Trong tnh cht 4 l tnh cht ch yu y. Ni dung ca n l nu mt bn r x c m ha bng ek v bn m nhn c sau c gii m bng dk th ta phi thu c bn r ban u x. Alice v Bob s p dng th tc sau khi dng h mt kha ring. Trc tin h chn mt kha ngu nhin k K. iu ny c thc hin khi h cng mt ch v khng b Oscar theo di hoc h c mt knh mt trong trng hp h xa nhau. Sau gi s Alice mun gi mt thng bo cho Bob trn mt knh khng mt v ta xem thng bo ny l mt chui: x = x1,x2 ,. . .,xn vi s nguyn n1 no . y mi k hiu ca mi bn r xi P, 1 i n. Mi xi s c m ha bng quy tc m ek vi kha k xc nh trc .Bi vy Alice s tnh yi =ek(xi), 1 i n v chui bn nhn c y = y1,y2 ,. . .,yn s c gi trn knh. Khi Bob nhn c y = y1,y2 ,. . .,yn anh ta s gii m bng hm gii m dk v thu c bn r gc x1,x2 ,. . .,xn. Hnh 1.1. l mt v d v mt knh lin lc

Oscar Alice B m ha B gii m Bob

Knh an ton Ngun kha

R rng trong trng hp ny hm m ho phi l hm n nh (tc l nh x 11), nu khng vic giai rmax s khng thc hin c mt cch tng minh. V d y= ek(x1)=ek(x2) trong x1 x2, th Bob s khng c cch no bit liu s phi gii m thnh x1 hay x2. Ch rng nu P = C th mi hm m ha ize=2. Bn quyn Cng ty Pht tp cc bn m v tp cc bn r l ng nht th mi mt hm m s l mt s sp xp li (hay hon v) cc phn t ca tp ny

1.4.Phn loi h mt m hc Lch s ca mt m hc chnh l lch s ca phng php mt m hc c in- phng php m ha bt v giy. Sau ny da trn nn tng ca mt m hc c in xut hin phng php m ha mi. Chnh v vy mt m hc c phn chia thnh mt m hc c in v mt m hc hin i1.4.1.Mt m c in (ci ny ngy nay vn hay dng trong tr chi tm mt th). Da vo kiu ca php bin i trong h mt m c in, ngi ta chia h mt m lm 2 nhm: m thay th (substitution cipher) v m hon v (permutation/ transposition cipher).

Substitution: thay th phng php m ha trong tng k t (hoc tng nhm k t) ca vn bn ban u(bn r - Plaintext) c thay th bng mt (hay mt nhm) k t khc to ra bn m (Ciphertext). Bn nhn ch cn o ngc trnh t thay th trn Ciphertext c c Plaintext ban u. Mt v d v m thay th thun ty l m bng t in. Ngi lm cng tc mt m c mt quyn t in. m ha mt bn tin (dng vn bn), anh ta tm t hoc cm t ca bn tin trong t in v thay bng mt nhm ch s tng ng. N ging nh tra t in Vit-XXX, trong XXX l th ngn ng m ch bao gm cc ch s, ng thi cc t lun c di c nh (thng l 4-5 ch s). Sau khi dch t ting Vit sang ting XXX, ngi ta s cng tng t trong ca vn bn (trong ting XXX) vi kha theo module no . Kha cng l mt t ngu nhin trong ting XXX. Mt v d n gin na minh ha m thay th: cho mt vn bn ch gm cc k t latin, tm trong cc nguyn m (a,e,i,o,u) v bin i chng theo quy tc a thay bi e, e thay bi i,.... , u thay bi a. V d 2: Vit trn mt dng cc k t trong bng ch ci theo ng th t.Trn dng th hai, cng vit ra cc k t ca bn ch ci nhng khng bt u bng ch a m bng ch f chng hn. m ha mt k t ca bn r , hy tm n trn dng th nht , thay n bi k t nm trn dng th hai (ngay di n). Thay th n tr v thay th a tr l hai trng hp ring ca m thay th.Tr li vi v d v m t in, vi ngn ng XXX nu trn.Nu nh trong t in, 1 t Ting Vit tng ng vi 1 v ch 1 t ting XXX th l m thay th n tr.Cn nu mt t Ting Vit tng ng vi 2 hay nhiu hn 2 t trong ting XXX (tc l nhiu t trong ting XXX c cng mt ngha trong Ting Vit) th l m thay th a tr. Tuy khng cn c s dng nhng tng ca phng php ny vn c tip tc trong nhng thut ton hin i Transposition: hon v Bn cnh phng php m ho thay th th trong m ho c in c mt phng php khc na cng ni ting khng km, chnh l m ho hon v.

Nu nh trong phng php m ho thay th, cc k t trong Plaintext c thay th hon ton bng cc k t trong Ciphertext, th trong phng php m ho hon v, cc k t trong Plaintext vn c gi nguyn, chng ch c sp xp li v tr to ra Ciphertext. Tc l cc k t trong Plaintext hon ton khng b thay i bng k t khc. C th phng php hon v l phng php m ha trong cc k t trong vn bn ban u ch thay i v tr cho nhau cn bn thn cc k t khng h b bin i. V d n gin nht: m ha bn r bng cch o ngc th t cc k t ca n. Gi s bn r ca bn c di N k t. Bn s hon i v tr k t th 1 v k t N, k t 2 v k t N-1,Phc tp hn mt cht, hon v khng phi ton b bn r m chia nios ra cc on vi di L v thc hin php hon v theo tng on.Khi L s l kha ca bn! Mt khc L c th nhn gi tr tuyt i (2,3,4) hoc gi tr tng i (1/2,1/3,1/4ca N). Vo khong th k V-IV trc Cng nguyn, ngi ta ngh ra thit b m ha. l mt ng hnh tr vi bn hnh R. m ha, ngi ta qun bng giy (nh, di nh giy dng trong in tn) quanh ng hnh tr ny v vit ni dung cn m ha ln giy theo chiu dc ca ng. Sau khi g bng giy khi ng th ni dung s c che du. Muoons gii m th phi cun bng giy ln ng cng c bn knh R.Bn knh R chnh l kha trong h mt ny.1.4.2.Mt m hin i

a. Symmetric cryptography: m ha i xng, tc l c hai qu trnh m ha v gii m u dng mt cha kha. m bo tnh an ton, cha kha ny phi c gi b mt. V th cc thut ton loi ny cn c tn gi khc l secret key cryptography (hay private key cryptography), tc l thut ton m ha dng cha kha ring (hay b mt). Cc thut ton loi ny l tng cho mc ch m ha d liu ca c nhn hay t chc n l nhng bc l hn ch khi thng tin phi c chia s vi mt bn th hai.

Gi s nu Alice ch gi thng ip m ha cho Bob m khng h bo trc v thut ton s dng, Bob s chng hiu Alice mun ni g. V th bt buc Alice phi thng bo cho Bob v cha kha v thut ton s dng ti mt thi im no trc y. Alice c th lm iu ny mt cch trc tip (mt i mt) hay gin tip (gi qua email, tin nhn...). iu ny dn ti kh nng b ngi th ba xem trm cha kha v c th gii m c thng ip Alice m ha gi cho Bob.

Hnh 1.Thut ton m ha i xng Bob v Alice c cng mt kha KA-B. Kha ny c xy dng sao cho: m = KA-B(KA-B(m)). Trn thc t, i vi cc h mt i xng, kho K lun chu s bin i trc mi pha m ha v gii m. Kt qu ca s bin i ny pha gii m Kd s khc vi kt qu bin i pha m ha Ke.Nu coi Ke v Kd ln lt l kha m ha v kha gii m th s c kha gii m khng trng vi kha m ha. Tuy nhin nu bit c kha Ke th c th d dng tnh c Kd v ngc li. Vy nn c mt nh ngha rng hn cho m i xng l: M i xng l nhm m trong kha dng gii m Kd c th d dng tnh c t kha dng m ha Ke. Trong h thng m ho i xng, trc khi truyn d liu, 2 bn gi v nhn phi tho thun v kho dng chung cho qu trnh m ho v gii m. Sau , bn gi s m ho bn r (Plaintext) bng cch s dng kho b mt ny v gi thng ip m ho cho bn nhn. Bn nhn sau khi nhn c thng ip m ho s s dng chnh kho b mt m hai bn tho thun gii m v ly li bn r (Plaintext). Trong qu trnh tin hnh trao i thng tin gia bn gi v bn nhn thng qua vic s dng phng php m ho i xng, th thnh phn quan

trng nht cn phi c gi b mt chnh l kho. Vic trao i, tho thun v thut ton c s dng trong vic m ho c th tin hnh mt cch cng khai, nhng bc tho thun v kho trong vic m ho v gii m phi tin hnh b mt. Chng ta c th thy rng thut ton m ho i xng s rt c li khi c p dng trong cc c quan hay t chc n l. Nhng nu cn phi trao i thng tin vi mt bn th ba th vic m bo tnh b mt ca kho phi c t ln hng u. M ha i xng c th phn thnh hai nhm ph: - Block ciphers: thut ton khi trong tng khi d liu trong vn bn ban u c thay th bng mt khi d liu khc c cng di. di mi khi gi l block size, thng c tnh bng n v bit. V d thut ton 3-Way c kch thc khi bng 96 bit. Mt s thut ton khi thng dng l:DES, 3DES, RC5, RC6, 3-Way, CAST, Camelia, Blowfish, MARS, Serpent, Twofish, GOST...-

Stream ciphers: thut ton dng trong d liu u vo c m ha tng bit mt. Cc thut ton dng c tc nhanh hn cc thut ton khi, c dng khi khi lng d liu cn m ha cha c bit trc, v d trong kt ni khng dy. C th coi thut ton dng l thut ton khi vi kch thc mi khi l 1 bit. Mt s thut ton dng thng dng: RC4, A5/1, A5/2, Chameleon

b. Asymmetric cryptography: m ha bt i xng, s dng mt cp cha kha c lin quan vi nhau v mt ton hc, mt cha cng khai dng m ho (public key) v mt cha b mt dng gii m (private key). Mt thng ip sau khi c m ha bi cha cng khai s ch c th c gii m vi cha b mt tng ng. Do cc thut ton loi ny s dng mt cha kha cng khai (khng b mt) nn cn c tn gi khc l public-key cryptography (thut ton m ha dng cha kha cng khai). Mt s thut ton bt i xng thng dng l : RSA, Elliptic Curve, ElGamal, Diffie Hellman... Quay li vi Alice v Bob, nu Alice mun gi mt thng ip b mt ti Bob, c ta s tm cha cng khai ca Bob. Sau khi kim tra chc chn cha kha

chnh l ca Bob ch khng ca ai khc (thng qua chng ch in t digital certificate), Alice dng n m ha thng ip ca mnh v gi ti Bob. Khi Bob nhn c bc thng ip m ha anh ta s dng cha b mt ca mnh gii m n. Nu gii m thnh cng th bc thng ip ng l dnh cho Bob. Alice v Bob trong trng hp ny c th l hai ngi cha tng quen bit. Mt h thng nh vy cho php hai ngi thc hin c giao dch trong khi khng chia s trc mt thng tin b mt no c.

Hnh 2.Thut ton m ha bt i xng Trong v d trn ta thy kha public v kha private phi p ng v t kha public ngi ta khng th tm ra c kha private. M ho kho cng khai ra i gii quyt vn v qun l v phn phi kho ca cc phng php m ho i xng. Qu trnh truyn v s dng m ho kho cng khai c thc hin nh sau: - Bn gi yu cu cung cp hoc t tm kho cng khai ca bn nhn trn mt server chu trch nhim qun l kho. - Sau hai bn thng nht thut ton dng m ho d liu, bn gi s dng kho cng khai ca bn nhn cng vi thut ton thng nht m ho thng tin c gi i. - Khi nhn c thng tin m ho, bn nhn s dng kho b mt ca mnh gii m v ly ra thng tin ban u.

Vy l vi s ra i ca M ho cng khai th kho c qun l mt cch linh hot v hiu qu hn. Ngi s dng ch cn bo v Private key. Tuy nhin nhc im ca M ho kho cng khai nm tc thc hin, n chm hn rt nhiu so vi m ho i xng. Do , ngi ta thng kt hp hai h thng m ho kho i xng v cng khai li vi nhau v c gi l Hybrid Cryptosystems. Mt s thut ton m ho cng khai ni ting: Diffle-Hellman, RSA, Trn thc t h thng m ho kho cng khai c hn ch v tc chm nn cha th thay th h thng m ho kho b mt c, n t c s dng m ho d liu m thng dng m ho kho. H thng m ho kho lai ra i l s kt hp gia tc v tnh an ton ca hai h thng m ho trn. V vy ngi ta thng s dng mt h thng lai tp trong d liu c m ha bi mt thut ton i xng, ch c cha dng thc hin vic m ha ny mi c m ha bng thut ton bt i xng. Hay ni mt cch khc l ngi ta dng thut ton bt i xng chia s cha kha b mt ri sau dng thut ton i xng vi cha kha b mt trn truyn thng tin. Chng ta c th hnh dung c hot ng ca h thng m ho ny nh sau: - Bn gi to ra mt kho b mt dng m ho d liu. Kho ny cn c gi l Session Key. - Sau , Session Key ny li c m ho bng kho cng khai ca bn nhn d liu. - Tip theo d liu m ho cng vi Session Key m ho c gi i ti bn nhn. - Lc ny bn nhn dng kho ring gii m Session Key v c c Session Key ban u. - Dng Session Key sau khi gii m gii m d liu. Nh vy, h thng m ho kho lai tn dng tt c cc im mnh ca hai h thng m ho trn l: tc v tnh an ton. iu ny s lm hn ch bt kh nng gii m ca tin tc. Cn lu rng trn y, chng ta nhc n hai khi nim c tnh cht tng i l d v kh. Ngi ta quy c rng nu thut ton c phc tp

khng vt qu phc tp a thc th bi ton c coi l d; cn ln hn th bi ton c coi l kh.

Chng 2.H mt m c in2.1.H m Caesar H m Caesar c xc nh trn Z26 (do c 26 ch ci trn bng ch ci ting Anh) mc d c th xc nh n trn Zm vi modulus m ty .D dng thy rng , m dch vng s to nn mt h mt nh xc nh trn, tc l D k(Ek(x)) = x vi xZ26. nh ngha: Mt h mt gm b 5 (P,C,K,E,D). Gi s P = C = K = Z26 vi 0 k 25, nh ngha: Ek(x)=x+k mod 26 V Dk(x)=y-k mod 26 (x,y Z26) Nhn xt:Trong trng hp k=3, h mt thng c gi l m Caesar tng c Julius Caesar s dng Ta s s dng m dch vng (vi modulo 26) m ha mt vn bn ting Anh thng thng bng cch thit lp s tng ng gia cc k t v cc thng d theo modulo 26 nh sau: A0, B1,.,Z25. A 0 N 1 B 1 C 2 D 3 E 4 F 5 S 1 G H I 6 7 8 T 1 U 2 V 2 J 9 K 1 0 W X 2 2 L 1 1 Y 2 M 12 Z 25

O P 1 1

Q R 1 1

3

4

5

6

7

8

9

0

1

2

3

4

V d Gi s kha cho m dch vng k=11 v bn r l: wewillmeetatmidnight Trc tin bin i bn r thnh dy cc s nguyn nh dng php tng ng trn.Ta c: 22 4 22 8 11 11 12 4 4 19 0 19 12 8 3 13 8 6 7 19 Sau cng 11 vo mi gi tr ri rt gn tng theo modulo 26 7 11 15 4 7 23 19 19 22 14 22 24 23 19 15 17 15 18 4 4

Cui cng bin i dy s nguyn ny thnh cc k t thu c bn m sau HPHTWWXPPELEXTOYTRSE gi m bn m ny, trc tin, Bob s bin i bn m thnh dy cc s nguyn ri tr i gi tr cho 11 (rt gn modulo 26) v cui cng bin i li dy ny thnh cc k t

2.2.H m Affinne nh ngha: M tuyn tnh Affinne l b 5 (P,C,K,E,D) tha mn: 1.Cho P=C=Z26 v gi s P={(a,b) Z26 x Z26:UCLN(a,26)=1} 2.Vi k=(a,b) K, ta nh ngha: Ek(x)=ax+bmod26 V Dk(y)=a-1(y-b)mod26, x,yZ26 vic gii m thc hin c, yu cu cn thit l hm Affine phi l n nh.Ni cch khc, vi bt k yZ26, ta mun c ng nht thc sau: ax+b y(mod26) phi c nghim x duy nht.ng d thc ny tng ng vi ax y-b(mod 26)

v y thay i trn Z26 nn y-b cng thay i trn Z26.Bi vy, ta ch cn nghin cu phng trnh ng d: ax y(mod 26) (yZ26) ta bit rng phng trnh ny c mt nghim duy nht i vi mi y khi v ch khi UCLN(a,26)=1. Chng minh:Trc tin ta gi s rng, UCLN(a,26)=d>1. Khi , ng d thc ax 0(mod26) s c t nht hai nghim phn bit trong Z26 l x=0 v x=26/d. Trong trng hp ny, E(x)=ax+b(mod 26) khng pahir l mt hm n nh v bi vy n khng th l hm m ha hp l. V d do UCLN(4,26)=2 nn 4x+7 khng l hm m ha hp l: x v x+13 s m ha thnh cng mt gi tr i vi bt k xZ26. Ta gi thit UCLN(a,26)=1.Gi s vi x1 v x2 no tha mn: ax1 ax2(mod 26) Khi a(x1 x2) 0 (mod 26) bi vy 26| a(x1 x2) By gi ta s s dng mt tnh cht ca php chia sau: Nu UCLN(a,b)=1 v a | bc th a |c. V 26 | a(x1 x2) v UCLN(a,26)=1 nn ta c: 26 |(x1 x2) Tc l x1 x2 (mod 26) Ti y ta chng t rng, nu UCLN(a,26)=1 th mt ng d thc dng ax y (mod 26) ch c nhiu nht mt nghim trong Z26.D , nu ta cho x thay i trn Z26 th ax mod 26 s nhn c 26 gi tr khc nhau theo modulo 26 v ng d thc ax y(mod 26) ch c nghim duy nht. V d: Gi s k=(7,3).Ta c 7-1 mod 26= 15.Hm m ha l: Ek(x)=7x+3 V hm gii m tng ng l Dk(x)=15(y-3) mod 26=15y-19

y tt c cc php ton u thc hin trn Z26. Ta s kim tra liu Dk(Ek(x))=x vi xZ26 khng? Dng cc tnh ton trn Z26, ta c Dk(Ek(x))= Dk(7x+3) = 15(7x+3)-19 =x+45-19 =x minh ha, ta hy m ha bn r hot. Trc tin bin i cc ch h,o,t thnh cc thng d theo modulo 26. Ta c cc s tng ng l: 7, 14 v 19.By gi m ha: 7 7 +3 mod 26 = 52 mod 26 = 0 7 14 + 3 mod 26 = 101 mod 26 =23 7 19 +3 mod 26 = 136 mod 26 = 6 By gi 3 k t ca bn m l 0, 23 v 6 tng ng vi xu k t AXG. Gii m: t xu k t ca bn m chuyn thnh s nguyn trong bng ch ci ting Anh (26 ch ci), ta c cc s tng ng 0, 23, 6 Dk(0)=15 0- 19 mod 26 =7 Dk(23)=15 23- 19 mod 26 =14 Dk(6)=15 6- 19 mod 26 =19 By gi 3 k t ca bn r: h, o, t.

2.3.H m Vigenre Trong c hai h m dch chuyn v m tuyn tnh(mt khi kha c chn ) mi k t s c nh x vo mt k t duy nht. V l do , cc h mt cn li c gi l h thay th n biu. By gi ti s trnh by mt h mt khng phi l b ch n, l h m Vigenre ni ting. Mt m ny ly tn ca Blaise de Vigenre sng vo th k XVI. S dng php tng ng A 0, B 1, .,Z25 m t trn, ta c th gn cho mi kha k vi mt chui k t c di m c gi l t kha.Mt m V s m ha ng thi m k t: mi phn t ca bn r tng ng vi m k t V d

Gi s m=6 v t kha l CIPHER. T kha ny tng ng vi dy s k=(2,8,15,4,17).Gi s bn r l xu thiscryptosystemisnotsecure nh ngha: Cho m l mt s dng c nh no . Cho P=C=K=(Z26)m. Vi kha K=(k1, k2 , ,km) ta xc nh: EK(x1, x2, . . . ,xm) = (x1+k1, x2+k2, . . . , xm+km) v DK(y1, y2, . . . ,ym) = (y1-k1, y2-k2, . . . , ym-km) Trong tt c cc php ton c thc hin trong Z26 Ta s bin i cc phn t ca bn r thnh cc thng d theo modulo 26, vit chng thnh cc nhm 6 ri cng vi t kha theo modulo nh sau 19 7 8 18 2 17 24 15 19 14 18 24 2 8 15 7 4 17 2 8 15 7 4 17 21 18 2 20 15 19 8 1 23 4 15 19 25 12 7 19 6 8 4 12 8 18 17 9 0 13 2 15 23 14 8 22 8 19 15 8 21 18 7 15 22 4 4 8 15 2 17 19

20 2

17 8

4 15

22 25 19 Bi vy, dy k t tng ng ca xu bn m s l: VPXZGIAXIVWPUBTTMJPWIZITWZT gii m ta c th dng cng t kha nhng thay cho cng, ta tr n theo modulo 26

Ta thy rng cc t kha c th vi s di m trong mt m Vigenre l 26 , bi vy, thm ch vi cc gi tr m kh nh, phng php tm kim vt cn cng yu cu thi gian kh ln. V d, nu m=5 th khn gian kha cng c kchm

thc ln hn 1,1 107. Lng kha ny ln ngn nga vic tm kha bng tay Trong h mt Vigenre c t kha di m, mi k t c th c nh x vo trong m k t c th c (gi s rng t kha cha m k t phn bit).Mt h mt nh vy c gi l h mt thay th a kiu (poly alphabetic). Ni chung, vic thm m h thay th a kiu s kh khn hn so vic thm m h n kiu.

2.4.H mt Hill Trong phn ny s m t mt h mt thay th a kiu khc c gi l mt m Hill. Mt m ny do Lester S.Hill a ra nm 1929. Gi s m l mt s nguyn, t P = C = (Z26)m . tng y l ly t hp tuyn tnh ca m k t trong mt phn t ca bn r to ra m k t mt phn t ca bn m. nh ngha: Mt m Hill l b 5(P, C, K, E, D). Cho m l mt s nguyn dng c nh. Cho P = C = (Z26)m v cho K={cc ma trn kh nghch cp m m trn Z26} Vi mt kha K K ta xc nh EK(x) = xK v DK(y) = yK -1 tt c cc php ton c thc hin trong Z26 V d Gi s kha

T cc tnh ton trn ta c

Gi s cn m ha bn r July. Ta c hai phn t ca bn r m ha:(9,20) (ng vi Ju) v (11,24)(ng vi ly). Ta tnh nh sau:

V

Bi vy bn m ca july l DELW. gii m Bob s tnh

V

Nh vy Bob nhn c bn ng Cho ti lc ny ta ch ra rng c th thc hin php gii m nu K c mt nghch o. Trn thc t, php gii m l c th thc hin c, iu kin cn l K phi c nghch o. (iu ny d dng rt ra t i s tuyn tnh s cp).

2.5. H mt Playfair Php thay th n-gram:thay v thay th i vi cc k t, ngi ta c th thay th cho tng cm 2 k t (gi l digram) hoc cho tng cm 3 k t (gi l trigram) v tng qut cho tng cm n k t (gi l n-gram). Nu bng ch ci gm 26 k t ting Anh th php thay th n-gram s c kho l mt hon v ca 26n n-gram khc nhau. Trong trng hp digram th hon v gm 262 digram v c th biu din tt nht bng mt dy 2 chiu 26 26 trong cc hng biu din k hiu u tin, cc ct biu din k hiu th hai, ni dung ca cc biu din chui thay th. V d bng 2 chiu sau biu th AA c thay bng EG, AB c thay bng RS, BA c thay bng BO, BB c thay bng SC, A B A EG RS B BO SC

y l mt s da trn s thay th digram trong kho l mt hnh vung kch thc 5 5 cha mt s sp xp no ca 25 k t ca bng ch ci (khng tnh k t J v s xut hin t ca n v c th thay n bng I). Gi s chng ta c ma trn kho nh sau B Y D G Z W S F U P L A R K X C O I V E Q N M H T S thay th s c thc hin nh sau. Chng hn nu digram cn thay th l AV th trong hnh ch nht c A, V l hai nh cho nhau thay A bng nh k ca n theo ng thng ng chnh l O v tng t thay V bng nh k ca n theo ng thng ng chnh l K. Tng t nu digram cn thay th l VN th chui thay th l HO. Nu cc k t ca digram nm trn hng ngang th chui thay th l cc k t bn phi ca chng. Chng hn nu digram l WU th chui thay th l SP, nu digram l FP th chui thay th l UW, nu digram l XR th chui thay th l LK. Tng t nu cc k t ca digram nm trn hng dc th chui thay th l cc k t bn di ca chng. Chng hn nu digram l SO th chui thay th l AN, nu digram l MR th chui thay th l DI, nu digram l GH th chui thay th l UG. Trong trng hp digram l mt cp k t ging nhau chng hn OO hoc l mt k t c i km mt khong trng chng hn B th c nhiu cch x l, cch n gin nht l gi nguyn khng bin i digram ny.

Chng 3. Mt s cng c h tr cho thuyt mt m3.1.L thuyt s3.1.1.Kin thc ng d thc

a. nh ngha: Cho l s nguyn dng. Hai s nguyn d vi nhau theo module m nu hiu a

v c gi l ng khng chia ht

K hiu a b(mod m) c gi l mt ng d thc. Nu cho , ta vit V d 3 -1 (mod 4) 5 17 (mod 6) 18 0 (mod 6) iu kin a 0(mod m) ngha l a b. Tnh cht v cc h qu Tnh cht 1: Vi mi s nguyn , ta c: a a (mod m) Tnh cht 2: a b (mod m) b a (mod m) Tnh cht 3 a b (mod m), b c (mod m) a c (mod m) Chng minh:

a b (mod m) m | (a - b) b c(mod m) m | (b- c v a c = (a b) + (b c ) m | (a - c Tnh cht 4 Chng minh:

Tnh cht 5 Chng minh: Theo tnh cht 4 ta c:

Nhn tng v hai T ta c:

Nhn xt: 1, Nu a 1(mod 2) v b 1(mod 2) th a + b 2(mod 2), v 2 0 (mod 2) suy ra: a + b 0(mod 2), cn a.b 1(mod 2) iu ny c ngha : Tng ca hai s l l mt s chn; Tch ca hai s l l mt s l 2,Nu a 3(mod 7) a2 9 (mod 7) 2(mod 7) C ngha: Nu mt s chia cho 7 d 3 th bnh phng s chia 7 d 2. Cc h qu ca tnh cht 4 v 5:

3. Ch :

, vi

1_Chia 2 hn :

hai

v

cho mt ng thc, ni chung l khng c. nhng nhng ab c th ng d vi 0 theo module m. Chng nhng 2.5=10 0(mod 10)

3.1.2.Mt s nh l s dng trong thut m ha cng khai

a.Thut gii Euclid- Tm UCLN ca hai s nguyn Gii thut Euclid hay thut ton Euclid, l mt gii thut gip tnh c s chung ln nht (SCLN) ca hai s mt cch hiu qu. Gii thut ny c bit n t khong nm 300 trc Cng Nguyn. Nh ton hc Hy Lp c Euclid vit gii thut ny trong cun sch ton ni ting Elements. Gi s a = bq + r, vi a, b, q, r l cc s nguyn, ta c:

Gii thut Input: hai s nguyn khng m a v b, b>0 Output: UCLN ca a, b. (1) While b 0 do r= a mod b, a= b, b=r (2) Return (a) b.Gii thut Euclid m rng Gii thut Euclid m rng s dng gii phng trnh v nh nguyn (cn c gi l phng trnh i--phng) a*x+b*y=c, trong a, b,c l cc h s nguyn, x, y l cc n nhn gi tr nguyn. iu kin cn v phng trnh ny c nghim (nguyn) l UCLN(a,b) l c ca c. Khng nh ny da trn mt mnh sau: Trong s hc bit rng nu d=UCLN(a,b) th tn ti cc s nguyn x, y sao cho

a*x+b*y = d Gii thut Input: hai s nguyn khng m a v b , a>b Output: d= UCLN(a,b) v cc s nguyn x v y tha mn ax + by = d (1) Nu b = 0 th t d =a, y = 0, v return (d,x,y) (2) Khai bo 5 bin trung gian x1, x2, y1, y2 v q (3) t x2 = 1, x1 = 0, y2 = 0, y1 = 1 (4) While b > 0 do (4.1) q = [a/b], r = a qb, x = x2 qx1, y = y2 qy1 (4.2) a = b, b = r, x2 = x1 , x1 = x, y2 = y1, y1 = y (5) t d = a, x = x2, y = y2 v return (d,x,y). nh gi phc tp: Thut ton Euclid m rng c phc tp v thi gian l O((lg n)2). V d: Xt v d vi a=4864 v b=3458. q r x y a b x2 x1 y2 y1 4864 3458 1 0 0 1 1 1406 1 -1 3458 1406 0 1 1 -1 2 646 -2 3 1406 646 1 -2 -1 3 2 114 5 -7 646 114 -2 5 3 -7 5 76 -27 38 114 76 5 -27 -7 38 1 38 32 -45 76 38 -27 32 38 -45 2 0 -91 128 38 0 32 -91 45 128 ng dng thut ton Euclid m rng tm phn t nghch o Thut ton Euclid m rng c s dng rt thng xuyn trong mt m vi kha cng khai tm phn t nghch o. Xt mt trng hp ring khi vn dng thut ton Euclid m rng: Cho hai s nguyn dng nguyn t cng nhau a, n: n>a, (a,n)=1. Cn tm s nguyn dng b nh nht sao cho ab 1 (mod n). S b nh th c gi l "nghch o" ca a theo module n (v ngc li, a l "nghch o" ca b theo module n). p dng thut ton Euclid m rng cho cp s (n,a) ta tm c b 3 s (d,x,y) tha mn d=(n,a) v nx+ay=d. Bi v a v n nguyn t cng nhau nn d=1

v nx+ay=1. V nx lun chia ht cho n nn t ng thc cui cng ta suy ra c ay 1 (mod n). i chiu vi yu cu ca bi ton, ta c b = y + zn. Trong z l s nguyn nh nht tha mn b > 0. Dng rt gn ca thut ton Euclid m rng. Bi v bi tan tm "phn t nghch o" l trng hp ring ca thut ton Euclid m rng, li c dng rt thng xuyn trong mt m vi kha cng khai nn ngi ta xy dng thut ton n gin hn gii bi ton ny. Thut ton c th hin bng di y: I 1 2 3 ... K ... ? I 1 2 3 4 5 Bc 1: 1. u := 0; 2. v := n; (v d: n=23) 3. Chuyn n bc 2 Bc 2: 1. u := 1; 2. v := a; (v d: a=5) 3. Nu v=1 th chuyn n bc 5. 4. q = n/a ui 0 1 u1-q2.u2 ... uk-2-qk-1.uk-1 ... y ui 0 1 -4 5 -9 vi n a v1-q2.v2 ... vk-2-qk-1.vk-1 ... 1 vi 23 5 3 2 1 qi [n/a] [v2/v3] ... [vk-1/vk] ... qi 4 1 1

5. Chuyn n bc 3 Bc 3:1. uk := uk-2-qk-1.uk-1; 2. vk := vk-2-qk-1.vk-1; 3. Nu vk=1 th chuyn n bc 5. 4. qk := [vk-1/vk];

5. Chuyn n bc 4 Bc 4: Tr li bc 3. Bc 5: n y ta thu c gi tr v = y. S b cn tm c xc nh bi b = y + zn. Trong , z l s nguyn nh nht tha mn b > 0. v d trn y, i vi n=23 v a=5 ta tm c y = -9 nn b = 14 (vi z=1). c.nh l phn d Trung Hoa nh l phn d Trung Hoa, hay bi ton Hn Tn im binh, l mt nh l ni v nghim ca h phng trnh ng d bc nht. Ni dung Cho tp cc s nguyn t cng nhau tng i mt :m1, m2, , mk. Vi mi b s nguyn bt k a1, a2, , ak. H phng trnh ng d:

Lun c nghim duy nht theo moun M = m1.m2...mk l:

trong M1 = M / m1, M2 = M / m2,..., Mk = M / mk y1 = (M1) 1(mod m1), y2 = (M2) 1(mod m2),..., yk = (Mk) 1(mod mk)

d.Thut gii Rabin Miller (1980) Cho n 3 l, thut ton sau y xc nh rng n l mt hp s hoc in ra thng bao sn l s nguyn t(1) Write n 1 = 2k m, where m is old (2) Chose a random integer, 1 a n 1 (3) Compute b = am mod n (4) If b=1 (mod n) then anwer n is prime and quit (5) For i =0 to k 1 do

If b = -1 (mod n) then anwer n is prime and quit else b = b2 (mod n)(6) Anwser n is composite

f. Thut gii tnh xp mod m Cho x Zm v mt s nguyn p N* c biu din nh phn p = pi2i(i = 0, 1). Vic tnh gi tr y = xp mod m c gi l php ly tha mod Input: x Zm, p = pi2i(i = 0, 1) Output: y = xp mod m(1) y = 1 (2) for i = 1 downto 0 do

y = y2 mod m if pi = 1 then y = (y*x) mod m(3) return y

g. nh l Ferma Nu p l mt s nguyn t cn a l mt s nguyn th ap a(mod p). Nu p khng chia ht cho a (tc l a(mod p) 0) th a p-1 1(mod p)(nh l Ferma nh ) D nhn thy rng nh l Fermat nh l trng hp ring ca nh l Euler khi n l s nguyn t. h. nh l Euler nh ngha hm Euler: Cho n l mt s nguyn dng. Hm Euler ca n c k hiu l (n) v c xc nh bi cng sut ca tp hp M cc s nguyn dng nh hn n v nguyn t cng nhau vi n. Gii thch:

Cho trc s nguyn dng n Xc nh tp hp M (di vi s n cho): s x thuc tp hp M khi v ch khi tha mn cc iu kin sau: 1. x N 2. 0 < x < n 3. (x,n) = 1 Hm Euler ca n c gi tr bng s phn t ca tp hp M: (n) = #M

Quy tc tnh gi tr ca hm Euler: 1. (p) = p 1, nu p l s nguyn t; 2. (pi) = (pi 1), trong pi l cc s nguyn t khc nhau; 3. (piki) = (pi(pi 1)ki), trong pi l cc s nguyn t khc nhau; 4. (mn) = (m)(n), nu (m,n)=1. nh l Euler:Cho a v n l 2 s nguyn dng, nguyn t cng nhau: (a,n)=1. nh l Euler khng nh: a(n) 1 (mod n), trong (n) l hm Euler ca n.

3.2.L thuyt phc tp Mt chng trnh my tnh thng c ci t da trn mt thut ton ng gii quyt bi ton hay vn . Tuy nhin, ngay c khi thut ton ng, chng trnh vn c th khng s dng c i vi mt d liu u vo no v thi gian cho ra kt qu l qu lu hoc s dng qu nhiu b nh (vt qu kh nng p ng ca my tnh). Khi tin hnh phn tch thut ton ngha l chng ta tm ra mt nh gi v thi gian v "khng gian" cn thit thc hin thut ton. Khng gian y c hiu l cc yu cu v b nh, thit b lu tr, ... ca my tnh thut ton c th lm vic. Vic xem xt v khng gian ca thut ton ph thuc phn ln vo cch t chc d liu ca thut ton. Trong phn ny, khi ni n phc tp ca thut ton, chng ta ch cp n nhng nh gi v mt thi gian m thi. Phn tch thut ton l mt cng vic rt kh khn, i hi phi c nhng hiu bit su sc v thut ton v nhiu kin thc ton hc khc. y l cng vic m khng phi bt c ngi no cng lm c. Rt may mn l cc nh ton hc phn tch cho chng ta phc tp ca hu ht cc thut ton c s (sp xp, tm kim, cc thut ton s hc, ...). Chnh v vy, nhim v cn li ca chng ta l hiu c cc khi nim lin quan n phc tp ca thut ton. nh gi v thi gian ca thut ton khng phi l xc nh thi gian tuyt i (chy thut ton mt bao nhiu giy, bao nhiu pht,...) thc hin thut ton m l xc nh mi lin quan gia d liu u vo (input) ca thut ton v chi ph (s thao tc, s php tnh cng,tr, nhn, chia, rt cn,...) thc hin thut ton. S d ngi ta khng quan tm n thi gian tuyt i ca thut ton v yu t ny ph thuc vo tc ca my tnh, m cc my tnh khc nhau th c tc rt khc nhau. Mt cch tng qut, chi ph thc hin thut ton l mt hm s ph thuc vo d liu u vo : T = f(input)

Tuy vy, khi phn tch thut ton, ngi ta thng ch ch n mi lin quan gia ln ca d liu u vo v chi ph. Trong cc thut ton, ln ca d liu u vo thng c th hin bng mt con s nguyn n. Chng hn : sp xp n con s nguyn, tm con s ln nht trong n s, tnh im trung bnh ca n hc sinh, ... Lc ny, ngi ta th hin chi ph thc hin thut ton bng mt hm s ph thuc vo n : T = f(n) Vic xy dng mt hm T tng qut nh trn trong mi trng hp ca thut ton l mt vic rt kh khn, nhiu lc khng th thc hin c. Chnh v vy m ngi ta ch xy dng hm T cho mt s trng hp ng ch nht ca thut ton, thng l trng hp tt nht v xu nht. nh gi trng hp tt nht v xu nht ngi ta da vo nh ngha sau: Cho hai hm f v g c min xc nh trong tp s t nhin . Ta vit f(n) = O(g(n)) v ni f(n) c cp cao nht l g(n) khi tn ti hng s C v k sao cho | f(n) | C.g(n) vi mi n > k Tuy chi ph ca thut ton trong trng hp tt nht v xu nht c th ni ln nhiu iu nhng vn cha a ra c mt hnh dung tt nht v phc tp ca thut ton. c th hnh dung chnh xc v phc tp ca thut ton, ta xt n mt yu t khc l tng ca chi ph khi ln n ca d liu u vo tng. Mt cch tng qut, nu hm chi ph ca thut ton (xt trong mt trng hp no ) b chn bi O(f(n)) th ta ni rng thut ton c phc tp l O(f(n)) trong trng hp . Nh vy, thut ton tm s ln nht c phc tp trong trng hp tt nht v xu nht u l O(n). Ngi ta gi cc thut ton c phc tp O(n) l cc thut ton c phc tp tuyn tnh.

Sau y l mt s "thc o" phc tp ca thut ton c s dng rng ri. Cc phc tp c sp xp theo th t tng dn. Ngha l mt bi ton c phc tp O(nk) s phc tp hn bi ton c phc tp O(n) hoc O(logn).

Chng 4. H mt m cng khai4.1.Gii thiu mt m vi kha cng khai4.1.1.Lch s

Mt m ha kha cng khai l mt dng mt m ha cho php ngi s dng trao i cc thng tin mt m khng cn phi trao i cc kha chung b mt trc . iu ny c thc hin bng cch s dng mt cp kha c quan h ton hc vi nhau l kha cng khai v kha c nhn (hay kha b mt). Thut ng mt m ha kha bt i xng thng c dng ng ngha vi mt m ha kha cng khai mc d hai khi nim khng hon ton tng ng. C nhng thut ton mt m kha bt i xng khng c tnh cht kha cng khai v b mt nh cp trn m c hai kha (cho m ha v gii m) u cn phi gi b mt. Trong mt m ha kha cng khai, kha c nhn phi c gi b mt trong khi kha cng khai c ph bin cng khai. Trong 2 kha, mt dng m ha v kha cn li dng gii m. iu quan trng i vi h thng l khng th tm ra kha b mt nu ch bit kha cng khai. H thng mt m ha kha cng khai c th s dng vi cc mc ch:

M ha: gi b mt thng tin v ch c ngi c kha b mt mi gii m c. To ch k s: cho php kim tra mt vn bn c phi c to vi mt kha b mt no hay khng. Tha thun kha: cho php thit lp kha dng trao i thng tin mt gia 2 bn.

Thng thng, cc k thut mt m ha kha cng khai i hi khi lng tnh ton nhiu hn cc k thut m ha kha i xng nhng nhng li im m chng mang li khin cho chng c p dng trong nhiu ng dng.

Trong hu ht lch s mt m hc, kha dng trong cc qu trnh m ha v gii m phi c gi b mt v cn c trao i bng mt phng php an ton khc (khng dng mt m) nh gp nhau trc tip hay thng qua mt ngi a th tin cy. V vy qu trnh phn phi kha trong thc t gp rt nhiu kh khn, c bit l khi s lng ngi s dng rt ln. Mt m ha kha cng khai gii quyt c vn ny v n cho php ngi dng gi thng tin mt trn ng truyn khng an ton m khng cn tha thun kha t trc. Nm 1874, William Stanley Jevons xut bn mt cun sch m t mi quan h gia cc hm mt chiu vi mt m hc ng thi i su vo bi ton phn tch ra tha s nguyn t (s dng trong thut ton RSA). Thng 7 nm 1996, mt nh nghin cu bnh lun v cun sch trn nh sau: Trong cun The Principles of Science: A Treatise on Logic and Scientific Method c xut bn nm 1890, William S. Jevons pht hin nhiu php ton rt d thc hin theo mt chiu nhng rt kh theo chiu ngc li. Mt v d chng t m ha rt d dng trong khi gii m th khng. Vn trong phn ni trn chng 7 (Gii thiu v php tnh ngc) tc gi cp n nguyn l: ta c th d dng nhn cc s t nhin nhng phn tch kt qu ra tha s nguyn t th khng h n gin. y chnh l nguyn tc c bn ca thut ton mt m ha kha cng khai RSA mc d tc gi khng phi l ngi pht minh ra mt m ha kha cng khai. Thut ton mt m ha kha cng khai c thit k u tin bi James H. Ellis, Clifford Cocks, v Malcolm Williamson ti GCHQ (Anh) vo u thp k 1970. Thut ton sau ny c pht trin v bit n di tn Diffie-Hellman, v l mt trng hp c bit ca RSA. Tuy nhin nhng thng tin ny ch c tit l vo nm 1997. Nm 1976, Whitfield Diffie v Martin Hellman cng b mt h thng mt m ha kha bt i xng trong nu ra phng php trao i kha cng khai. Cng trnh ny chu s nh hng t xut bn trc ca Ralph Merkle v phn phi kha cng khai. Trao i kha Diffie-Hellman l phng php c th p

dng trn thc t u tin phn phi kha b mt thng qua mt knh thng tin khng an ton. K thut tha thun kha ca Merkle c tn l h thng cu Merkle. Thut ton u tin cng c Rivest, Shamir v Adleman tm ra vo nm 1977 ti MIT. Cng trnh ny c cng b vo nm 1978 v thut ton c t tn l RSA. RSA s dng php ton tnh hm m mun (mun c tnh bng tch s ca 2 s nguyn t ln) m ha v gii m cng nh to [ch k s]. An ton ca thut ton c m bo vi iu kin l khng tn ti k thut hiu qu phn tch mt s rt ln thnh tha s nguyn t. K t thp k 1970, c rt nhiu thut ton m ha, to ch k s, tha thun kha.. c pht trin. Cc thut ton nh ElGamal (mt m) do Netscape pht trin hay DSA do NSA v NIST cng da trn cc bi ton lgarit ri rc tng t nh RSA. Vo gia thp k 1980, Neal Koblitz bt u cho mt dng thut ton mi: mt m ng cong elliptic v cng to ra nhiu thut ton tng t. Mc d c s ton hc ca dng thut ton ny phc tp hn nhng li gip lm gim khi lng tnh ton c bit khi kha c di ln.4.1.2.L thuyt mt m cng khai

Khi nim v mt m kha cng khai to ra s c gng gii quyt hai vn kh khn nht trong mt m kha quy c, l s phn b kha v ch k s: Trong m quy c s phn b kha yu cu hoc l hai ngi truyn thng cng tham gia mt kha m bng cch no c phn b ti h hoc s dng chung mt trung tm phn b kha. - Nu vic s dng mt m tr nn ph bin, khng ch trong qun i m cn trong thng mi v nhng mc ch c nhn th nhng on tin v ti liu in t s cn nhng ch k tng ng s dng trong cc ti liu giy. Tc l, mt phng php c th c ngh ra c quy nh lm hi lng tt c nhng ngi tham gia khi m mt on tin s c gi bi mt c nhn c bit hay khng-

Trong s m ha quy c, cc kha c dng cho m ha v gii m mt on tin l ging nhau. y l mt iu kin khng cn thit, n c th pht trin gii thut m ha da trn mt kha cho m ha v mt kha khc cho gii m Cc bc cn thit trong qu trnh m ha cng khai-

Mi h thng cui trong mng to ra mt cp kha dng cho m ha v gii m on tin m n s nhn Mi h thng cng b rng ri kha m ha bng cch t kha vo mt thanh ghi hay mt file cng khai, kha cn li c gi ring Nu A mun gi mt on tin ti B th A m ha on tin bng kha cng khai ca B Khi B nhn on tin m ha, n c th gii m bng kha b mt ca mnh. Khng mt ngi no khc c th gii m oan tin ny bi v ch c mnh B bit kha b mt thi .

Vic cc tip cn ny, tt c nhng ngi tham gia c th truy xut kha cng khai. Kha b mt c to bi tng c nhn, v vy khng bao gi c phn b. bt k thi im no, h thng cng c th chuyn i cp kha m bo tnh b mt. Bng sau tm tt mt s kha cnh quan trng v m ha quy c v m ha cng khai : phn bit c hai loi chng ta tng qut ha lin h kha s dng trong m ha quy c l kha b mt, hai kha s dng trong m ha cng khai l kha cng khai v kha b mt. M ha quy c * Yu cu M ha cng khai * Yu cu

- Thut gii tng t cho m ha v - Mt thut gii cho m ha v mt gii m. thut gii cho gii m - Ngi gi v ngi nhn phi tham - Ngi gi v ngi nhn, mi

gia cng thut gii v cng kha * Tnh bo mt - Kha phi c b mt

ngi phi c cp kha ring ca mnh * Tnh bo mt

- Mt trong hai kha phi c gi - Khng th hay t nht khng c tnh b mt thc t gii m on tin nu thng tin khc c sn - Khng th hay t nht khng c tnh thc t gii m on tn nu thng - Kin thc v thut gii cng vi tin khc khng c sn cc mu v mt m khng xc nh kha - Kin thc v thut gii cng vi mt trong cc kha, cng vi cc mu v mt m khng xc nh kha4.1.3.Nhng yu im, hn ch ca mt m vi kha cng khai

Tn ti kh nng mt ngi no c th tm ra c kha b mt. Khng ging vi h thng mt m s dng mt ln (one-time pad) hoc tng ng, cha c thut ton m ha kha bt i xng no c chng minh l an ton trc cc tn cng da trn bn cht ton hc ca thut ton. Kh nng mt mi quan h no gia 2 kha hay im yu ca thut ton dn ti cho php gii m khng cn ti kha hay ch cn kha m ha vn cha c loi tr. An ton ca cc thut ton ny u da trn cc c lng v khi lng tnh ton gii cc bi ton gn vi chng. Cc c lng ny li lun thay i ty thuc kh nng ca my tnh v cc pht hin ton hc mi. Mc d vy, an ton ca cc thut ton mt m ha kha cng khai cng tng i m bo. Nu thi gian ph mt m (bng phng php duyt ton b) c c lng l 1000 nm th thut ton ny hon ton c th dng m ha cc thng tin v th tn dng - R rng l thi gian ph m ln hn nhiu ln thi gian tn ti ca th (vi nm).

Nhiu im yu ca mt s thut ton mt m ha kha bt i xng c tm ra trong qu kh. Thut ton ng gi ba l l mt v d. N ch c xem l khng an ton khi mt dng tn cng khng lng trc b pht hin. Gn y, mt s dng tn cng n gin ha vic tm kha gii m da trn vic o c chnh xc thi gian m mt h thng phn cng thc hin m ha. V vy, vic s dng m ha kha bt i xng khng th m bo an ton tuyt i. y l mt lnh vc ang c tch cc nghin cu tm ra nhng dng tn cng mi. Mt im yu tim tng trong vic s dng kha bt i xng l kh nng b tn cng dng k tn cng ng gia (man in the middle attack): k tn cng li dng vic phn phi kha cng khai thay i kha cng khai. Sau khi gi mo c kha cng khai, k tn cng ng gia 2 bn nhn cc gi tin, gii m ri li m ha vi kha ng v gi n ni nhn trnh b pht hin. Dng tn cng kiu ny c th phng nga bng cc phng php trao i kha an ton nhm m bo nhn thc ngi gi v ton vn thng tin. Mt iu cn lu l khi cc chnh ph quan tm n dng tn cng ny: h c th thuyt phc (hay bt buc) nh cung cp chng thc s xc nhn mt kha gi mo v c th c cc thng tin m ha.4.1.4.ng dng ca mt m

a.Bo mt ng dng r rng nht ca mt m ha kha cng khai l bo mt: mt vn bn c m ha bng kha cng khai ca mt ngi s dng th ch c th gii m vi kha b mt ca ngi . Phn mm PGP min ph ch c s dng cho ngi dng c nhn vi mc ch phi thng mi, c th ti v ti a ch : http://www.pgp.com/products/freeware.html b.Chng thc

Cc thut ton to ch k s kha cng khai c th dng nhn thc. Mt ngi s dng c th m ha vn bn vi kha b mt ca mnh. Nu mt ngi khc c th gii m vi kha cng khai ca ngi gi th c th tin rng vn bn thc s xut pht t ngi gn vi kha cng khai . Dng ch k s cho email v m ha email khi gi i thng qua nh cung cp chng ch s lm trng ti iu khin Nh chng ch s ca nh cung cp Thawte(www.thawte.com) cho php bn c th ng k cho mnh mt ti khon Personal Email Certificate haonf ton min ph ti y thc hin giao dch khi gi v nhn mail (http://www.thawte.com/secure-email/personal-email-certificates/index.htm) c.ng dng trong thng mi in t Nhiu n v, t chc Vit Nam ang xy dng mng my tnh c quy m ln phc v cho cng vic kinh doanh ca mnh: mng chng khon, mng ngn hng, mng bn v tu xe, k khai v np thu qua mng. Cng ty phn mm v Truyn thng VASC chnh thc k kt hp ng ng dng chng ch s trong giao dch ngn hng in t vi ngn hng c phn thng mi Chu (ACB) t ngy 30/9/2003, cho php khch hng ACB s giao dch trc tuyn trn mng vi ch k in t do VASC cp. Mng giao dch chng khon VCBS (http://www.vebs.vn) : m ti khon ngn hng cho php giao dch trc tip qua sn, bo gi c phiu, cho php t lnh mua bn c phn ch bng thao tc click chut. Mng ngn hng VCB, EAB (http://www.vietcombank.com.vn, http://ebanking.dongabank.com.vn) cho php xem s d, chuyn khon cho ti khon khc cng h thng t 20-500 triu ng mi ngy, bn k chi tit gaio dch ca ti khon trn Internet.

H thng bn v qua mng ca ngnh hng khng (http://www.pacificairline.com.vn), ng st (http://www.vr.com.vn) trin khai 1/2007, mua bn trc tuyn (http://www.ebay.vn). Chi cc thu thnh ph H Ch Minh (http://www.hcmtax.gov.vn) ang th nghim cho php doanh nghip ng k t in ha n theo mu, t k khai bo co thu, khu tr thu qua mng Nu nh c c mt c ch bo mt tt, m bo xc thc r rng gia cc bn tham gia vo h thng th chc chn rng nhng vn lin quan n mng my tnh nu trn ch cn l vn thi gian. 4.2.H mt RSA Trong mt m hc, RSA l mt thut ton mt m ha kha cng khai. y l thut ton u tin ph hp vi vic to ra ch k in t ng thi vi vic m ha. N nh du mt s tin b vt bc ca lnh vc mt m hc trong vic s dng kha cng cng. RSA ang c s dng ph bin trong thng mi in t v c cho l m bo an ton vi iu kin di kha ln.4.2.1.Lch s

Thut ton c Ron Rivest, Adi Shamir v Len Adleman m t ln u tin vo nm 1977 ti Hc vin Cng ngh Massachusetts (MIT). Tn ca thut ton ly t 3 ch ci u ca tn 3 tc gi. Trc , vo nm 1973, Clifford Cocks, mt nh ton hc ngi Anh lm vic ti GCHQ, m t mt thut ton tng t. Vi kh nng tnh ton ti thi im th thut ton ny khng kh thi v cha bao gi c thc nghim. Tuy nhin, pht minh ny ch c cng b vo nm 1997 v c xp vo loi tuyt mt. Thut ton RSA c MIT ng k bng sng ch ti Hoa K vo nm 1983 (S ng k 4,405,829). Bng sng ch ny ht hn vo ngy 21 thng 9 nm 2000. Tuy nhin, do thut ton c cng b trc khi c ng k bo h nn s bo h hu nh khng c gi tr bn ngoi Hoa K. Ngoi ra, nu nh cng trnh ca

Clifford Cocks c cng b trc th bng sng ch RSA khng th c ng k.4.2.2.M t thut ton

Thut ton RSA c hai kha: kha cng khai (hay kha cng cng) v kha b mt (hay kha c nhn). Mi kha l nhng s c nh s dng trong qu trnh m ha v gii m. Kha cng khai c cng b rng ri cho mi ngi v c dng m ha. Nhng thng tin c m ha bng kha cng khai ch c th c gii m bng kha b mt tng ng. Ni cch khc, mi ngi u c th m ha nhng ch c ngi bit kha c nhn (b mt) mi c th gii m c. Ta c th m phng trc quan mt h mt m kho cng khai nh sau : Bob mun gi cho Alice mt thng tin mt m Bob mun duy nht Alice c th c c. lm c iu ny, Alice gi cho Bob mt chic hp c kha m sn v gi li cha kha. Bob nhn chic hp, cho vo mt t giy vit th bnh thng v kha li (nh loi kho thng thng ch cn sp cht li, sau khi sp cht kha ngay c Bob cng khng th m li c-khng c li hay sa thng tin trong th c na). Sau Bob gi chic hp li cho Alice. Alice m hp vi cha kha ca mnh v c thng tin trong th. Trong v d ny, chic hp vi kha m ng vai tr kha cng khai, chic cha kha chnh l kha b mt. a. To kha Gi s Alice v Bob cn trao i thng tin b mt thng qua mt knh khng an ton (v d nh Internet). Vi thut ton RSA, Alice u tin cn to ra cho mnh cp kha gm kha cng khai v kha b mt theo cc bc sau:1. Chn 2 s nguyn t ln p v q vi pq, la chn ngu nhin v c lp. 2. Tnh: n= pq 3. Tnh: gi tr hm s le (n)= (p-1)(q-1). 4. Chn mt s t nhin e sao cho 1< e