###### tags: `選修` # 資訊安全 老師:李珮如 副教授 :::spoiler 考試必考 ::: --- :::spoiler 作業 問題 知名大學有資安的問題,原因為有位教職員被植入惡意程式,藉先傑的設施進行攻擊 解決 1.學校委外請中華電信專業解決,並針對中華電信建議事項進行改進 2.提供:**CompTIA Security+國際網路資訊安全班**課程 3.開設資訊安全公佈欄,提供相關資安資訊,以利撰寫安全的程式碼 4.推動安全系統發展生命週期(SSDLC) 5.**個資防護的****SOP****:規劃、執行、稽核、改善**PDCA --------------------- ::: --- :::spoiler 基礎知識 ::: --- :::spoiler 重點 * <p style="color:red">打亂明文和密文的對應關係</p> * <p style="color:red">明文和密文對應關係越低越好,最好是所有字詞出現頻率都一樣</p> * <p style="color:red">運算必須在原集合裡,這樣做完加密後才能回推回明文</p> ::: --- ## 章節 ### 2022/02/26 Chap1 ### 2022/03/12 Chap2 ### 2022/03/26 Chap3 ### 2022/04/09 Chap4 ### 2022/04/23 Chap5 ### 2022/05/21 Chap6 離散對數、區塊鏈 --- :::spoiler 2022/02/26 Chap1 #### Computer Security Objectives * Confidentiality: 保密性 * Integrity: 完整性 * Availability: 可取得性 #### 安全性、方便性、友善性,很難兼顧 #### Focus on: * Security Attacks * Passive Attack:消極攻擊(偷資料、監看......等) * Active Attack:積極攻擊(修改資料......等) * Masquerade * Replay * Modification of Messsages * Denial of Service * Security Service(SS) SS * Defined by X.800 as: 數位簽章 * Defined by RFC 4949 as: SS.1(Authentication) * Concermed with assuring that a communication is authentic * In the csae of a single message * In the case of ongoing interaction SS.2(Access Control 存取控制) * Identified:被辨識、Authenticated:被授權(可使用某功能) SS.3(Data Confidentiality) * The Protection of Transmitted data from passive attacks SS.4(Data Integrity) * 確認資料不會被更改 SS.5(Nonrepudiation) * 不能被否定 * Security Mechanism ##### Authentication Services * Peer entity:驗證兩端,抗偽裝攻擊、及未驗證攻擊 * Data origin: #### Cont'd * Data integrity * Authentication exchange * Traffic padding: * Routing Control:路徑控制 * Notarization: 對稱加密、可透過第三方獲取鑰匙 ##### Model for Network Security * Gatekeeper function * intermal control ![](https://i.imgur.com/V542cEq.png) * Other security-related situations * 1. Protect an information system from unwanted access * 2. 命名規格邏輯避免被猜到,例如:產品命名product......等 #### Simplified Model of Symmetric Emcryption ![](https://i.imgur.com/Ftp0Tv3.png) * Enciphering of encryption * Deciphering of decryption #### Secure Use of Conventional Encryption * 被知道演算法和密文也無法破解 * 被知道明文和密文都無法破解 #### Model Of Symmetric Cryptosystem ![](https://i.imgur.com/fMHjf8k.png) #### Cryptographic Systems #### Cont'd * Substitution:替代 * Transposition:明文重排 #### Attacking approach * 暴力攻擊法:嘗試所有可能鑰匙(不適用密碼長度很長) #### Type Of Cryptanalytic Attacks ![](https://i.imgur.com/Hs5nZcw.png) #### Encryption Scheme Security * Unconditionally Secure(理想) * Computaionally Secure * 計算上的安全性:提高攻擊的計算成本 * 時間上的安全性:提高被破解的時間 ##### Caesar Cipher ![](https://i.imgur.com/aMqu7UY.png) ##### Numerical Equivalent ##### Monoalphabetic Cipher(位移加上排列組合) ![](https://i.imgur.com/0UwBoUS.png) #### Methods to Disconnect P/C * <p style="color:red">Countermeasure: 打亂明文和密文的對應關係</p> #### Playfair Cipher:是一種使用一個關鍵字方格來加密字元對的加密法 #### Advantages of Playfair Cipher: * Whereas there are only 26 letters, there are 26 * 26 = 676 digrams #### Hill Cipher * 優點:可以完全隱藏單字出現頻率 * 缺點:容易被已知明文攻擊擊破。 即得知明文與密文之相對,就能夠破解。 #### Concepts from Linear Algebra #### Vigenere Cipher(基於Caesar Cipher) * 缺點:會出現一樣單字的頻率 #### Vernam Cipher * 密碼只用一次,但是如何產生源源不絕且不重複的密碼,和如何儲存密碼 #### Rail Fence Cipher #### Row Transposition Cipher #### Rotor Machines #### Steganography(例如藏頭詩) * 藏機密訊息,但不屬於密碼學 #### Symmetric Cipher ![](https://i.imgur.com/nRcEo0L.png) #### Stream Cipher * 每個位元加密 #### Block Cipher * n bits 加密 #### Feistel Cipher ![](https://i.imgur.com/L5e2f7M.png) * Diffusion(擴散): 一個明文對應到不同密文 * Confusion:密文跟明文出現頻率不一樣 #### DES Encryption Algorithm ![](https://i.imgur.com/eWLKVeV.png) * 輸入輸出長度一致 #### Single Round of DES ![](https://i.imgur.com/MOeWNGw.png) #### E Table #### Concerns of DES #### Definition of DES S-Boxes ![](https://i.imgur.com/i3TD8lV.png) #### Key Generation #### Average Time Required for Exhaustive Key Search ![](https://i.imgur.com/29fVWCp.png) #### 如何判斷比較加密法好壞: * <p style="color:red">較難破解</p> * <p style="color:red">明文和密文對應關係越低越好,最好是所有字詞出現頻率都一樣</p> --- ::: --- :::spoiler 2022/03/12 Chap2 ## Basic Conepts in Number Theory and Finite Fields * <p style="color:red">運算必須在原集合裡,這樣做完加密後才能回推回明文</p> * Finite Field Arithmetic * Modular arithmetic:模數算數(取餘數的運算) * 令一個正整數n 與整數a,並a 除以n 得到商為q,與餘數b * Euclidean Algorithm: ![](https://i.imgur.com/4YUAk4g.png) * **計算至餘數為 0:表示求解完畢,最後將兩數整除的數字即最大公因數GCD。** * **計算出GCD為 1:表示兩數互質。** * Properties of Congruences:同餘 * 給定一個[正整數]m,如果兩個[整數]a和b滿足a-b能夠被m整除,即(a-b)/m得到一個整數,那么就稱整數a與b對[模]m同餘,記作a≡b(mod m)。對模m同餘是整數的一個等價關係。 * Group, Rings, and Field: ![](https://i.imgur.com/VlwmkdY.png) * Example of GF(2) * 加法: XOR * 乘法: AND * Polynomial Division:多项式除法 ## Advanced Encryption Standard(AES) * 1. Substitute Byte Transformation * ![](https://i.imgur.com/R0Gs9bt.png) * 2. Shift Row Transformation * ![](https://i.imgur.com/eIKSz73.png) * 3. MixColumn Transformation * ![](https://i.imgur.com/skvSrw7.png) * 4. AddRoundKey Transformation * ![](https://i.imgur.com/ARimGUG.png) ## AES Key Expansion 解密 * 加解密過程不一樣。 * ![](https://i.imgur.com/WNman45.png) * ![](https://i.imgur.com/Gnh8JPF.png) --- * ![](https://i.imgur.com/DhowJzK.png) * ![](https://i.imgur.com/sd3USJx.png) * ![](https://i.imgur.com/xrLQ8uU.png) --- [AES參考資料](https://kknews.cc/code/rn24jmo.html) [AES參考資料](https://ithelp.ithome.com.tw/articles/10249488) [AES影片](https://www.bilibili.com/s/video/BV1HK4y1s7Np) ::: --- ::: spoiler 2022/03/26 Chap3 ## Block Cipher Modes of Operation [Block Cipher Modes of Operation](https://www.educba.com/block-cipher-modes-of-operation//) ![](https://i.imgur.com/UDY0cxh.png) * ECB: 適用較短訊息,缺點是一樣的明文遇上一樣的密鑰會產生一樣的密文 * ![](https://i.imgur.com/r9pEXco.png) * CBC: 適用區塊加密和驗證上,缺點是必須要解自己區段的明文,需有其他區段的密鑰 * ![](https://i.imgur.com/4gxniX6.png) * CTR: 適用區塊加密和高速加解密上 * ![](https://i.imgur.com/8dZjnDB.png) * CFB: 適用串流加密 * ![](https://i.imgur.com/dTq9fRm.png) * OFB: 位元傳出錯誤不會影響解密過程,缺點是信息解密過程會被攻擊 * ![](https://i.imgur.com/oGIcD06.png) ## The Use of Random Numbers(亂數) * 判斷亂數產生器的好壞 1. 隨機性 2. 不可預測性 * Test of Randomness 1. Uniformity:一致性 2. Scalabillty:可擴展性 3. Consistency:合理性 * SP 800-22:測試亂數隨機性 ## PRNG Using Block Cipher Modes of Operation ![](https://i.imgur.com/9UltUKG.png) ## ASNI X9.17 PRNG ![](https://i.imgur.com/1NgFDtQ.png) ## More Number Theory * Prime Numbers(質數): 大於1的自然數中,除了1和該數自身外,無法被其他自然數整除的數。 1. 米勒-拉賓(MillerRabbin)法(判斷是否是素數的演算法): 核心為費馬小定理 * Fermat's Theorem(費馬大定理): 1. 設 _n_ 是大於 2 的正整數,則方程式 _x__n_+_y__n_=_z__n_,沒有正整數解。 2. **費馬小定理**: 若_p_是質數且_a_是與_p_互質的整數,則![](https://i.imgur.com/wFaDRUZ.png) * Euler's Totient function(歐拉函數): 小於等於_n_的正整數中與_n_[互質](https://zh.wikipedia.org/wiki/%E4%BA%92%E8%B3%AA "互質")的數的數目,例如{\\displaystyle \\varphi (8)=4}![\varphi (8)=4](https://wikimedia.org/api/rest_v1/media/math/render/svg/0b27ff795221f55c90a3acf7197fd4a2c337cfac),因為1,3,5,7均和8互質。 * Discrete Logarithms(離散對數): 是一種基於[同餘](https://www.newton.com.tw/wiki/%E5%90%8C%E9%A4%98)運算和[原根](https://www.newton.com.tw/wiki/%E5%8E%9F%E6%A0%B9)的一種[對數](https://www.newton.com.tw/wiki/%E5%B0%8D%E6%95%B8)運算。公鑰密碼學中幾個重要算法的基礎,是假設尋找離散對數的問題解,在仔細選擇過的羣中,並不存在有效率的求解算法。 ::: --- :::spoiler 2022/04/09 Chap4 ## 彼得·杜拉克:如果不能衡量,你就不能管理 ::: --- :::spoiler 2022/04/23 Chap5 ::: --- :::spoiler 2022/05/21 Chap6 離散對數、區塊鏈 ## Discrete Logarithms(離散對數): 能應用在公開金鑰加密系統 * Diffie-Hellman key exchange: 交換對稱加密鑰匙 * Digital sinature algorithm(DAS): 數位簽章 ![](https://i.imgur.com/eYhymEc.png) ![](https://i.imgur.com/MeZ8JFr.png) ![](https://i.imgur.com/zHRAv0W.png) ![](https://i.imgur.com/4CyxB97.png) ### 對數定理 ![](https://i.imgur.com/XxhfJYc.png) ![](https://i.imgur.com/NrdO11D.png) ![](https://i.imgur.com/iZCNc9E.png) ![](https://i.imgur.com/TJXsfIQ.png) ![](https://i.imgur.com/wOlbY4c.png) ### 尤拉公式 ![](https://i.imgur.com/WvRZdp2.png) ### 離散公式難題: 難以快速求得X ![](https://i.imgur.com/2HjEQ87.png) ## 區塊鏈 ### 定義: 將資料彙整為區塊,加上雜奏函數並串聯成鍊,以確保資料安全 ![](https://i.imgur.com/AB79utO.png) ### 區塊鏈技術 ![](https://i.imgur.com/50gv79z.png) ### 區塊的定義 ![](https://i.imgur.com/1v4rPFE.png) ### 區塊鏈的結構 ![](https://i.imgur.com/DWn8ZGL.png) ### 比特幣區塊中的資料內容 ![](https://i.imgur.com/x1sRfbM.png) ### 區塊鏈的共識機制 ![](https://i.imgur.com/2Zbp2Dw.png) ### 工作量證明機制 ![](https://i.imgur.com/BVdYPK1.png) ### 傳統帳本 VS. 區塊鏈帳本 ![](https://i.imgur.com/bbAVE5r.png) ### 幣特幣拜占庭將軍問題和解決: ![](https://i.imgur.com/7IaaooX.png) ![](https://i.imgur.com/yJG2E13.png) ### 區塊鏈解決之痛點Pain-Points ![](https://i.imgur.com/RvMOhku.png) ### 區塊鏈的類型 * 公有鏈: 任何人都可交易和查看交易資料及參與達成共識的過程 * 聯盟鏈:節點的權限將會有所限制 * 私有鏈:獲得授權的節點通之是有合作或商業關係的 * 混合鏈和複雜鏈: 節點有不同分工 ### 區塊鏈的技術 * 區塊鏈的觀念原於帳本記錄(Ledger) ![](https://i.imgur.com/M9OBZU0.png) ### 區塊鏈防偽 ![](https://i.imgur.com/Av5v5JW.png) ### 區塊鏈特性 ![](https://i.imgur.com/uHAv04g.png) ### 區塊鏈流程 ![](https://i.imgur.com/wLB5wi4.png) ### 區塊鏈安全技術 ![](https://i.imgur.com/tyj73gs.png) #### Hash Funcion 雜湊函數 * 欲由Hash輸出值反推輸入值非常困難 ![Uploading file..._8ahymp70o]() #### SHA-256 ![Uploading file..._7xrzudwms]() ### 區塊鏈的成長與驗證 ![](https://i.imgur.com/Z7WW57D.png) #### 默克爾數 ![](https://i.imgur.com/6VgcaQ9.png) ### 區塊串連成鍊 ![](https://i.imgur.com/gUDEej5.png) ### Hash List ![](https://i.imgur.com/dKkatVS.png) ### NFT ![](https://i.imgur.com/9JfTwGq.png) ### 比特幣並未完全解決重複消費之問題 :::