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

第4章 公钥密码 PowerPoint PPT Presentation


  • 128 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

RSA


4.1 4.1.1

Prime & coprime


2.

p(p>1)p1p

a(a>1)

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

91=71311011=711213


3.

cab

cab cab

abc

c=gcd(a, b)

? a,bc=gcd(a, b)


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.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


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.1 Z8={0,1,,7}Z84.1774.1

xyx+y0 mod 8262+60 mod 8yx

xyxy1 mod 8331 mod 8yx

x


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


[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 nbc mod n

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


63672 mod 837 mod 8

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


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


pZp0p

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


4.1.3

(Fermat) (Euler)


1.

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

4.1


2.

nnnn(n)

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

n


3.

4.4Euler ana(n)1 mod n

RZnn

aR=R


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)


x21 mod px0{-1,1}p


4.1.5

EuclidEuclid


1.

Euclid

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

abba mod b


2.

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


4.1.6

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


4.5 m1,m2,,mk

M:

ei


Mx(a1,a2,,ak)


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 18133749

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

a1973 mod m111,a2973 mod m342x374911,42


1

2


1

x1615xx2x4x8x164

amam

mbk bk-1b0

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


23=124+023+122+121+120

a23 = ?


(a,m)

d=1

For i=k Downto 0

DO {

d=(dd) mod n;

if bi=1 then {

d=(da) mod n

}

}

return d.


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


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


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


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)1329


4.1.7

1.

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

am1 mod n

anmm=(n)mna


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 amak1 mod nkm


am(n)

am(n)anan

a,a2,,a(n)

mod nn

ap

a,a2,,ap-1

mod p

?


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

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


n=19a=3mod 19

398515726181610111441217131

318=(19)319


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)


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)=6a=2pa9

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


3.

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

apibabpi

p


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.2



5


1976W.DiffieM.Hellman


4.2.1


4.1


BPKBSKBPKBSKB

BPKBSKB

ABmBmc=EPKB[m],cE

BcSKBm=DSKB[c]D


BSKBc

Am4.2ASKAm

c=ESKA[m]

cBBAPKAc

m=DPKA[c]


4.2


mcASKAAcAmASKAm


4.3


4.3


SKAmPKB2

c=EPKB[ESKA[m]]

m=DPKA[DSKB[c]]

,


4.2.2

:

BPKBSKB

Amc

c=EPKB[m]

Bcm=DSKB[c]


BPKBSKB

cBPKBm

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


XYYyxXxyyx

nnaaPn2n


fk

Y=fk(X)kX

X=f-1k(Y)kY

X=f-1k(Y)Yk


4.3 RSA

RSA1978R.Rivest, A.ShamirL.Adleman


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.

nlog2nm cme mod n


3.

mcd mod n

RSA


RSA

HI

(1)

p=5,q=11

n=55, (n)=40

e=3()

d=27 (mod 40)()


(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


(3)

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

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

HI


RSA

RSA{e=3,d=7},

4


4.3.2 RSA

1. RSA

RSA6677mod 1196677

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


x1615xx2x4x8x164

amam

mbk bk-1b0

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


23=124+023+122+121+120

a23 = ?


(a,m)

d=1

For i=k Downto 0

DO {

d=(dd) mod n;

if bi=1 then {

d=(da) mod n

}

}

return d.


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


2. RSA

pqed

n=pqpqpq10100n10200664102002664838DES88RSA


(Miller-Rabin)


4.3.3 RSA

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


RSA-129n129428819944RSA-130 19964


RSA-129RSA-130RSA130RSA-12910%RSA10242048RSA


RSA{e=3,d=7},

4


4.6

4.3RSAECCelliptic curve cryptographyECCIEEEP1363


4.6.0


4.6.1

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

abcdeO4.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


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

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


4.6.2

(4.1)GF(p)p

y2x3+ax+b(mod p)

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


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)


Ep(a,b)

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

pxy=0


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=(x1,y1)Q=(x2,y2)P-QP+Q=(x3,y3)

x32-x1-x2(mod p)

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


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

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


2P

2P=(7,12)


4P=P+P+P+P

4.13

E23(1,1)

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


4.6.3

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

Diffie-HellmanElGamal


1. DiffieHellman

p2180ab(4.2)AbelEp(a,b)

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

Ep(a,b)G

G(x1,y1)


AB

AnnAPA=nAGEp(a,b)

BnBPB

ABK=nAPBK=nBPA

nAPB=nBPA


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


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


(2) ElGamal

Ep(a,b)mPmPm

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


AnAPA=nAGBAPmk

Cm={kG,Pm+kPA}

A

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

CmPmkkGkG


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-HellmanElGamal


1

p pmaxAbel


(2)


(3)

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


  • Login