## 各加密的數學問題 * IFP(因數分解) * RSA * DLP(離散對數問題) * D-H, DSA * ECDLP * ECDH, ECDSA, EdDSA (Ed25519/Ed448) ## RC4 ### Q. 有沒有被破解 RC4 被發現有許多弱點,現已被破解 ### Q. 當初為何使用普遍 美國使用RC4讓出口審批流程比通常的加密方式更簡單、更快捷 ## chacha20 salsa20 * Salsa20 * Key sizes: 128 bits, 256 bits. * 20 rounds * Structure: ARX (add-rotate-xor) operations * ChaCha20 * The Most Widely used Stream Cipher * Key size: 256 bits. * 20 rounds * Structure: ARX (add-rotate-xor) operations * New Round Function: increasing Diffusion and Performance ### Q. chacha20跟shasha20有甚麼差別 chacha20使用新的round function,有更好的效率以及擴散(diffusion) (New Round Function: increasing Diffusion and Performance) ### Q. chacha20兩種版本差異 * original ChaCha20 cipher * 64-bit nonce * 64-bit counter * 一組key可以用於加密無限的資料 * IETF variant * 96 bits nonce * 32 bits counter * 一組key最多用於256 GB的資料 ## RSA ### 老師提示考點 > 給p,q求n, ɸ(n) > 給e求d > 訊息加密, 解密 ### RSA * Can be used for * Encryption * Digital Signature * Key Exchange * No practical weaknesses have been found yet ![image](https://hackmd.io/_uploads/H1LW2pqfkg.png) ### RSA計算範例 ![image](https://hackmd.io/_uploads/SJ2l_0qz1g.png) ### 計算模數的inverse Extended Euclidean Algorithm ![image](https://hackmd.io/_uploads/B1pLC3PTR.png) ### Euler’s Theorem(計算x^e mod n) * 計算$x^e (modN),以5^{1202}(mod13)為例$ ![image](https://hackmd.io/_uploads/SkbZQqjlyx.png) ## Diffie-Hellman ### 老師說會考計算 ![image](https://hackmd.io/_uploads/HJ17W2SS1g.png) ## ElGamal Cryptosystem ElGamal has been described as the father of SSL. Security Basis: DLP (Discrete Logarithm Problem) 缺點: 密文size是明文的2倍 ## 橢圓曲線(ECC) ### 老師提示考點 > 求有幾點 > 給x 求y > 可能考畫圖 ### ECC * 在相同的安全性下,ECC有較小的key size但卻有相同的安全性 * ECC 可用於 * key agreement * digital signatures * encryption * pseudo-random generators ![image](https://hackmd.io/_uploads/H1wbXhHSkg.png) ![image](https://hackmd.io/_uploads/B1Bnm2HHJl.png) ![image](https://hackmd.io/_uploads/rJAnz_OS1g.png) ## Hash * A good hash function須具備的條件 * evenly distributed * apparently random. * one-way property (1對1) * collision-free property ### SHA-2 * speed * SHA-512, SHA-384 > SHA-224, SHA-256(on 64-bit machine) * SHA-512在64-bit比較快,因為他們用的是64-bit word,並非224, 256 32-bit word ### SHA-3 * SHA-3採用sponge function * Sponge Function 支持可變長度的輸入與輸出 * 可以在硬體和軟體中輕鬆且高效地實現 * SHA-3設計目的是補充SHA-2 * SHA-3並非為了取代SHA-2. ### Q. SHA1, SHA2算法的Digest length * MD5 * Digest Length: 128 bits * SHA-1 * Digest Length: 160 bits * broken * SHA-512(SHA-2) * Digest Length: 512 bits * SHA-(digest length) * SHA-224,digest length = 224 ### Q.SHA3 mapping function大概用途 * θ * Substitution * 不同lane之間做XOR * Ρ * Permutation * 每個Lane做bit shift((0,0)不用做) * π * Permutation * 不同lane位置交換((0,0)不用做) * χ * Substitution * 不同lane之間做XOR * ι * Substitution * lane(0,0)跟RC(i)做XOR ![image](https://hackmd.io/_uploads/H1FkQLIBJl.png) ### Q. Image, Pre-image * 𝑥經過雜湊函數,𝐻(𝑥),H(x) 的計算後,產生的輸出值𝑦 * y稱為映像 (image)。 * X稱為原像(Pre-image) * Pre-image Resistance(原像抗性) * 含義:給定一個雜湊值𝑦,找到對應的輸入𝑥應該是計算上不可行的。 ## MAC MAC可用來驗證訊息是否被篡改以及是否來自合法發送方 ### Q.H-MAC和C-MAC比較, 優點 * C-MAC * 以block cipher為基礎 * H-MAC * 以hash function為基礎 * 速度比較快 ### Q.CCM, GCM不同 * CCM * Encrypt-and-MAC(E+MAC;E&M) * 針對明文計算MAC * GCM * Encrypt-then-MAC(E->MAC;EtM) * 針對密文計算MAC * 可以平行化運行 * 較安全 ### Q.AEAD定義 * AEAD(Authenticated Encryption with Associated Data) * 訊息驗證 * 處理附加數據 (與密文相關聯但不需要加密) * CCM和GCM都是AEAD ## DSA :::info 老師會給式子 ::: DSA(數位簽章演算法) 是一種基於公開密鑰的數位簽章標準,用於保證數據的完整性、真實性和不可否認性 ### Q.最新的標準中誰被排除了,誰被加進去了 * 2023年的標準中移除了DSA,新增了EdDSA ### EdDSA * 在符合安全標準的DSA中,速度最快的 * Security Basis: ECDLP * HashEdDSA * 根據message的hash去做簽章 ### Q.Ed25519,448誰比較安全, 誰比較快 * Ed25519 * 較快(256-bit private key) * Ed448 * 安全(456-bit private key) ### Q.ECDSA, DSA比較 * DSA * Security Basis: DLP * ECDSA * Security Basis: ECDLP ### Q.DSA為甚麼不能共用k * 利用被同個k加密後的兩個不同密文,即可回推x * If someone gets two distinct messages signed using the same k, then he can recover x. ### Q. k被求出來後為什麼就可以把x(private key)破解 :::info 公式不用背,出了老師會給 ::: **過程** * DSA公鑰組成: g, p, q, y, (r, s) * 已知r, s, q, k,在搭配下面式子可回推x ![image](https://hackmd.io/_uploads/Bk7vlMdr1e.png) ![image](https://hackmd.io/_uploads/BJnIBfuSJg.png) ### Q.當什麼等於0, x就失效了 * 當 r = 0 時,x會失效 * r = 0, xr = 0 ![image](https://hackmd.io/_uploads/Bk7vlMdr1e.png) ![image](https://hackmd.io/_uploads/ByJ7sZ_Hkl.png) ## ASCON ### Q.ASCON 128, 128a 哪個比較安全,哪一個比較快 * ASCON-128 is more secure, while ASCON-128a is faster. ### Q.ASCON hash, hash-a 哪個比較安全,哪一個比較快 * ASCON-Hash is more secure, while ASCON-Hash-a is faster. ### Q.ASCON XOF 是什麼,跟一般hash有甚麼不同 * 可以自行指定digest size(輸出的長度) * 一般hash function都是固定長度 ### Q.畫ASCON的圖 :::info 我不知道會考哪個,大概會是這個吧 ::: ![image](https://hackmd.io/_uploads/r1v5mXdHJx.png) ## BB84 ### 可能會考計算 ![image](https://hackmd.io/_uploads/HySg87uSye.png) ### Q.dector的基底用的不一樣會怎樣 如果使用的基底部不一樣,key則會是random If the bases of Filter and Detector match, the correct bit information will be received. If they do NOT, the received result will be random ## PQC & QC * 大多都是對稱式加密 * PQC並非使用IFP, DLP, ECDLP等為Security basis * CVP, SVP, MLWE ... * PQC的Security basis無法被量子電腦有效率的解決 ### Q.PQC(後量子密碼學)相對於QC最大的優點 PQC不用使用量子電腦也能計算 ## kyber ### 老師提示考點 > 要知道演算法概念,細節不會考 * 對稱式加密 * Security basis: MLWE * Module-Learning-With-Errors (MLWE) * secret key * Kyber-512(1632) < Kyber-768(2400) < Kyber-1024(3168) bytes ### Q.(MLWE)及kyber算法 概念 透過在矩陣乘法中加入e (Error),使破解s, e十分複雜 ![image](https://hackmd.io/_uploads/B1Bl9mdH1g.png) ### Q.size以及速度比較 * sc(密鑰), pk(公鑰), ct(密文) sizes * Kyber >> RSA >> ECC * 加解密速度 * kyber >> ECC >> RSA ![image](https://hackmd.io/_uploads/rJlX_mOr1l.png)