# 資安導論期中題庫
### What is the main difference between HASH and MAC? A MAC based on HASH is called HMAC. Please show the formula of HMAC or draw the structure of HMAC.
>Hash與MAC有何主要差異?以Hash為主的MAC稱為HMAC,請列出HMAC的式子或畫出其架構
Hash 只是單純將任意長度的資料輸出成固定長度,但 MAC 除了 Hash 的特性外還另外有一把私鑰,私鑰雙方持有可以驗證訊息的完整性


### What are the purposes of message digest algorithms, such as MD5, SHA? Give three kinds of uses.
>訊息摘要演算法,例如MD5與SHA,可以拿來作何用途?請舉三例
確保訊息完整性
檔案校驗
儲存不需要還原的資料
### What is the RSA’s security based on? ECC’s security based on? Explain them.
>RSA的安全性是基於甚麼性質? ECC的安全性又是基於甚麼性質?
RSA:大數因數分解
ECC:EC橢圖曲線上離散對數
### Please list at least five requirements of a secure Hash Function.
>訊息摘要演算法必須滿足若干條件,請列舉其中5項
1. 可以用在任何長度的資料
2. 可以產生固定長度的輸出
3. 輸出無法回推輸入
4. 無法找到一對 (x,y) 使得 Hash(x) = Hash(y)
5. 給任意 x,Hash(x) 都很好算
6. Hash 的輸出須滿足標準偽隨機測試
### Supposedly a message can be divided into L blocks in MD5 algorithm. What do CV0, CVq, and CVL mean, respectively?
>在MD5演算法中假設訊息可以被分為L塊,請問CV0, CVq, and CVL各代表甚麼意義?
CV0:初始向量
CVq:是 $Y_0 +Y_1+...+Y_{q-1}$ 的摘要
CVL:整個訊息的摘要
### Describe how to generate a pair of public key and private key in RSA algorithm?
>說明如何產生RSA的一對公私鑰
1. 隨意選擇兩個大的質數${\displaystyle p}$和${\displaystyle q}$,${\displaystyle p}$不等於${\displaystyle q}$,計算${\displaystyle N=pq}$
1. 根據歐拉函數,求得${\displaystyle r=\varphi (N)=\varphi (p)\times \varphi (q)=(p-1)(q-1)}$
1. 選擇一個小於${\displaystyle r}$的整數${\displaystyle e}$,使${\displaystyle e}$與${\displaystyle r}$互質。並求得${\displaystyle e}$關於${\displaystyle r}$的模反元素,命名為${\displaystyle d}$(求${\displaystyle d}$令${\displaystyle ed\equiv 1{\pmod {r}}}{\displaystyle ed\equiv 1{\pmod {r}}}$)。(模反元素存在,若且唯若${\displaystyle e}$與${\displaystyle r}$互質)
1. 將${\displaystyle p}$和${\displaystyle q}$的記錄銷毀。
### In RSA algorithm, why do we need the constraint “M<n” where M is the message and n is the system parameter?(If remove the constraint, what happens)
>RSA中為何需要有“M<n”的限制?
如果沒有這樣的約束(M < n),那麼不同的 M 可以產生相同的餘數(密文)。 這意味著當你做解密時,你不知道哪一個是明文
### How does RSA work with DES to encrypt a large message?
>RSA如何跟傳統加密法DES合作,以加密一個很大檔案
用RSA加密DES的金鑰,然後用DES來加密檔案
### Find the multiplicative inverse of 45 mod 238.
>找出45的乘法反元素, 模數是238

### Perform encryption and decryption using the RSA algorithm for the following:
p = 7, q = 11, e = 13, M = 5
>說明如何執行RSA加密與解密

### How can RSA be applied to do digital signatures?
>如何利用RSA來做簽章?
到目前為止,我們使用 RSA 進行加密/解密。
但是,也可以應用 RSA 來簽署文件(e.g 數位簽名)
傳送端用私鑰簽章後傳送,接收端用傳送端的公鑰來解密,確認是否是本人傳送的
### 試算7^1998^ mod 5 = ?
$7^4 mod5 = 1 =>7^{1998}=(({7^4})^{499}\times7^2) mod5 = 4$
### How to let sender get the recipient’s public key?
>如何讓傳送端知道接收端的公鑰?以便可以進行加密運算以保護機密
公鑰會被放入證書中,透過 SSL/TLS 傳給發送者
### Using the following formula, let P = (1, 7) and Q = (3, 10) in E~23~(1, 1).
(a) What is P+Q?
(b) What is 2Q? //hint:2Q=Q+Q
>使用下面公式計算 (a) P+Q 之座標 (b) 2Q之座標 //提示: 2Q=Q+Q


好
### This problem performs elliptic curve encryption/decryption. The cryptosystem parameters are E~11~(1, 6) and G = (2, 7). Alice’s private key is n~A~ = 7. (Sender: Bob, Receiver: Alice)(ECC加解密)
a. Find Alice’s public key $P_A$.
b. Bob wishes to encrypt the message $P_m$ = (10, 9) and chooses the random value k = 3 Determine the ciphertext $C_m$.
c. Show the calculation by which Alice recovers Pm from $C_m$.
7G=G+G+G+G+G+G+G(代橢圓曲線公式)
所有加減乘都代上一題的公式
