NYCU-LYX

2-Cryptographic Tools

Learning Objectives

After studying this chapter, you should be able to:

https://www.youtube.com/watch?v=8I_q-NNm7Nw&t=3s

2.1 Confidentiality with Symmetric Encryption

block encryption algorithms :

symmetric stream encryption algorithms

Symmetric encryption(對稱加密)

two requirements for secure use of symmetric encryption:

  1. A strong encryption algorithm
    • Opponent: Unable to decrypt cipher text or discover the key, (given pairs of cipher texts and plain texts, as well as the algorithm)
  2. Secure key distribution and maintenance (安全的分配及維運)

Two approaches to attacking a symmetric encryption scheme(對稱式加密攻擊情況)

  1. Cryptanalytic Attacks (密碼破譯)
    • Exploit:
    • Nature of the algorithm(演算法本身有問題)
    • general characteristics of the plaintext (有特徵字)
    • Sample plain text-cipher text pairs
      • Trick:
    • Deduce a specific plaintext or the key(推論出特定文字或金鑰)
      • effect:
    • All future and past messages encrypted with that key are compromised
  2. Brute-Force Attack (暴力破解)
    • Exploit
    • Knowledge about the expected plaintext(解出來且自己要看得懂)
      • Trick:
    • Try all possible keys on some ciphertexts
      • Until an intelligible translation into plaintext is obtained
      • On average half of all possible keys must be tried to achieve success
      • effect:
    • get the plain text

Symmetric Block Encryption Algorithms (對稱式加密演算法)

most commonly used symmetric encryption algorithms

Data Encryption Standard (DES)

Brute-Force Attacks against DES

EFF (Electronic Frontier Foundation): the leading nonprofit organization defending civil liberties in the digital world

Triple DES (3DES)

Advanced Encryption Standard (AES)

Practical Security Issues

Stream Ciphers

Block Cipher Stream Cipher
⚫ Processing one block at a time
⚫ Each input block → an output block


⚫ Pro: Can reuse keys
 More common
⚫ Apps: file transfer, e-mail, and database
⚫ Processing input elements continuously
⚫ One element at a time
 Typically: one byte; one bit or larger units are also allowed
⚫ Pro: almost always faster (XOR) and use far less code
⚫ Apps: data stream over a communication channel or a browser/Web link
  The keystream must not be reused!!
Consider: (A ⊕ K) ⊕ (B ⊕ K) = A ⊕ B

2.2 Message Authentication and Hash Function

Authentication Using Symmetric Encryption

Can We Use Symmetric Encryption?

It seems proper, but it is not a suitable tool for data authentication. Why?

Message Authentication w/o Encryption (訊息驗證無加密)

Message Authentication Code (MAC)

if the received code matches the calculated code, then:

  1. message has not been altered (訊息沒有被替換)
  2. receiver is assured that the message is from the alleged sender (接收者確信該訊息來自所謂的發送者) ➝ Because no one else knows the secret key
  3. If the message includes a sequence number (such as is used with X.25, HDLC, and TCP), then the receiver can be assured of the proper sequence because an attacker cannot successfully alter the sequence number.
    • Drawbacks
    • Encryption software is quite slow
    • Encryption hardware costs are non-negligible
    • Encryption hardware is optimized toward large data sizes

Does message authentication really need encryption of the message?

回想一下我們在第 2.1 節中對實際安全問題的討論,對於大量數據,需要某種操作模式來將分組密碼(例如 DES)應用於大於單一區塊的資料量。對於這裡提到的MAC應用,DES應用在所謂的密碼塊連結模式(CBC)中。本質上,DES 按順序應用於訊息的每個 64 位元區塊,加密演算法的輸入是當前明文區塊和前一個密文區塊的 XOR。 MAC 源自於最終的區塊加密。有關 CBC 的討論請參閱第 20 章。

One-way Hash Function

The hash value ensures only unaltered contents. How about authentic source?

Hash Function w/ Symmetric Encryption

Hash Function w/ Public-key Encryption

這兩種方法(Hash Function w/ Symmetric Encryption & Hash Function w/ Public-key Encryption)比加密整個訊息的方法具有優勢,因為需要較少的計算。但更常見的方法是使用_完全避免加密_的技術。 [TSUD92] 中指出了幾個這種興趣的原因:

Hash Function w/o Encryption: Keyed Hash MAC

scss
H(K XOR ipad || M)
  1. Outer Hash:
    • XOR the key with a different constant (opad) and hash the result todether with the output of the inner hash using the same hash function (H).
mathematica
H(K XOR opad || H(K XOR ipad || M))
  1. Output:
    • The result of the outer hash is the HMAC value, which can be used for message authentication and integrity verification.

The HMAC construction ensures that both the secret key and the message are involved in the hash computation, making it resistant to various types of attacks.

Secure Hash Functions

haSh Function rEquirEMEntS

A hash function 𝐻 must have the following properties(函數 𝐻 必須具有以下特性)

  1. 𝐻 can be applied to a block of data of any size (𝐻 可應用於任何大小的數據塊)
  2. 𝐻 produces a fixed-length output(𝐻 產生固定長度的輸出)
  3. 𝐻(𝑥) is relatively easy to compute for any given 𝑥 (對於任何給定的 𝑥,計算 𝐻(𝑥) 相對容易)
    • Making both hardware and software implementations practical (可以用於硬件和軟件實現)
  4. One-way (pre-image resistant) (可以用於硬件和軟件實現)
    • For any given code h, it is computationally infeasible to find 𝑥 such that 𝐻(𝑥)=h (對於任何給定的代碼 h,計算上是不可能找到 𝑥 使得 𝐻(𝑥)=h)
  5. Second pre-image (weak collision) resistant (𝐻 是第二原像抵抗(抗弱碰撞攻擊))
    • For any given block 𝑥, it is computationally infeasible to find 𝑦 ≠ 𝑥 with 𝐻(𝑦)= 𝐻(𝑥) (對於任何給定的數據塊 𝑥,計算上是不可能找到 𝑦 ≠ 𝑥 使得 𝐻(𝑦)= 𝐻(𝑥))
  6. Collision (strong collision) resistant(𝐻 是碰撞抵抗(抗強碰撞攻擊))
    • It is computationally infeasible to find any pair (𝑥, 𝑦) such that 𝐻 𝑥 = 𝐻(𝑦)= h (計算上是不可能找到任何一對 (𝑥, 𝑦) 使得 𝐻(𝑥) = 𝐻(𝑦))

Feature

Security of hash Functions

the level of effort required is proportional to the following:

Secure hash function algorithm

特徵 SHA-3 SHA-2
結構 海綿函數 Feistel 迴圈
摘要長度 任意 固定
安全性
效率
擴展性

Other Applications of Hash Function

2.3 Public-Key Encryption

Public-Key Encryption Structure(公鑰加密結構)

For public-key key distribution, some form of protocol is needed, often involving a central agent, and the procedures involved are no simpler or any more efficient than those required for symmetric encryption.(對於公鑰加密中的鍵分發,需要使用某種形式的協議,通常涉及一個中央代理,而涉及的過程並不比對稱加密所需的簡單或高效。)

一個公鑰加密方案有六個組成部分(見圖 2.6a):

通用公鑰加密算法依賴於一個密鑰進行加密,另一個相關的密鑰進行解密。

基本步驟如下:

  1. 每個用戶生成一對密鑰,用於對消息進行加密和解密。
  2. 每個用戶將兩個密鑰中的其中一個放入公共註冊表或其他可訪問文件中。這就是公鑰。伴隨的密鑰是保密的。正如圖 2.6a 所示,每個用戶都維護一個從他人那裡獲得的公鑰集合。
  3. 如果Bob想向Alice發送私人消息,Bob將使用Alice的公鑰對消息進行加密。
  4. 當Alice收到消息時,她將使用她Alice的私鑰對其進行解密。沒有其他收件人可以解密消息,因為只有Alice知道Alice的私鑰。

圖 2.6a 的方案旨在提供機密性(confidential)

圖 2.6b 的方案旨在提供身份驗證(authentication)和/或數據完整性(data Integrity)

Application for Public-Key Cryptosystems (公鑰加密系統的應用)

  1. 數位簽名
  2. 對稱密鑰分發
  3. 秘密密鑰
Algorithm Digital Signature Symmetric Key Distribution Encryption of Secret Keys
RSA Yes Yes Yes
Diffie–Hellman No Yes No
DSS Yes No No
Elliptic Curve Yes Yes Yes

Requirements for Public-Key Cryptosystems(公鑰加密的要求)

2.4 Digital Signatures and Key Management

Digital Signature

the use of one of three digital signature(FIPS 186-4):

步驟:

  1. Bob 使用安全 Hash_func(message) ➝ hash value。
  2. Bob 使用自己的 Digital_signature_gen_func(bob_private key , hash value)➝ Bob’s Signature。
  3. Bob 將帶有簽名的消息(Message+Bob’s Signature)發送給 Alice。
  4. Alice 收到帶有signature 的message後,使用 Bob 的 public key 驗證 signature。
    1. 計算該 Message 的 hash value
    2. hash valueBob 的 public key 作為 Digital Signature Verification 的輸入。
  5. 如果簽名有效,則 Alice 可以確信該消息一定是 Bob 簽署的,並且沒有被篡改。

Public-Key Certificates

key steps

1. User software (client) creates a pair of keys: one public and one private.

2. Client prepares an unsigned certificate that includes the user ID and user’s

public key.

3. User provides the unsigned certificate to a CA in some secure manner. This might

require a face-to-face meeting, the use of registered e-mail, or happen via a Web

form with e-mail verification.

4. CA creates a signature as follows:

a. CA uses a hash function to calculate the hash code of the unsigned certificate. A hash function is one that maps a variable-length data block or message into a fixed-length value called a hash code, such as SHA family that we will discuss in Sections 2.2 and 21.1.

b. CA generates digital signature using the CA’s private key and a signature generation algorithm.

5. CA attaches the signature to the unsigned certificate to create a signed certificate.

6. CA returns the signed certificate to client.

7. Client may provide the signed certificate to any other user.

8. Any user may verify that the certificate is valid as follows:

a. User calculates the hash code of certificate (not including signature).

b. User verifies digital signature using CA’s public key and the signature verification algorithm. The algorithm returns a result of either signature valid or invalid.

Symmetric Key Exchange Using Public-Key Encryption

使用對稱加密時,雙方安全通信的一個基本要求是共享一個秘密密鑰。假設 Bob 想要創建一個消息應用程序,使他能夠與任何有權訪問 Internet 或他們共享的其他網絡的人安全地交換電子郵件。假設 Bob 想使用對稱加密來做到這一點。

一種方法是使用 Diffie-Hellman 密鑰交換。這種方法確實被廣泛使用。但是,它在最簡單的形式下存在一個缺點,即 Diffie-Hellman 不提供兩個通信方身份驗證。有克服此問題的 Diffie-Hellman 變體。此外,還有使用其他公鑰算法的協議可以實現相同的目標。

Digital Envelopes(數位信封)

假設 Bob 想向 Alice 發送保密消息,但他們沒有共享對稱秘密密鑰:

  1. 準備Message。
  2. 生成一個只用一次的隨機 symmetric key。
  3. 使用one-time key使用 symmetric key 加密該Message。
  4. 使用 Alice 的公鑰使用 public-key encryption 加密 one-time key。
  5. 將加密的一次性密鑰附加到加密的消息上並將其發送給 Alice。

只有 Alice 能夠解密一次性密鑰,因此能夠恢復原始消息。如果 Bob 通過 Alice 的公鑰證書獲取了 Alice 的公鑰,那麼 Bob 可以確定它是一個有效的密鑰。

2.5 Random and Pseudorandom Numbers

The Use of Random Numbers

Random vs. Pseudorandom

###