You are on page 1of 9

MT S PHNG PHP M HA D LIU

1. M u
Ngy nay trong mi hot ng ca con ngi thng tin ng mt vai tr quan
trng khng th thiu. X hi cng pht trin nhu cu trao i thng tin gia cc
thnh phn trong x hi ngy cng ln. Mng my tnh ra i mang li cho con
ngi rt nhiu li ch trong vic trao i v x l thng tin mt cch nhanh chng v
chnh xc. Chnh t nhng thun li ny t ra cho chng ta mt cu hi, liu
thng tin i t ni gi n ni nhn c m bo tuyt i an ton, ai c th m bm
thng tin ca ta khng b truy cp bt hp php. Thng tin c lu gi, truyn dn,
cng s dng trn mng li thng tin cng cng c th b nghe trm, chim ot,
xuyn tc hoc ph hu dn n s tn tht khng th lng c. c bit l i vi
nhng s liu ca h thng ngn hng, h thng thng mi, c quan qun l ca
chnh ph hoc thuc lnh vc qun s c lu gi v truyn dn trn mng. Nu
nh v nhn t an ton m thng tin khng dm a ln mng th hiu sut lm vic
cng nh hiu sut li dng ngun d liu u s b nh hng. Trc cc yu cu
cn thit , vic m ho thng tin s m bo an ton cho thng tin ti ni lu tr
cng nh khi thng tin c truyn trn mng.
2. Khi nim c bn v mt m hc
K thut mt m thng qua vic bin i hoc m ho thng tin, bin i nhng
thng tin nhy cm, vn c mt thnh nhng vn t m ho c dng hn lon, lm
cho bn tin tc kh lng m c hiu c, t s t c hai mc ch: mt l,
lm cho bn tin tc khng bit lm th no gii m nn cng khng th thu c
nhng thng tin c bt k ngha no trong chui mt m hn lon ; hai l lm cho
tin tc khng c kh nng lm gi thng tin vi chui mt m hn lon nh th.
Khoa hc nghin cu k thut mt m gi l mt m hc.
Mt m hc bao gm hai nhnh, l mt m hc lp m v mt m hc phn tch.
Mt m hc lp m vi l tin hnh m ho thng tin thc hin vic che giu
thng tin, cn mt m hc phn tch l ngnh hc nghin cu phn tch gii dch mt
m. Hai ci i lp vi nhau, nhng li thc y ln nhau.
Dng phng php mt m c th che du v bo h nhng thng tin c mt, lm
cho ngi cha c u quyn khng th ly c thng tin, nhng thng tin c
giu kn kia c gi l vn bn r, mt m c th em vn bn r bin i thnh mt
loi hnh khc, gi l vn bn mt. S bin i vn bn r thnh vn bn mt gi l
m ho bo mt, qu trnh ngi thu nhn hp php khi phc t vn bn mt tr
thnh vn bn r c gi l qu trnh gii m (hoc gii mt). Ngi thu nhn phi
php c phn tch t vn bn mt ra thnh vn bn r, gi l gii dch.
3. Cc thnh phn ca mt h mt m
Mt h mt l mt b 5 (P, C, K, E, D) tho mn cc iu kin sau:
+ P l mt tp hu hn cc bn r c th
+ C l tp hu hn cc bn m c th
+ K (khng gian kho) l tp hu hn cc kho c th

+ i vi mi kK c mt quy tc m ek: P -> C v mt quy tc gii m


tng ng dkD. Mi ek: P -> C v dk: C -> P l nhng hm m: dk(ek(x)) = x
vi mi bn r xP.
Tnh cht 4 l tnh cht ch yu. Ni dung ca n l nu mt bn r x c m
ho bng ek v bn m nhn c sau c gii m bng d k th ta phi thu c
bn r ban u x. Trong trng hp ny hm m ho e k phi l hm n nh, nu
khng vic gii m s khng th thc hin c mt cch tng minh.
4. Phn loi cc h mt m
Hin nay ngi ta thit k ra nhiu loi h thng mt m, nu nh ly kho
mt m lm tiu chun c th phn cc h mt m thnh hai loi:
- H mt m i xng (cn gi l mt m kho n hoc l mt m kho ring):
Trong cc h mt m ny, kho mt m m ho bo mt ging vi kho gii m hoc
trn thc t l cng ng cp. Lc ny kho mt m cn phi c mt ng truyn an
ton truyn a kho mt m t pha ngi truyn cho pha ngi nhn. c im
ca mt m i xng l bt lun khi gia cng bo mt hay l khi gii m u s dng
cng mt kho mt m. Do tnh an ton ca mt m ny l s an ton ca kho
mt m. nu nh kho mt m b tit l, th h thng mt m ny s b ph v. Mt
m i xng c nh hng nht l php tnh DES do cc tiu chun quc gia M
cng b vo nm 1977.
u im: Tnh an ton cao, tc gii m nhanh.
Nhc im:
+ Theo s m rng ca quy m mng li, vic qun l kho mt m tr
thnh mt vic kh khn.
+ Khng c cch no gii quyt vn xc nhn thng tin.
+ Thiu nng lc kim tra t ng s tit l kho mt m.
- H mt m bt i xng (cn gi l mt m kho cng khai hoc mt m kho
i): Trong cc h mt m ny qu trnh m ho v gii m c cha kho khc nhau,
lc ny khng cn c ng truyn an ton truyn a kho mt m m ch cn b
pht sinh kho m ti ch to ra kho gii m ng thi ly khng ch cc
thao tc gii m. Mt m bt i xng l mt th ch mt m loi mi do W.Diffie v
M.E Hellman xut nm 1976. Do qu trnh m ho v gii m ca th ch mt m
bt i xng khng nh nhau v kho m bo mt l cng khai, hn na, ch yu cu
bo mt kho gii m, cho nn mt m bt i xng khng tn ti vn qun l
kho mt m. Mt m bt i xng cn mt u im na l c th c kh nng k tn
ch s v mt s chc nng mi. Mt m bt i xng ni ting nht l th ch mt
m RSA do ba ngi l Rivest, Shamir v Adleman xut nm 1977. Khuyt im
ca mt m bt i xng l: php tnh mt m l tng i phc tp, tc gii m
chm.
Do , vic bo mt d liu trn mng nn dng c ch bo mt hn hp kt
hp gia mt m i xng v mt m bt i xng, tc l khi gii m th dng mt
m i xng, khi truyn a kho mt m th dng mt m bt i xng. Nh th tc
l gii quyt c kh khn trong vic qun l kho mt m, va li gii quyt
c vn tc gii m. Khng cn hoi nghi g na, n l mt phng php

tng i tt gii quyt vn an ton thng tin khi truyn a trn mng hin
nay.
5. Mt s phng php m ha
5.1. M ha c in
M ho c in l phng php m ho n gin nht xut hin u tin trong
lch s ngnh m ho. Thut ton n gin v d hiu. Nhng phng php m ho
ny l c s cho vic nghin cu v pht trin thut ton m ho i xng c s
dng ngy nay.
Trc khi m ho mt bn r thnh bn m bng cc phng php m ho, ta xt
mt s mt thit lp tng ng gia cc k t v cc thng d theo modulo 26 nh
sau: A0, B1, , Z25 hoc:
A B
0 1

C
2

D E
3 4

F
5

G H I
6 7 8

J
9

K L M N O P Q R S T U V W X Y Z
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

a) Mt m CAESAR
Mt trong s nhng ngi s dng mt m c bit sm nht, l julias caesar
(x-da). ng lm cho cc bc th tr nn b mt bng cch dch mi ch ci i ba
ch ci v pha trc trong bng ch ci ( v ba ch ci cui cng thnh ba ch ci
u tin). y l 1 v d v s m ho, tc l qu trnh lm cho bc th tr nn b
mt.
Phng php m ho ca CAESAR c th c biu din bi hm f, hm ny gn
cho s nguyn khng m p, p 25, s nguyn f(p) trong tp 0, 1, 2, , 25 sao
cho: f(p)=(p+3) mod 26.
Nh vy, trong phin bn m ho ca bc th, ch ci c biu din bi p s
c thay bng ch ci c biu din bi: (p+3) mod 26
V d: dng mt m ca CAESAR chuyn bc th meet you in the park thnh
bc th b mt.
Trc ht, thay cc ch ci trong bc th gc thnh cc s, ta c:
12 4 4 19 24 14 20 8 13 19 7 4 15 0 17 10
by gi thay cc s p bng f(p)=(p+3) mod 26, ta c:
15 7 7 22 1 17 23 11 16 22 10 7 18 3 20 13
dch tr li cc ch ci, ta c bc th m ho l:
PHHW BRX LQ WKH SDUN
phc hi li bc th gc c m ho theo mt m ca CAESAR, ta cn
phi dng hm ngc f -1 ca f: f -1(p)=(p-3) mod 26 . Ni cch khc, tm li bc
th gc, mi mt ch ci li li ba ch trong bng ch ci, vi ba ch ci u tin
chuyn thnh ba ch ci cui cng tng ng ca bng ch ci.

Nhn xt: phng php m ho ca CAESAR khng c an ton cao. Phng


php m ho ny d b khm ph bng cch da vo tn xut xut hin ca cc ch
ci trong bc th.

b) M thay th
M thay th c th c m t nh sau:
Cho P = C = Z26 . K cha mi hon v c th ca 26 k hiu 0, 1, ,25. vi mi
hon v K, ta nh ngha.
e(x) = (x)

d(y) = -1(y)
trong -1 l hon v ngc ca
V d: m ho bn r: illustrate s dng m thay th vi kho l 1 hon v bt k
sau:

Vi kho l mt hon v bt k trn th bn r: illustrate s tng ng vi bn


m sau (s dng hm m ho e(x) = (x)): ZBBUVMCXMH
Hm gii m l php hon v ngc, iu ny c thc hin bng cch vit hng
th hai ln trc ri sp xp theo th t ch ci. Ta nhn c:

S dng php hon v ngc ny ta bin i bn m: ZBBUVMCXMH thnh bn


r nh sau: illustrate
Nhn xt: vi m thay th, ta c mt khng gian kho tng i ln (mi kho l
mt hon v ca 26 k hiu 0, 1, , 25) do n kh c th b thm theo phng
php tm kha vt cn, thm ch c bng my tnh.
c) M vigenre
S dng m vigenre, ta c th gn cho mi kho k mt chui k t c di m
c gi l t kho. Mt m vigenre s m ho ng thi m k t: mi phn t ca
bn r tng ng vi m k t.
M vigenre c th c m t nh sau:

Cho m l mt s nguyn dng c nh no . nh ngha P=C=K=(Z)m vi kho


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
V d: m ho bn r: thiscryptosystemisnotsecure vi m=6 v t kho l
CIPHER bng m vigenre.
T kha CIPHER tng ng vi dy s k=(2, 18, 15, 7, 4, 17)
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 kho theo modulo 26 nh sau:

Dy k t: 21, 15, 23, 25, 6, 8, 0, 23, 8, 21, 22, 15, 20, 1, 19, 19, 12, 9, 15, 22, 8,
25, 8, 19, 22, 25, 19. S tng ng vi xu bn m l:
VPXZGIAXIVWPUBTTMJPWIZITWZT
gii m ta bin i cc phn t ca bn m thnh cc thng d theo modulo
26, vit chng thnh cc nhm 6 ri tr vi t kho theo modulo 26. kt qu ta s ra
c bn r nh sau: thiscryptosystemisnotsecure
Nhn xt: ta thy rng s cc t kho c th vi s di m trong mt m
vigenre l 26m , bi vy, n kh c th b thm theo phng php tm kho vt cn,
thm ch vi cc gi tr m kh nh, phng php tm kho vt cn cng phi yu cu
thi gian kh ln.
d) M hon v
tng ca m hon v l gi cc k t ca bn r khng thay i nhng s thay
i v tr ca chng bng cch sp xp li cc k t ny.
M hon v c th c m t nh sau:
Cho m l mt s nguyn dng xc nh no . Cho P=C=(Z 26)m v K gm tt c
cc hon v ca 1, , m. i vi mt kho (tc l mt hon v) ta xc nh.
e(x1, , xm)=(x(1), , x(m)) v
d(y1, , ym)=(y(1) , , y(m) )
trong -1 l hon v ngc ca
V d: m ho bn r: shesellsseashellsbytheseashore, s dng m hon v, vi
m=6 v kho l php hon v sau:

Trc tin ta nhm bn r thnh cc nhm 6 k t:


shesel / lsseas / hellsb / ythese / ashore
By gi mi nhm 6 ch ci c sp xp li theo hon v , ta c:
EESLSH / SALSES / LSHBLE / HSYEET / HRAEOS
Nh vy bn m l: EESLSHSALSESLSHBLEHSYEETHRAEOS
gii m ta s dng php hon v ngc ca l -1 c dng:

Ta cng nhm bn m thnh nhm 6 k t:


EESLSH / SALSES / LSHBLE / HSYEET / HRAEOS
Mi nhm 6 ch ci c sp xp li theo hon v ngc -1 ta c:
shesel / lsseas / hellsb / ythese / ashore
Cui cng ta thu c bn r l: shesellsseashellsbytheseashore
e) DES (Data Encryption Standard)
Lc m ho c s dng ph bin nht da trn c s ca DES c pht
trin vo nm 1977 bi cc tiu chun quc gia M, by gi l hc vin tiu chun v
cng ngh quc gia (NIST), chun x l thng tin lin bang. i vi DES, d liu
c m ho trong khi 64 bit s dng kho 56 bit. Thut ton chuyn 64 bit u
vo, bin i v a ra 64 bit u ra.
DES c s dng ph bin. N cng l ch ca rt nhiu cuc tranh lun v
mc an ton. hiu r gi tr ca nhng cuc tranh lun v DES chng ta xem
qua li lch s ca DES.
Cui nhng nm 1960, IBM a ra d n nghin cu trong bo mt my tnh.
D n kt thc vo nm 1971 vi vic cho ra i thut ton gi l LUCIFER, h mt
LUCIFER c s dng trong h thng phn pht tin, cng c pht trin bi
IBM. LUCIFER l mt khi m ho Feistel c thc hin trn khi 64 bit, s dng
kho c di 128 bit. Nhng kt qu y ha hn a ra bi d n LUCIFER, IBM
bt tay vo cng vic y n lc pht trin thnh mt sn phm m ho thng
mi c th bn c, l mt sn phm l tng c th thc hin c trn mt
chp n. Cng u phi k n Walter Tuchman v Carl Meyer, n khng ch lm
rc ri cho nhng nh thit k m cn cn phi c nhng li khuyn ca nhng nh
k thut v t vn bn ngoi l NSA. Kt qu ca n lc ny l mt phin bn
LUCIFER c chn lc k lng, phin bn ny c th chng li cc phng php
gii dch, nhng n cng lm gim di kho xung cn 56 bit, ph hp trn
mt chip n.
Nm 1973 cc tiu chun quc gia M (NBS) a ra mt yu cu ngh cho
mt chun m ho quc t. IBM a ra xem xt nhng kt qu ca d n
Tuchman-Meyer. Kt qu n c ngh l thut ton tt nht v c cng nhn
vo nm 1977 nh l mt chun m ho d liu.
Trc khi c cng nhn nh l mt chun m ho d liu, DES tr thnh
ch ca nhiu cuc ph bnh mnh m, v s ph bnh ny vn cha lng xung
cho n ngy hm nay. C hai mt c a ra lm ni gin nhng nh ph bnh.

u tin, chiu di kho ca thut ton LUCIFER nguyn thu ca IBM l 128 bit
nhng h thng c ngh ch dng 56 bit, mt s gim rt ln trong di kho
72 bit. Nhng nh ph bnh lo s rng (v vn s) chiu di kho qu nh chng
li nhng cuc tn cng quy m ln. Mt th 2 cn quan tm l tiu chun thit k
cho cu trc bn trong ca DES, nhng hp S phi c coi l mt. Nh vy, nhng
ngi s dng khng th chc chn rng cu trc bn trong ca DES l t do cho bt
k nhng im yu c che du, iu ny s cho php NSA hng ti nhng thng
bo gii m khng c li cho kho. Nhng s kin xy ra sau, c bit gn y lm
vic trn nhng s gii dch khc nhau, dng nh ch r rng DES c mt cu trc
bn trong rt mnh.
5.2. Thut ton m ha cng khai
a) H mt RSA
tng v mt h mt kho cng khai c Diffie v Hellman a ra vo
1976. Cn vic hin thc ha h mt kho cng khai th do Rivest, Shamir v
Adleman a ra u tin vo 1977, h to nn h mt RSA ni ting.
H mt ny s dng cc tnh ton trong Z n , trong n l tch ca 2 s nguyn t
phn bit p v q. Ta c th m t h mt RSA nh sau:
Cho n=p.q trong p v q l cc s nguyn t. t P=C=Zn v nh ngha:
K=(n,p,q,a,b):n=pq, p,q l cc s nguyn t, ab1(mod (n))
Vi K =(n,p,q,a,b) ta xc nh
ek(x)=xb mod n
dk(y)=ya mod n
(x,y Zn) cc gi tr n v b c cng khai v cc gi tr p, q,a c gi kn,
(n)=(p-1)(q-1)
Qu trnh thc hin h mt RSA: (ngi gi:Alice; ngi nhn:Bob)
+ Bob to hai s nguyn t ln p v q
+ Bob tnh n=pq v (n)=(p-1)(q-1)
+ Bob chn mt s ngu nhin b (0<b<(n)) sao cho UCLN(b, (n))=1
+ Bob tnh a=b-1 mod (n) bng cch dng thut ton Euclide
+ Bob cng b n v b trong mt danh b v dng chng lm kho cng khai.
V d: gi s Bob chn p=101 v q=113
Khi n=11413 v (n)=100x112=11200. v 11200=26527, nn c th dng mt
s nguyn b nh mt s m m ho khi v ch khi b khng chia ht cho 2,5 hoc 7.(v
th trong thc t Bob s khng phn tch (n)), anh ta s kim tra iu kin
UCLN((n),b)=1 bng thut ton Euclide. Gi s Bob chn b=3533, khi theo thut
ton Euclide m rng: b-1=6597 mod 11200. Bi vy, s m mt gii m cho Bob
l a=6597. Bob s cng b n=11413 v b=3533 trong mt danh b. by gi, gi s
Alice mun gi bn r 9726 ti Bob. C ta s tnh
97263533 mod 11413=5761 ri gi bn m 5761 trn knh. Khi Bob nhn c bn
m 5761, anh ta s dng s m a mt tnh: 57616597 mod 11414=9726.
Vi h mt RSA c trnh by trn ta thy cch tn cng d thy nht i vi
h mt ny l thm m c gng phn tch n ra cc tha s nguyn t. Nu thc hin

c php phn tch ny th c th d dng tnh c (n)=(p-1)(q-1) v ri tnh s


m a v b ng nh Bob lm.V th h RSA c coi l mt th nht thit n=pq
phi l mt s ln vic phn tch n s khng c kh nng v mt tnh ton.
b) H mt Elgamal
H mt Elgamal l mt h mt m cng khai da trn bi ton logarithm ri rc.
N l mt h mt khng tt nh v bn m ph thuc vo c bn r x ln gi tr ngu
nhin k do ngi gi chn. Bi vy s c nhiu bn m c m t cng bn r.
Bi ton logarithm ri rc trong Zp:
c trng ca bi ton: I = (p,,) trong p l s nguyn t Zp l phn t
nguyn thu, Zp*
Mc tiu: hy tm mt s nguyn duy nht a, 0 a p-2 sao cho
a (mod p)
Ta s xc nh s nguyn a bng log.
H mt kho cng khai Elgamal trong Zp*:
Cho p l s nguyn t sao cho bi ton logarithm ri rc trong Z p l kh gii. cho
Zp* l phn t nguyn thu. Gi s P=Zp*, C= Zp* x Zp*. Ta nh ngha:
K=(p, ,a, ): a (mod p)
Cc gi tr p, , c cng khai, cn a gi kn
Vi K=(p, ,a, ) v mt s ngu nhin b mt k Zp-1 ta xc nh:
ek(x,k)=(y1,y2)
Trong
y1 = k mod p
y2 = xk mod p
Vi y1, y2 Zp* ta xc nh:
dk(y1,y2) = y2(y1a)-1 mod p
V d:
Cho p=2579, =2, a=765. Khi =2765 mod 2579 = 949
By gi gi s ngi gi mun gi thng bo x=1299 ti ngi nhn. Gi s s
ngu nhin k m ngi gi chn l k=853. Sau ngi gi tnh:
y1 = 2853 mod 2579 = 435
y2 = 1299 x 949853 mod 2579 = 2396
Khi ngi nhn thu c bn m y = (435, 2396), ngi nhn tnh
x = 2396 x (435765)-1 mod 2579 = 1299
y chnh l bn r m ngi gi m ho.
6. Nhn xt v cc thut ton m ha
nh gi mt thut ton m ho cn da vo cc yu t nh phc tp, thi
gian m ho v vn phn phi kho trong mi trng nhiu ngi dng.
M ha i xng

Cc thut ton m ho kho i xng thng n gin d ci t, tc m ho


cao nhng an ton khng cao do d b l kho. Kho d b i phng s dng
cc h thng c thit k c bit chuyn ph kho theo hnh thc bit t hin,
trong h thng thc hin th tt c cc kho. Nh th, cho chui t hin x v chui
m tng ng y, mi kho s c th tm kho k tho e K(x)=y. M DES l mt v
d in hnh vi khng gian kho l 2 56 DES khng an ton mc cao. Mc
d c nhng ch trch v an ton, DES vn c p dng rng ri (ch yu l cc
ng dng ngn hng), l do DES c ci t d dng trn c phn cng cng nh
phn mm, v DES ch s dng mt php ton c bn l php XOR.
M ho cng khai
Cc thut ton m ho kho cng khai khc phc c tnh trng d b l kho
ca thut ton m ho kho i xng. Tuy nhin chi ph ci t cao, tc m ho li
rt chm.
RSA l thut ton in hnh ca mt m ho cng khai, n cho an ton cao v
vi n ln th vic phn tch n =pq l kh c th thc hin c. Khi p dng vo
trong thc t nn s dng cc s p v q c kch c vo khong 100 ch s n c
kch c khong 200 ch s, bi v hin nay cc thut ton c th phn tch mt s c
130 ch s.
Khoa CNTT
Th.s. Nguyn Nguyn Ngc

Ti liu tham kho


1. L thuyt m
Nguyn Thy Vn, NXB khoa hc v k thut
2. Mt m hc l thuyt v thc hnh
Nguyn Bnh, Vin k thut thng tin-1996
2. Cryptography and network security
William Stallings