4
This presentation is the property of its rightful owner.
Sponsored Links
1 / 111

第4章 公钥密码 PowerPoint PPT Presentation


  • 115 Views
  • Uploaded on
  • Presentation posted in: General

第4章 公钥密码. 学习要求: 公钥密码体制的基本概念 RSA 算法 椭圆曲线密码体制. 4.1 数论简介 4.1.1 素数和互素数. Prime & coprime. 2.整数分解 称整数 p(p>1) 是素数,如果 p 的因子只有±1,± p。 任一整数 a(a>1) 都能惟一地分解为以下形式: 其中 p 1 >p 2 >…p t 是素数, a i >0(i=1,…,t)。 例如 91=7×1 3 ,11011=7×11 2 ×13. 3. 互素数 称 c 是两个整数 a、b 的最大公因子,如果

Download Presentation

第4章 公钥密码

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


4

4

RSA


4 1 4 1 1

4.1 4.1.1

Prime & coprime


2 p p 1 p 1 p a a 1 p 1 p 2 p t a i 0 i 1 t 91 7 1 3 11011 7 11 2 13

2.

p(p>1)p1p

a(a>1)

p1>p2>ptai>0(i=1,,t)

91=71311011=711213


3 c a b c a b c a b a b c c gcd a b a b c gcd a b

3.

cab

cab cab

abc

c=gcd(a, b)

? a,bc=gcd(a, b)


4 1 2

4.1.2

nanaqr

a=qn+r,0r<n,

xx

a mod nr

(a mod n)=(b mod n)abnab mod nana[a]a

a0(mod n)n|a


4 1 21

4.1.2

n|(a-b)ab mod n

(a mod n)(b mod n)ab mod n

ab mod n,ba mod n

ab mod n,bc mod n,ac mod n


4

a mod na{0,1, ,n-1}

[(a mod n)+(b mod n)] mod n=(a+b) mod n

[(a mod n)-(b mod n)] mod n=(a-b) mod n

[(a mod n)(b mod n)] mod n=(ab) mod n


4

4.1 Z8={0,1,,7}Z84.1774.1

xyx+y0 mod 8262+60 mod 8yx

xyxy1 mod 8331 mod 8yx

x


4

ZnnZn={0,1, ,n-1}Znn

(w+x) mod n=(x+w) mod n

(wx) mod n=(xw) mod n

[(w+x)+y] mod n=[w+(x+y)] mod n

[(wx)y] mod n=[w(xy)] mod n


4

[w(x+y)] mod n=[wx+wy] mod n

(0+w) mod n=w mod n

(1w) mod n=w mod n

wZnzZnw+z0 mod nz=-w


A b a c mod n b c mod n a b a c mod n a

(a+b)(a+c) mod nbc mod n

(a+b)(a+c) mod na


6 3 6 7 2 mod 8 3 7 mod 8 a b a c mod n b c mod n

63672 mod 837 mod 8

(a b)(a c) mod nbc mod n


4

4.1 aZngcd(a, n)=1aZn

aZnbcc<b|aZn|=|Zn|aZn ZnaZn=Zn1ZnxZnax1 mod nxax=a-1

abac mod nk1,k2ab=k1n+rac=k2n+ra(b-c)=(k1-k2)na(k1-k2)ngcd(an)=1ak1-k2k1-k2=k3aa(b-c)=k3anb-c=k3n0<c<b<n


P zp 0 p a b a c mod n a a b a c mod n a 1 b c mod n

pZp0p

(ab)(ac) mod na(ab)(ac) mod na-1bc mod n


4 1 3

4.1.3

(Fermat) (Euler)


1 4 2 fermat p a gcd a p 1 a p 1 1 mod p 4 1

1.

4.2 (Fermat)pagcd(a, p)=1ap-11 mod p

4.1


2 n n n n n 4 3 n p q n p q p 1 q 1 n

2.

nnnn(n)

4.3 npq(n)=(p)(q)=(p-1)(q-1)

n


3 4 4 euler a n a n 1 mod n r zn n a r r

3.

4.4Euler ana(n)1 mod n

RZnn

aR=R


4 1 4

4.1.4

p2x21(mod p)x1x-1

x21 mod px2-10 mod p(x+1)(x-1)0 mod pp|(x+1)p|(x-1) p|(x+1)p|(x-1)

x-1(mod p) x1(mod p)


X 2 1 mod p x 0 1 1 p

x21 mod px0{-1,1}p


4 1 5

4.1.5

EuclidEuclid


1 euclid a b gcd a b gcd b a mod b a b b a mod b

1.

Euclid

abgcd(a, b)=gcd(b, a mod b)

abba mod b


2 gcd a b 1 b mod a b a x x a bx 1 mod a euclid gcd a b gcd a b 1 b

2.

gcd(a, b)=1 bmod ab<ax (x<a)bx1 mod aEuclidgcd(a, b)gcd(a, b)=1b


4 1 6

4.1.6

Z102510x25[0][3]x mod 20x mod 53538x


4 5 m 1 m 2 m k m ei

4.5 m1,m2,,mk

M:

ei


M x a 1 a 2 a k

Mx(a1,a2,,ak)


4

4.4 x

M=2357=210M1=105M2=70M3=42M4=30,e1M-11 mod 21,e2M-12mod 31,e3M-13 mod 53,e4M-14 mod 74,

x (10511+7012+4233+3045) 173 (mod 210) x173 mod 210


4 5 973 mod 1813 37 49 x 973 m 1813 m1 37 m2 49 a1 973 mod m1 11 a2 973 mod m3 42 x 37 49 11 42

4.5 973 mod 18133749

x=973, M=1813, m1=37,m2=49

a1973 mod m111,a2973 mod m342x374911,42


4

1

2


4

1

x1615xx2x4x8x164

amam

mbk bk-1b0

m=bk2k+bk-12k-1++b12+b0


23 1 2 4 0 2 3 1 2 2 1 2 1 1 2 0 a 23

23=124+023+122+121+120

a23 = ?


A m d 1 for i k downto 0 do d d d mod n if b i 1 then d d a mod n return d

(a,m)

d=1

For i=k Downto 0

DO {

d=(dd) mod n;

if bi=1 then {

d=(da) mod n

}

}

return d.


4

7560mod 561

5601 0 0 0 1 1 0 0 0 0

(1 2 4 8 17 35 70 140 280 560

( 7 49 157 526 67 1)

7560mod 561=1


4

1

Witness(a,n)

for i=k downto 0 do

{

xd;

d(dd) mod n;

if d=1 and(x1)and(xn-1)then return False;

if bi=1 then d(da) mod n

}

if d1 then return False;

return True.


1 witness a n true

1

Witness(a,n) true


2 euclid f d 1 x f y d 2 if y 0 then return x gcd f d 3 r x mod y 4 x y 5 y r 6 goto 2

2

Euclidf, d //

1. Xf; Yd

2. if Y=0 then return X=gcd(f,d)

3. R=X mod Y

4. X=Y

5. Y=R

6. goto 2


4

2

Extended Euclid(f, d) f >d

1. (X1,X2,X3)(1,0,f);(Y1,Y2,Y3)(0,1,d);

2. if Y3=0 then return X3=gcd(f, d)no inverse;

3. if Y3=1 then return Y3=gcd(f, d)Y2=d-1 mod f;

4. Q=INT[X3/Y3]

5. (T1,T2,T3)(X1-QY1,X2-QY2,X3-QY3);

6. (X1,X2,X3)(Y1,Y2,Y3);

7. (Y1,Y2,Y3)(T1,T2,T3);

8. goto 2


2 extended euclid f d 13 29

2

Extended Euclid(f, d)1329


4 1 7

4.1.7

1.

Eulergcd(a, n)=1a(n)1 mod n:

am1 mod n

anmm=(n)mna


4

a=7n=19717 mod 19,7211 mod 19,731 mod 197193

73+j=737j7j mod 19,

747 mod 19,

7572 mod 19,

74mod 193


4 6 a m a k 1 mod n k m

4.6 amak1 mod nkm


4

am(n)

am(n)anan

a,a2,,a(n)

mod nn

ap

a,a2,,ap-1

mod p

?


N 9 n 6 2 mod 9 2 1 mod 9 2 2 2 mod 9 4 2 3 mod 9 8 2 4 mod 9 7 2 5 mod 9 5 2 6 mod 9 1 2 9 2 9

n=9(n)=62mod 921mod 92,22 mod 94

23 mod 98,24 mod 9725 mod 95,26 mod 912(9)29


N 19 a 3 mod 19 3 9 8 5 15 7 2 6 18 16 10 11 14 4 12 17 13 1 3 18 19 3 19

n=19a=3mod 19

398515726181610111441217131

318=(19)319


4

2.

y=ax(a>0,a1)axy=logax loga1=0,logaa=1,logaxy=logax+logay,logaxy=ylogax

papa,a2,,ap-11p-1b{1,,p-1}i(1ip-1)bai mod pipabi=inda,p(b)


Ind a p 1 0 ind a p a 1 a 0 mod p 1 mod p 1 a 1 mod p a p

inda,p(1)=0

inda,p(a)=1

a0 mod p=1 mod p=1,

a1 mod p=a

p


4 6 p 9 p 6 a 2 p a 9 2 0 1 2 1 2 2 2 4 2 3 8 2 4 7 2 5 5 2 6 1

4.6 p=9(p)=6a=2pa9

201,212,224,238,247,255,261


4

3.

papa1,a2,,ap-1 mod p1p-1b{1,,p-1}i{1,,p-1}bai mod pipabilogab(mod p)

apibabpi

p


4

Fermat ap-1 = 1 mod p gcd(a,p)=1

Euler a(n) = 1 mod n gcd(a,n)=1

DLP(Discrete Logarithms Problem): i=logab(mod p)

a Zp


4

4.2


4


4

5


1976 w diffie m hellman

1976W.DiffieM.Hellman


4 2 1

4.2.1


4

4.1


4

BPKBSKBPKBSKB

BPKBSKB

ABmBmc=EPKB[m],cE

BcSKBm=DSKB[c]D


4

BSKBc

Am4.2ASKAm

c=ESKA[m]

cBBAPKAc

m=DPKA[c]


4

4.2


M c a sk a a c a m a sk a m

mcASKAAcAmASKAm


4

4.3


4

4.3


Sk a m pk b 2 c e pkb e ska m m d pka d skb c

SKAmPKB2

c=EPKB[ESKA[m]]

m=DPKA[DSKB[c]]

,


4 2 2

4.2.2

:

BPKBSKB

Amc

c=EPKB[m]

Bcm=DSKB[c]


4

BPKBSKB

cBPKBm

EPKB[DSKB(m)]=DSKB[EPKB(m)]


4

XYYyxXxyyx

nnaaPn2n


4

fk

Y=fk(X)kX

X=f-1k(Y)kY

X=f-1k(Y)Yk


4 3 rsa

4.3 RSA

RSA1978R.Rivest, A.ShamirL.Adleman


4 3 1

4.3.1

1.

pq

n=pq(n)=(p-1)(q-1),(n)n

e1<e<(n)gcd((n),e)=1

dde1 mod (n),de(n)e(n)

{e,n},{d,n}


2 n log 2 n m c m e mod n

2.

nlog2nm cme mod n


3 m c d mod n rsa

3.

mcd mod n

RSA


4

RSA

HI

(1)

p=5,q=11

n=55, (n)=40

e=3()

d=27 (mod 40)()


4

(2)

=00,A=01,B=02, ,Z=26

HI=0809

C1=(08)3=512 17 (mod 55)

C2=(09)3=729 14 (mod 55)

N=14,Q=17

QN


4

(3)

M1=Cd=(17)27 08 (mod 55)

M2=Cd=(14)27 09 (mod 55)

HI


4

RSA

RSA{e=3,d=7},

4


4 3 2 rsa

4.3.2 RSA

1. RSA

RSA6677mod 1196677

(ab) mod n=[(a mod n)(b mod n)] mod n


4

x1615xx2x4x8x164

amam

mbk bk-1b0

m=bk2k+bk-12k-1++b12+b0


23 1 2 4 0 2 3 1 2 2 1 2 1 1 2 0 a 231

23=124+023+122+121+120

a23 = ?


A m d 1 for i k downto 0 do d d d mod n if b i 1 then d d a mod n return d1

(a,m)

d=1

For i=k Downto 0

DO {

d=(dd) mod n;

if bi=1 then {

d=(da) mod n

}

}

return d.


4

7560mod 561

5601 0 0 0 1 1 0 0 0 0

(1 2 4 8 17 35 70 140 280 560

( 7 49 157 526 67 1)

7560mod 561=1


4

2. RSA

pqed

n=pqpqpq10100n10200664102002664838DES88RSA


Miller rabin

(Miller-Rabin)


4 3 3 rsa

4.3.3 RSA

RSANPRSAnpq(n)=(p-1)(q-1)e(n)dde-1 mod (n)


Rsa 129 n 129 428 8 1994 4 rsa 130 1996 4

RSA-129n129428819944RSA-130 19964


4

RSA-129RSA-130RSA130RSA-12910%RSA10242048RSA


4

RSA{e=3,d=7},

4


4

4.6

4.3RSAECCelliptic curve cryptographyECCIEEEP1363


4 6 0

4.6.0


4 6 1

4.6.1

y2+axy+by=x3+cx2+dx+e (4.1)

abcdeO4.4


4

4.4


4

x

3O

OPP+O=P

P1=(x,y)4.4P2=-P1=(x, -y)

P1P2O3P1P2OP1+P2+O=OP1+P2=OP2=-P1

O+O=OO=-O


4

QRxQ+R QRP1QRP1=QP1=RQ+R+P1=OQ+R=-P1

Q QS2Q=Q+Q=-S3Q=Q+Q+Q+


4 6 2

4.6.2

(4.1)GF(p)p

y2x3+ax+b(mod p)

(a,bGF(p),4a3+27b2(mod p)0)(4.2)


4

4.12 p=23a=b=14a3+27b2(mod 23)80 (4.2)y2x3+x+14.4(b)Ep(a,b)(4.2){(x,y)|0x<p,0y<px,y}O

E23(1,1)


4

Ep(a,b)

x(0x<pxx3+ax+b(mod p)

pxy=0


4

Ep(a,b)

PQEp(a,b)

P+O=P

P=(x,y)(x, y)+(x, -y)=O (x, -y)P-P

Ep(a,b)-PEp(a,b)P=(13,7)E23(1,1)-P=(13, -7)-7 mod 2316-P=(13, 16)E23(1,1)


P x 1 y 1 q x 2 y 2 p q p q x 3 y 3 x 3 2 x 1 x 2 mod p y 3 x 1 x 3 y 1 mod p

P=(x1,y1)Q=(x2,y2)P-QP+Q=(x3,y3)

x32-x1-x2(mod p)

y3(x1-x3)-y1(mod p)


4 13 e 23 1 1 p 3 10 q 9 7 p q 17 20 e 23 1 1

4.13 E23(1,1)P=(3,10)Q=(9,7)

P+Q=17,20E23(1,1)


2 p 2 p 7 12

2P

2P=(7,12)


4

4P=P+P+P+P

4.13

E23(1,1)

Ep(a,b)Ep(a,b)Abel


4 6 3

4.6.3

ECDLP: AbelEp(a,b)Q=kPPQEp(a,b)k<pkPQPQk

Diffie-HellmanElGamal


4

1. DiffieHellman

p2180ab(4.2)AbelEp(a,b)

2Ep(a,b)G(x1,y1)GGnG=On

Ep(a,b)G

G(x1,y1)


4

AB

AnnAPA=nAGEp(a,b)

BnBPB

ABK=nAPBK=nBPA

nAPB=nBPA


4

4.14 p=211Ep(0,-4)y2x3-4G=(2,2)E211(0,-4)241241G=OAnA=121PA=121(2,2)=(115,48)BnB=203PB=203(2,2)=(130,203)121(130,203)=203(115,48)=(161,169)xx


4

2. ElGamal

(1) ElGamal

ppgxygx mod p(y, g, p)x

Mp-1kC1gk mod p,C2ykM mod pC=(C1,C2)

gcd(k,p-1)=1gcd(k,p)=1


4

(2) ElGamal

Ep(a,b)mPmPm

Ep(a,b)GEp(a,b)G


4

AnAPA=nAGBAPmk

Cm={kG,Pm+kPA}

A

Pm+kPA-nAkG=Pm+k(nAG)-nAkG=Pm

CmPmkkGkG


4

4.15 p=751Ep(-1,188)y2x3-x+188,Ep(-1,188)G=(0,376)APA=(201,5)BAPm=(562,201)Bk=386kG=386(0,376)=(676,558)Pm+kPA=(562201)+386(201,5)=(385,328){(676,558),(385,328)}


3 diffie hellman elgamal

3.

Diffie-HellmanElGamal


4

1

p pmaxAbel


4

(2)


3 gf q gf q 0 gf q

(3)

GF(q)GF(q)-{0}GF(q)


  • Login