1 網際網路的資訊安全 陳以德. 2 Outline(1/2) 密碼學簡介 – 網路傳輸的危險性...

Preview:

Citation preview

1

網際網路的資訊安全

陳以德

2

Outline(1/2)

• 密碼學簡介– 網路傳輸的危險性– 加密與解密– 對稱性加密 (Substitution, Transposition, AES)

– 非對稱性加密 (RSA)

– MAC

– 電子簽章

3

Outline(2/2)

• 防火牆 (Firewall)– 簡單交通記錄系統– Packet Filtering

– Application Gateway

– Proxy Server

– Screened Host Firewall

4

明文在網路上傳輸的危險性

Sniffer

pw: 天地玄黃 pw: 天地玄黃

pw: 天地玄黃

eavesdropper

A B

E

5

其他傳輸 Attack

• Eavesdropping

• OS 漏洞• Password 的竊取• Spoofing, Spam, Intrusion

• Session Hijacking

• 特洛依木馬 Troy 、 virus 、 trapdoor

• Covert Channel

6

加密系統的應用

NetXray

pw: 天地玄黃 pw: 天地玄黃

eavesdropper

A B

加密

@#$%&*

解密

@#$%&*

@#$%&*

E

7

加 密 與 解 密

Decryption

Encryption

M CeK

dK密文明文

8

對稱 ,秘密與公開金匙

對稱金匙 (Symmetric Key) 系統 Ke=Kd

非對稱金匙 (Asymmetric Key) 系統 Ke≠Kd

9

表 白  雖萍水相逢,但覺你是很好的人,仔細思考後,決定向你用以最最笨拙的方式表白,也許我沒有你想要的優點,也許是一廂情願,我卻甘心.我並不需要你的回報,我只願默默的關心你,在背後祝福你,不讓你苦惱,也無意擾亂你生活,要是你深覺不妥,我願意忍住痛苦,裝做不曾為了你而動過心,我不是聰明伶俐的人,但也不至是如此不明理的人.年輕都會有夢想,我的愚昧,使我踏入了情感陷阱,整個人就如斷線風箏,飛向夢想.在這季節裡,天氣正如我的心情,時而愉快,時而感傷.此時,我不抱任何樂觀的態度,但只願你瞭解我的心. ...僅以真誠的心...

10

Substitution Ciphers( 對稱性加密 )

原始文字與加密文字對照表

•那麼 apple 這個字就會變成 bqqmf 了• I love you 變成 j mpwf zpv•加密時向右移一位 , 解密時向左移一位•加解密的 Key 相同

1 2 3 4 5 6 7 8 9 10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

A B C D E F G H I J K L M N O P Q R S T U V WX Y ZB C D E F G H I J K L M N O P Q R S T U V W X Y Z A

11

Transposition Ciphers

這富額代能都一獸貴上表買能個又,打名賣夠人強奴印字。算。迫隸記的這出這所或。數裡獸數有自這字需的字的由印;要數是人人記沒有字六,,就有智,百無在是這慧因六論他那印。為十大們獸記凡這六小的的的是數。,右右,聰字貧手字就明代窮和或不人表

12

這富額代能都一 獸貴上表買能個 又,打名賣夠人 強奴印字。算。迫隸記的這出這所或。數裡獸數有自這字需的字的由印;要數是人人記沒有字六,,就有智,百無在是這慧因六論他那印。為十大們獸記凡這六小的的的是數。,右右,聰字貧手字就明代窮和或不人表

13

Vigenere 加密法

Jwlmliplopwkjmiplopwkjmzieufvhshhnabhofodqfauiipjaoxabtwlmleffrsnruhloggbnn

Fesnedxabieltmbeevuiqzizjlogoomoziipfvhsslochiewpufiegnykfauuinoozuhhseltnw

brDedotrpdhfpdnoxotdjnvphlhhlucdotnfeslehqmhbwdzazbyisopiivmoyf

14

DES(Data Encryption Standard)

• Plaintext M(64 bits)

• Ciphertext C(64 bits)

• Key K(56 bits or 64 bits)

• Round Function F(X, Y) :

X(32 bits) and Y(48 bits)

• Rounds: 16

15

DES(Cont.)

• IP: initial permutation IP(M) = (L, R)

• FP: final permutation : IP.FP = FP.IP

• (Ln, Rn) = (Rn-1, Ln-1 F(Rn-1, K))

• F(X, Y) = Perm(S_box( Ext(X) Y))

• C = FP(R, L)

16

Plaintext

Plaintext

L0

L16=R15

R15=L14 xor f(R14,K15)

R2=L0 xor f(R0,K1)

R1=L0 xor f(R0,K1)

R0

R16=L15 xor f(R15,K16)

L15=R14

L1=R0

L2=R1

IP

f

f

IP -1

f

K 1

K 2

K 16

DES(Fig.)

17

DES(One round)

L i-1 R i-1

R iL i

E-box Permutation

P-box Permutation

S-boxes Substitution

K e y

Left Shift Left Shift

Compression Permutation

32 位 元32 位 元48 位 元

subkey: 48 位 元

28 位 元28 位 元

32 位 元

f fu n c tio n

su b k ey s ª º² £¥ Í

18

Triple DES

Plaintext Ciphertext

DES

DES DESDES-1

DES-1 DES-1

K1 K3K2

Encipher

Decipher

19

RSA 密碼系統 ( 非對稱加密 )

產生兩把鑰匙的步驟:• 隨機取兩個很大的質數 p, q 。(最好大於 2512)• 計算出 n = p * q 及 (n)=(p-1)*(q-1)• 隨機找一個與 (n) 互質的數目 : e 。 (意即 gcd (e, (n))=1)• 利用歐幾里得演算法得出 : d such that

  d 滿足 e * d ≡1 mod (n) 。• 以 (e, n) 為 Public key , d 為 Private key 。

20

RSA ( 原理 )

(Cd mod n)

= ((Me mod n)d mod n)

= Me*d mod n

= M(k * (p-1) * (q-1)) + 1 mod n

= M1 mod n=M

( 因為 e * d ≡1 (mod ((p-1) * (q-1))) 。 )

Fermat’s Theorem (n) mod n =1

21

RSA 密碼系統• 取兩個質數 p=101, q=53, n=101*53=5353

• 明文 =4657

• 設 A 的公開金匙 (eA,NA)=(7,5353)

• 利用歐幾里得演算法得出秘密金匙 dA=743,

[Where eA, dA=1 mod (100*52)]

• 得到密文為 4657743 mod 5353 = 1003

• 密文用的公開金匙 (eA,NA ) 解開得回明文 10037mod 5353=4657

22

RSA 例子 1,BA

• 取兩個質數 p=3, q=5

• n=3*5=15

• Φ(n)= (3-1)*(5-1)=8

• 明文 m=13

• 任取一數 11得 A’s Public key (eA,NA)=(11,15)

• 利用歐幾里得演算法得出 Private key dA=3,

23

11 與 Φ(n) 輾轉相除11 8 8 6 3 2 2

1

1=3-2 =3-(8-6) =3-8+6 =(11-8)-8+2(11-8) =3(11-8)-8 =3(11)-4(8)取 Public key 11 與 Φ(n) 輾轉相除最後 (11)旁的係數 3, 為另一支key

24

RSA 例子 1,BA(Cont.)

• eA*dA=11*3=1 mod Φ(n)

• B 用 A’s Public key 加密得密文為 :1311 mod 15 = 7

• A 用自己的 Private key 解開密文得回明文 73mod 15=13

25

RSA (例子 2, 驗證 )

• Example(承上例 , p=3, q=5, n=15, e=11, d=3)– A將文件 (m=13) 用 A 的 Private key 加密

133 mod 15=7– B 用 A’s Public key 解密得回明文

711 mod 15 =13– 可用來做電子簽章驗證

26

RSA 特性及其運用• RSA運用 exponential algorithm

• RSA執行速度較 DES等對稱加密慢• 硬體的 RSA比硬體的 DES慢 1000倍• 軟體的 RSA則比軟體的 DES慢 100倍• 故 RSA 其主要的用途:

– digital signature– protocol中的 key exchange 。

27

單向函數 One-way Function• 定義:一函數滿足下列條件則稱 f 為 One-way Function

• 1. 對於所有屬於 F域之 x, 很容易計算出 f(x)=y.• 2. 對於幾乎所有屬於 f 之範圍的任一 y, 在計算上不可

能求出 x 使得 y=f(x)

• Example:• y = f(x) =xn+an-1 xn-1+…+a1x+a0 mod p

X Y易 f

28

Message Authentication Codes (MAC)

• MAC is an authentication tag (also called a checksum) derived by appying an authentic-ation scheme, together with a secret key, to a message.

• There are four types of MACs:(1) unconditionally secure

(2) hash function-based

(3) stream cipher-based or

(4) block cipher-based.

29

MAC

• Hash function H(m1, m2, …, mt)=m

• 現有的 Hash function: MD5, SHA-1, ...

• MAC is key-dependent one-way hash function– MAC are computed and verified with the same key– A & B 共同擁有 key K– A send H(K, M) to B– B can reproduce A’s result

30

現有對稱與非對稱加密法• 對稱加密法

– DES, IDEA, AES(MARS, RC6, Rijndael, Serpent, and Twofish), ...

• 非對稱加密法– RSA, ElGamal, …

31

總結 (1/)

• 對稱式加密

I am

YiterDES

Asd$#v#$h DES

Session Key

Session Key

I am

Yiter

32

總結 (2/)

• 非對稱式加密

RSA@#SDFGSASDF

RSA

對方的

Public key自己的 Priv

ate Key

I am

Yiter

I am

Yiter

第三公正者

33

總結 (3/)

• 對稱與非對稱式加密交互運用

Session Key RSA

^%$(*&#$ RSA

Session Key

I am

陳水扁DES

Dthfgb$shgzxcv

DES

Session Key

Session Key

I am

陳水扁

Bdve$%^@dgrse

對方的

Public key

自己的 Private Key

34

總結 (4/) 電子簽章• Example(承上例 , p=3, q=5, n=15, e=11, d=3)

– 將簽署文件 (m=13) 用 A 自己的 Private key 加密後得到密文 133 mod 15=7

– A 將簽署文及密文 (m=13, c=7) 一齊送給 B

– B 可拿 A 的 Public key (eA,NA)驗證得回簽署文

– m’=711 mod 15 =13

– 若 m=m’ 則驗證正確

35

訊息摘要 電子簽章

Hashing

原文

電子簽章

電子簽章 訊息摘要

PublicKey

訊息摘要Hashing

比對

 原文

 原文

總結 (5/) 電子簽章圖示

Secret Key

36

總結 (6/)

• 對稱 ; 非對稱式加密加電子簽章

Session Key RSA

^%$(*&#$ RSA

Session Key

Rijndael Dthfgb$shgzxcv

Rijndael

Session Key

Session Key

原文

電子簽章

原文

電子簽章

對方的

Public key

自己的 Private Key

37

定義 :

只讓具備特殊身分的外在使用者才能連上一個被保護的網站 , 使用其軟體或硬體A firewall system is used to control access to or from a protected network ( a site ).

小問題 : pcanywhere

Firewall

38

Firewall圖示

39

Firewall 的種類•簡單交通記錄系統•封包過濾 (Packet Filtering)

• Application Gateway (Dual-homed Gateway)

• Proxy Server

• Screened Host Firewall

40

簡單交通記錄系統• 將網路上傳輸記錄在稽查記錄檔案 (.log)

• 記錄的資料– 被存取的檔案– 使用者何時由何地用什麼程式進來– 使用者存取及上傳的位元數

41

封包過濾 (Packet Filtering)

42

封包過濾常用審查法則• 根據協定 (ICP, UDP, ICMP)來控制及過濾

• 對某些應用做限制性取用 (port 80, 443...)

• 對己知來源的 IP 位置做限制 (.edu)

Block or filter protocols「 ports」 and「 addresses」IP header Source IP address TCP header Source port

Destination IP address Destination port

43

封包過濾優缺點•優點

– Most Common ,easy and cheap

– Fully transparency, no impact to user

•缺點– Little or no logging capability– Complex filtering rules may become unmanageable– Rules are difficult to test thoroughly

44

Application GatewayDual-homed Gateway

45

Application Gateway圖示

46

Application Gateway

• 外界使用者在做進一步連結前 , 先連接到受信賴的應用程式上

• 系統管理注意事項– 除 Firewall必須帳戶外 , 刪除所以使用者帳戶– 刪除不必要的檔案及程式 (FTP, Telnet)– 將記錄 (.log)和監控延伸到可以檢查遠端存取– 關閉 IP轉寄的功能

47

Proxy Server

Client

Proxy Server 位於 Internet 和內部網路之間 , 提供中間人的服務 支援「 extra logging」 and「 advanced authentication」 Proxy

ServerRemote Server

Cache

48

Screened Host Firewall

Site Systems

Internet

Bastion Host(Application Gateway)

IP FilteringRouter

Screened Host Firewall 為封包濾器 (packet filter) 與應用閘道器 (application gateway) 的組合

49

Screened Host Firewall

•允許外界封包輸至內部閘道器 •不允許外界封包輸至內部其它主機 •允許閘道器的封包輸出至外界網路 •不允許其它內部主機的封包輸出至外界網路

50

Screened Host Firewall

優點 More flexibility. Router filtering rules are simplified .

缺點 Less security. (packet can go directly i

nside)

51

Screened Subnet Firewall

Site Systems

Internet

Bastion Host

IP FilteringRouter

IP FilteringRouter

InfoServer

MailServer

(1) From bastion host to outside(2) E-mail from mail server to outside(3) From outside to bastion host(4) E-mail From outside to mail server(5) WWW , Gopher from outside to info server(6) REJECT all other traffic

(1) From bastion host to inside(2) E-mail from mail server to inside(3) From inside to bastion host(4) E-mail From inside to mail server(5) WWW , Gopher from inside to info server(6) REJECT all other traffic

DMZ/Perimeter Network

52

“Subnet v.s. Host” Screened Gateway• Subnet 將 Host中的單部 Gateway擴展成數部,並將風險及效能的負擔分散至數部主機,所以較有彈性、安全、且有效率。

• 缺點– More expensive– complex management– Less security if permit special「 trusted」 servi

ce.

53

What Can’t a Firewall Protect Against

• Firewalls can’t protect against attacks that don’t go through the firewall , or rules that make a leak.

• Firewalls can’t protect against 「 data driven 」 attacks , like 「 Virus 」 .

54

Firewall 的安全策略• 管理者工作

– 對機構內的安全策略必須十分清楚– 知道 Firewall功能中監視 , 複製 , 控制的程度– Firewall反應整體安全程度

• 不能允許不受限制的 modem 上線• 機密資料就不該連到 Internet

• 私人資料系統與公司網路的其它部分分開– Firewall 非萬能

55

Firewall管理問題• 自己建立或買現成的

– 買現成的貴又怕 Trapdoor– 自行設計要考慮支援和系統更新等後續維修

• 容量管理問題– Bottleneck

• 內容管理和控制問題– MIS部門 , 行銷通訊部門或功能部門的工作

56

參考資料• Electronic Commerce : A Manager’s Guide Kalakota & Whinston

•碁峰 :網際網路安全手冊•網站

– http://www.rsasecurity.com/– http://khchu.virtualave.net/index.htm

Recommended