[密碼學複習]Cryptography
整合
Week 2對稱加密
Two requirements:
- A strong encryption algorithm
- A secret key known only to participants.
1. 有三部分構成:
1.加密演算法
2.可能使用的金鑰數量:數量越大越安全
3.text文字的處理:分為stream ciphers整段傳輸和block ciphers, 將文字切成固定塊大小傳輸
2. 密碼攻擊有以下幾種:
Ciphertext only, Known plaintext, Chosen plaintext, Chosen ciphertext, Chosen text:

已知明文攻擊指的是攻擊者獲取到的明密文對。
而選擇明文攻擊指的是攻擊者可以通過某種手段往其中加入指定明文並由此獲取指定密文。
選擇密文和選擇文字很少見,所以書上沒有過多介紹
3. Two important definitions are interesting on which much of the cryptologic research of modern times are based. 兩個現代密碼學研究的基礎
也就是說密碼學必須建立在這兩個其中之一條件之上:
• Unconditional Security (Shannon): The security of the cipher is independent of the computing resource available to the adversaries. 不管對手擁有的計算資源有多強大都無法破解
• Computational Security (Turing): Adversaries are provided with constrained computing resources and the security of the cipher determined by the size of the computations required to break the cipher.為對手提供了受限制的計算資源,並且密碼的安全性由破解密碼所需的計算大小確定。
4. Classical Ciphers
4.1 Substitution Ciphers 代替技術
Here plaintext symbols are substituted or replaced with other symbols
using an unknown key. The substitutions can be performed as sequence of symbols or symbol by symbol. 簡單來說就是把當前的字元固定的換成另一個字元
4.1.1 Caser Cipher
最簡單的加密技術,給定一個k,把當前字元(所在位置為i)變成i+k個位置的字元。比如k=3,a的i=1,那麼i+k=4,所以a就變成d。
這裡其實E(k, p) => (c = p + k) mod 26
所以直接變換(p = c - k) mod 26 => D(k, p)
key space(金鑰取值範圍)為1~25,因為0就是明文自己,所以不算
Affine Cipher
Caser Cipher的升級版
Encryption: E(k,p) = c = ap + b mod m
Decryption: D(k,p) = a-1(c – b) mod m
⚠️這裡的要點是a和m需要互為質數,b的取值範圍為[0, m-1]或[1, m],因為取0和取m模出來都是0
舉兩個例子,如果m=26,也就是說對應的表為26字母表,那麼a的取值範圍為[1, 25],b為[0, 25],所以key space = 25 * 26
如果m=36,也就是說對應的表為26字母表,那麼a的取值範圍為{1,5,7,11,13,17,19,23,25,29,31,35},因為需要互質,b為[0, 35],所以key space = 12 * 36
這裡引入一個概念叫trival。如果說trival的話就是p不管取什麼,c恆等於p。所以如果a=1, b=0那麼c=p。non-trivial就是總數-trival
Monalphabetic Cipher
更簡單暴力,直接把每一個字母隨機對應到不同的字母(可以是自身)。
所以possible keys = 26!
雖然看起來很安全,因為brute-force很難破解,但是其實Language statistics可以作為一種分析方式。分析每個字元的使用頻率來計算
4.2 Transposition Ciphers 置換技術
Here plaintexts are organized as a sequence of plaintext blocks and symbol positions in each block are permuted or transposed using a key. The same permutation is used for every block. 在這裡,純文字被組織為一系列的純文字塊,並且每個塊中的符號位置使用鍵進行置換或轉置。 每個塊使用相同的排列。更通俗一點說,它區別於代替技術,它是直接將明文打散,通過複雜排列進行重新組合
一個例子:Row transposition cipher
plaintext: attackpostponeduntiltwoamxyz
簡單來說它就是先把明文一行一行地寫成矩陣塊,然後打亂列的序號,根據序號從1開始,按列從上到下的順序依次讀取字元拼成新的密文。且可以多次加密。
4.3 Complex Ciphers - Polyalphabetic Cipher
Vigenère Cipher
假設plaintext P的長度是n,他會先隨機定義一個d,然後對應每一個index i(i屬於n)獲得Ki = i mod d。然後使用Caser Cipher獲得
Encryption:E(K,P) = C, where ci = pi + ki mod 26
Decrypton: D(K,C) = P, where pi = ci - ki mod 26
d越大越安全。以下是一個例子:
Week 3
Modern Symmetric Ciphers
主要分成兩種,流加密和塊加密
1. One Time Pad
首先我們回顧一下Vigenère Cipher
假設plaintext P的長度是n,他會先隨機定義一個d,然後對應每一個index i(i屬於n)獲得Ki = i mod d。然後使用Caser Cipher獲得
Encryption:E(K,P) = C, where ci = pi + ki mod 26
Decrypton: D(K,C) = P, where pi = ci - ki mod 26
d越大越安全。以下是一個例子:
One time pad其實就是這種cipher的特殊例子,就是當n=d的時候就是one time pad,也叫Vernam。(n是plaintext長度,d是key的長度)
在這裡其實就是用XOR來加密解密。
Plaintext ⊕ Key = CipherText
CipherText ⊕ Key = Plaintext
Perfect Secrecy
• An encryption scheme has the property of unconditional security if the cipher text generated by the algorithm does not reveal sufficient information to break the scheme, even with access to an unlimited amount of computational power.
• In other words, the adversary cannot not obtain any knowledge to reverse the encryption by watching any amount of cipher text without access to the key.
It implies: Pr[M = x|C = y] = Pr[M = x]
也可以寫成PX|Y(x|y) = PX(x) 大致意思就是,哪怕給定了另一個條件Y,也不會改變/影響原來X的概率
One time pad其實不太practical,因為要保證key的絕對安全。但是two time pad就不夠安全,因為
• C1=M1 ⊕ K; C2= M2 ⊕ K; then
• C1 ⊕ C2=M1 ⊕ M2 ⊕ K ⊕ K= M1 ⊕ M2.
Even though M1 ⊕ M2 may not direct meaning, it still leaks information about both M1 and M2.
Block Cipher
Fiestel Block Cipher
首先要了解這是一種密碼結構,很多演算法都在用這種結構,包括DES
首先會傳入一個長度為2w的明文(2的倍數)和一個金鑰Key。接下來會決定產生輪次round,圖中輪次為16(DES一般就是16)。然後根據傳入的key用特殊或者自制演算法計算出子key{key1, key2, …, key16}。這些子key和原key沒啥直接關係。接下來就是如圖,每一輪,讓右邊part R完全不做處理,直接放在下一輪的L。然後輸入keyi和右邊部分進函式F獲得result,讓左邊part L和result XOR得到下一輪的R。
所以說Fiestel主要強度來自於:1.F函式強度,2.輪數,3.生成子key的演算法的強度
DES
DES演算法的相關引數如下:
明文分組長度:64 bits,左右各32 bits
金鑰長度:64 bits
輪數:16輪
3DES
首先先說一下2DES在本質上並沒有比DES安全多少,所以能破解DES大概率也能破解2DES。但是3DES如果在三個過程中使用的key都不一樣的話,那麼金鑰長度可以被認為是192(64*3)位。同時為什麼採用加密-解密-加密的模式是因為首先如果3個key都不相同,那麼這種方式其實和加密-加密-加密的模式得出來的加密效果是一樣的。但是如果3個key一樣,又可以向下相容,變成DES模式。
幾種分組密碼的工作模式
1. ECB
這種模式就是簡單粗暴,把密碼分成一塊一塊,每一塊單獨做加密。這種模式適用於少量文字,比如加密金鑰。比如加密DES和AES的Key
2. CBC
CFB就是上一塊的結果會作為下一塊加密的引數。因此一個bit出問題會propogate,影響很大,但是也只對該bit位造成影響,因為是異或。同時也不能並行操作,因為需要之前的結果。
3. CFB
CFB可以進行並行操作,原理有點像流密碼。是因為它的操作原理是這樣的,首先生成一個和整個明文一樣size的IV。接下來每次從最左側取塊密碼size s的大小來和P XOR。XOR之後將整個IV向左移動s,並在尾部,也就是右邊插入剛剛得到的C。每次都取IV最左邊操作。可以並行操作的原因是,知道固定size s,那麼將整個IV平分,並在相應位置填入C即可。填入C的原因是把這個用C填充的Key作為解密的IV,這樣很方便。
4. OFB
這裡我其實一開始不太明白為什麼是公式裡Ci需要用到Ci-1和Pi-1。但是其實跟這兩個無關。因為我想要的是某個值X,這個X XOR Pi-1 = Ci-1那麼兩邊同時XOR一個 Pi-1可以得到X = Pi-1 XOR Ci-1,得到公式式子。
優點是容錯高,明文C在傳輸過程中發生的錯誤不會在加密過程中向後傳播
5. CTR
我個人感覺應該不會考。他的概念大致就是首先定一個計數器,和明文分組有同樣長度的規模。首先第一個計數器被初始化成為一個值,過了固定時間會加一(或者其他的計數器操作),然後進行加密,最後進行XOR
Week 4 - Public Key Protocol: Diffie-Hellman and RSA
1. DH Protocol
這是一種交換金鑰的演算法。同時DH加密演算法是建立在一個fact之上:計算離散對數是一件非常困難的是,也就是已知ai = b mod n也難以計算出i。同時要保證這個a夠大
在這幅圖中Alice首先自己建立了一個g,一個n,還有一個Na,通過公示gNa mod n = Ma計算出Ma。(圖中n=10)接下來Alice將g, n, Ma都傳送給Bob,然後Bob隨機選擇一個Nb,用公式gNb mod n = Mb計算出Mb,然後把Mb發回給Alice。(注意這裡Na和Nb都只有各自知道)。接下來兩個人可以得到一個共有的Key = MbNa = MaNb,然後可以開始愉快的通訊了。
但是這種通訊因為沒有signature所以很容易被Man-in-the-middle攻擊。如下圖,中間人Malice可以擷取然後跟他們通訊,得到各自資訊,並且也可以封裝發給自己,讓他們以為在正常通訊。
所以接下來就需要著名的升級版演算法RSA
2. RSA
一個概念: A cryptosystem is a five-tuple ( P,C,K,E,D).
- P: Plaintext
- C: Ciphertext
- K: the space of keys, a finite set of possible keys; 這裡麵包括 (n, p, q , e, d),在下面使用RSA的時候會介紹
- E: Encryption function
- D: Decryption func
RSA的做法很簡單,如下圖:注意這裡面的p和q是nearly impossible破解出來的(當n非常大), factorization problem是非常難得問題
非對稱加密的常見攻擊有三種:
1. Chosen-plaintext attack(CPA) 就是攻擊者獲得了加密演算法,public key,所以攻擊者可以自己輸入plaintext去獲得ciphertext
2. Chosen-ciphertext attack(CCA)
• Decryption box is available to the attacker before the attack.
3. Adaptive Chosen-ciphertext attack(CCA2)
Decryption box is available to the attacker except for the
challenged ciphertext.
• Here attacker can obtain plaintexts corresponding any chosen
ciphertexts. This means the attacker gets decryption assistance for
any chosen ciphertext. The goal for the attacker is to obtain any
part of the plaintext after the decryption assistance is terminated.
Week 5- RSA Digital Signature
一般public key都存在於權威第三方機構,因此要確保請求的Public Key是準確的,所以會用到簽名。一般對於RSA來說有Ciphertext = RF(PU, Message) /RF=RSA Function/ (使用Public key加密message), Message = RF(PR, Ciphertext)。 因為RSA使用的是指數函式的方法加密解密,所以加密解密的方法可以說是都一樣的。
非常注意!!這裡是使用Private Key去加密Message來獲得Signature!!!然後用Public key來解密signature,如果Se=Message - 1⃣️。這是因為S=Md,Mde=Med=M。所以1⃣️成立就說明是有效signature。
對於Signature來說,演算法變更為:
Ciphertext = RF(PU, Message, Sig), 其中Sig需要等於RF(PR, Message)
所以要判斷Sig =? RF(PR, Message), 同時演算法在解密的時候會提供一個additional output = 1 or 0作為判斷結果。如果是1說明解密成功,0表示解密失敗。
**這裡主要一點!!!Sig是用來給B看的!**比如A產生訊息Ciphertext = RF(PU, Message, Sig),B獲得以後解密得到Message和Sig,然後B計算SigPublic key = Message,可以證明是A發來的。這裡不是像我之前想象的還要發回給A,而是給B看,讓他Verify這是A發來的!
1st version of RSA
給出5個要素:
- Ciphertext: S
- Plaintext: M
- Public Part: Public Key: e, So large number N=e*d
- Private Part: Private Key: d
- Signature = Md,然後在private key解開以後計算Se ?= M,只有等於才說明簽名正確,來自於正確獲取源。
但是這個版本的RSA其中一個問題就是: 訊息(M1 * M2)d = M1d * M2d = Sig1 * Sig2. 所以這樣就會可能導致簽名的偽造 forgery of signature!
Blinding
這是一種1st RSA的攻擊,比如攻擊者想要偽造一個A暫時還不想簽名的簽名SigA
- 選擇一個隨機數,位於[0, … N-1] N在上面有,是mod N
- 建立blinded message Mb = xe M mod N
- 假設A想簽名Mb,於是會獲得SigAb = Mbd mod N
- 這時候問題出現了,由於RSA multiplicative property, 因為現在可以計算出SigA了。
SigA = SigAb / x mod N
這是因為SigA = Md mod N, SigAb = (xe * M)d mod N = xed * Md mod N,根據RSA性質,xed mod N = x。所以我們有SigA = SigAb / x mod N - 那麼SigAe = (SigAb / x)e = (Mb)de / xe = (Mb) / xe = Mxe / xe = M,這樣就導致了偽造!
2nd version of RSA
這種方法其實就是在方法1的基礎上做一個升級,Sig不再是直接通過Private Key去加密Message來獲得,而是兩方都要有一個 redundancy function,R。
首先先計算出M1 = R(M), Sig = M1d。Func R會讓M和M1變得相對無關,這樣子就沒辦法偽造簽名了。但是難點在於要讓兩方都知曉這個Func R。
RSA signature in practice
• 前面說的兩個issue,一個是Blinding,一個是在1st結尾提到的multiplicative property導致的forgery of signature
• Messages are generally long.
• RSA signature scheme needs a redundancy function to avoid existential forgery attacks.
• Also repeated messages carry same signature.
3rd version of RSA
對Func R的優化,這裡使用的是Hash Function替代Function Redundancy
Securicy of RSA
• Brute force Attack: (infeasible given size of numbers)
• Attack by making use of loopholes in Key distribution.
• Mathematical attacks (Factoring and RSA problem) 在d,e夠大的情況下數學攻擊和因式分解基本不可能,ppt. 有
• Elementary attacks 這個攻擊的主要問題是:首先ed = 1 mod Φ(n)這個難度堪比factoring,但是最重要的問題是所有人都用這一套,所以如果有所記錄e和d,那麼記錄非常多的使用者使用的ed可以推出來將來使用者的ed
• Advanced Factorization methods
• Network attacks
• Broadcast problem 這個攻擊的問題是一個group of entities可能會用同一個public key with different modulo N。一般PU都比較小,比如是e=3,那麼給一個group中的3個entities:
• c1 = m3 (mod n1)
• c2 = m3 (mod n2)
• c3 = m3 (mod n3).
• x = c1 (mod n1),
• x = c2 (mod n2),
• x = c3 (mod n3),
• You can use CRT and Then obtain an unique
• x=m3 modulo n1 n2 n3
• m can then be obtained by taking the cube root of x. Finding a cube root in integers is not a hard problem.
CCA Chosen Cipher Attack ?這裡怪怪的,如果我是可以隨便選擇密文的話,那不是直接就可以求得M嗎?如果我不能直接選擇密文,那怎麼解密X?
基本的RSA演算法易受選擇密文攻擊(CCA)。**注意,選擇密文攻擊是隻能獲得部分密文的明文!**進行CCA攻擊時,攻擊者選擇一些密文,並獲得相應的明文,這些明文是利用目標物件的私鑰解密獲得的。因此,攻擊者可以選擇一個明文,運用目標物件的公鑰加密,然後再用目標物件的私鑰解密而取回明文。顯然,這麼做並沒有給攻擊者任何新的資訊。可是攻擊者可以利用RSA的性質,選擇資料塊使得當用目標物件的私鑰處理時,產生密碼分析所需要的資訊。
例如利用CCA可以解密C = Me mod n
Step1: 計算X = (C * 2e) mod n
Step2:
Timing Attacks
這種攻擊是通過計時來求得的。把陣列當作二進位制來看的話,因為在計算模乘運算的時候如果該位置是1,時間上比0要慢,通過這種方法來模擬出ciphertext。
常見的解決方法有:
• Constant time: One way is to make sure that your algorithm takes a
constant time for all inputs. This approach requires you to estimate the
longest delay in advance and use appropriate idle time when results take
less than the worst case time. However, this method may still leak power
profile. In general performance decreases in efficiency. 不管輸入多長,輸出的時間保持一致
• Random delay: You will add a random delay to algorithm execution to
ensures that the relationship between key and the execution time is
uncorrelated. 給定計算時候一個隨機延遲,讓攻擊者計時不問
• Blinding: You can use the blinding technique introduced earlier. With this,
the algorithm takes a random amount time and assures that the relationship
between key and the execution time is uncorrelated.通過blinding的方法讓計算模運算前先乘上一個隨機數,打亂計算時間
Week 6- Hash Functions
Introduction
It’s different from what we used in program language. In general, the function takes a variable-length data block as input and produces a fixed
length tag or digest satisfying certain properties.將任意長度的輸入輸出成相同長度或者滿足特定屬性
The main objective is to obtain data integrity.
• It is referred as unkeyed primitive as does not require any key.
• As assumed in the other cryptographic functions, the definition of Hash function is also public.
• Hash is also referred to as message digest.
Integrity for Hash Function
Modification Detection Codes (MDC).
• The function Hash has a property that a small change in the message introduces unpredictable changes in the hash value, h = Hash (M).意思就是相差很小的兩個值經過hash function也會有巨大的變化
• If a message is changed while in transit, then running Hash function at the received message tells you how the value is deviated from the hash value computed at the source, thus assuring integrity with high probability.所以如果用hash function作為簽名的話,可以判斷訊息是否被篡改
Modification of Attacker (Active Setting)
攻擊者Malice整個修改資訊,把M變成M’,並且用M’生成簽名的話,Bob會以為A發的訊息其實是M’
注意一點,Hash Function是沒有authentication的,因為他是totally public的!
解決上述問題的一些方法
- 使用對稱加密演算法對(Message, H(Message))同時加密
- 只對H(Message)進行對稱加密
- 不使用加密演算法,而是要求雙方同時擁有一個共享祕密值S,對S和Message一起用Hash,H(M || S),從而起到驗證的效果
- 在3的基礎上,對整個資訊加密E(Key, [M || H(M || S)]),這樣做可以在3的基礎上增加保密性。
Comparison:
方案b比起a,d 需要計算的量比較少,這裡給出幾個方案b的優點:
- 加密軟體速度慢 2. 加密硬體成本高 3. 加密硬體一般是針對大資料做的優化,因此針對小資料的話大部分時間會浪費在初始化和呼叫上 4.加密演算法可能需要支付專利費
Digital Signature
圖(a),簽名不再是像簡單RSA那樣直接用PR對M進行加密生成,而是用PR對H(M)加密生成
圖(b), 則是在圖A基礎上再對整個訊息用公鑰進行一次加密,加強保密性
Hash Function Requirement
**最主要三大安全特性:PR (Preimage Resistance), 2nd PR (Second Preimage Resistance), CR (Collision Resistance): **
Attacks on Hash Function
The function should resist brute-force attacks and regular cryptanalysis.
中文論證請參考教材p246-247
brute-force attacks:
• Attack against PR: Given a random hash value, determine y such that H(y)
equals to the hash value. 假設hash長度為m,那麼嘗試次數為2m-1
• Attack against CR(使用了Birthday attack theory): The task is to determine any two messages whose hashes are same, i.e determine x, y such that H(x) = H(y). 假設hash長度為m,那麼嘗試次數為2m/2
Message Authentication(我們一直以來探討的問題)
Let us look at message authentication issue in practice.
• What is it concerned with?
– To address message authentication
– A dedicated primitive based on symmetric key cryptography
• Issues for message authentication
– Message integrity
– Validation of originator’s identity
– Non-repudiation of the message origin
• Three ways of achieving authentication
– Message Encryption
– Hash functions (we looked at it in the previous lecture)
– Message Authentication Code (MAC) (this lecture)
Security Requirement
– disclosure
– traffic analysis
– masquerade
– content modification
– sequence modification
– timing modification
– source repudiation
– destination repudiation
MAC(Message Authentication Codes)
• So formally, MAC is a dedicated symmetric key primitive aimed at providing authentication.
• With encryption it can be easily integrated to provide secrecy also.
• They are useful when in some applications you only need authentication.
• There are many situation where the property of authentication requires longer than confidentiality: authenticated sessions where only at times you may exchange secret information.
• MAC is different to Signatures, MAC has many properties similar to Hash.
Properties:
• mac:= MAC(Key, message).
• You can treat it as a cryptographic checksum/digest: It takes a arbitrary
length message as input and outputs a fixed length authenticator using a
key.
• Like hash functions, it is many-to-one function with Preimage resistance
(PR).
• For every key, it satisfies hash function properties.
• So sometimes, MAC is referred to as a family of Hash functions.
首先明確一點,MAC一般也是用來做authentication的。MAC需要傳送方A和接收方B共享一個金鑰,使用專有的MAC Function- C(…)來建立MAC,
方程式形如:MAC = C(K, M)
MAC- Message Authentication Codes, C- MAC Function, K- Secret Key, M- Message, 在slides上,寫作F(M),MAC Function變成F,且少了Key
MAC函式與加密方法類似,但是最大的區別是MAC函式要求不可逆,也就是知道MAC也不知道明文,加密演算法則是可以解密的。所以MAC採用的是對映多對一的情況。也就是說多個明文對應一個MAC。但是MAC的基數要求足夠大,這樣子的話attacker也做不到輕易破解。
常用的方法如下:
- 直接加一個MAC(這種方法基本不用,因為明文都是直接暴露的)
- 對M, MAC在進行一次對稱加密,也被叫做Internal Error Control
- 明文部分用對稱加密加密,MAC=對用對稱加密的密文再進行一次MAC加密得到MAC,也被叫做External Error Control
Attack on MAC
• Brute-force attack: Here the objective is to find a collision.
• For cryptanalysis, there are two approaches:
• Attacker may first determine the key, then he can produce MAC value for any message.
• Sometimes, he may just try to determine a valid tag for a given message.
• Similar to Hash functions, you realize that MAC has to have a certain length to defeat brute-force attacks.
• In general you try to create new MAC functions using existing Hash functions.
Week 7- Key Management
Key Management的介紹
NS介紹
Week 8- Public Key Distribution
Stallings discusses four important methods:
– Through Public announcement
– By Using publicly available directory
– With Public-key authority
– Using Public-key certificates
Public announcement(Uncontrilled Public Key Distribution)
這種分法方式就是直接讓個人無控制的向外分法自己的Public Key,誰請求都發。這樣子做有一個最大的問題就是所有人都可以獲得A的PU,因此別人可以冒充A,向別人傳送PUa,直到A發現冒充者並且廣播通知其他人之前,冒充者都可以獲取本應該向A傳送的加密檔案,甚至可以用偽造的金鑰進行認證
By Using publicly available directory
A directory service is established, each user contacts the directory through secure methods and places his public address to be downloaded by other users. 公鑰目錄通過{名字,PU}的鍵值對方式儲存
Each user can update his public key and details. Because public key has been used for multiple times or private key is leaked.
Security is better than the previous method, but still vulnerable. 如果攻擊者獲取到了目錄管理者的金鑰,那麼他可以假冒任何通訊方。此外還有一種攻擊方式是通過修改目錄管理員記錄來竊取傳送給通訊方的資料。
With Public-key authority
This method is a further improvement to the directory service. It has following properties:
• The authority server is always online with tight control over the distribution and maintenance of keys.
• Authority also has a public and private key: <PUauth ,PRauth >
• Users will contact the authority whenever they need key service.
• Issues:
– Server needs to be online always.
– Still there is a possibility of tampering and attacks. 最大的問題就是怕目錄記錄被篡改
(1) A傳送一條帶有時間戳的訊息給公鑰管理員,以請求B的當前公鑰。
(2) 管理員給A傳送一條用其私鑰PRaulh加密的訊息,這樣A就可用管理員的公鑰對接收到的訊息解密,因此A可以確信該訊息來自管理員。這條訊息包含以下內容:
• B的公鑰PUA,A用來加密發給B的訊息。
•原始請求,這樣A可以將該請求與其最初發出的請求進行比較,以確保在管理員收到請求之前,其原始請求未被修改。
•原先的時間戳,A可以確定它收到的不是來自管理員的舊訊息。
(3) 儲存B的公鑰,並用它去加密包含A的身份標誌符ID,和臨時互動號N1的訊息傳送給B,
其中N1為該次互動的唯一標誌。
(4, 5)與A檢索B的公鑰一樣,B使用同樣的方法從管理員處得到A的公鑰。
此時,公鑰已被安全地傳遞給A和B,A、B之間的資訊交換將會受到保護,儘管如此,最好
還包含以下兩步:
(6) B用A的公鑰PUa加密包含A的臨時互動號N1,和B新產生的臨時互動號N2的訊息,併傳送給A。因為只有B能解密訊息(3),所以訊息(6)中的N1可以使A確信該訊息來自於B。
(7) A用B的公鑰加密包含N2的訊息給B,這樣B就可以知道該訊息來自於A。
這樣,總共需要7條訊息,然而,前面的4條訊息不會被頻繁使用,因為A、B可以儲存彼此
的公鑰以備將來之需。使用者需要週期性的請求當前公鑰資訊,以保證通訊中使用的是當前的
公鑰。
Using Public-key certificates
這種方法是最複雜的一種,和上述都有點不太一樣。
首先A和B使用自己的公鑰傳送給Certificate Authority,這個權威機構一般是政府或者金融部門的機構,並且傳送過程嚴謹且安全。之後權威機構返回給他們各自的Certification = E(PRauth, [T || ID || PU])。這裡是用權威機構的私鑰去加密,裡面包含了一個時間戳(作用是告知證書過期時間,如果過期了就說明這是個廢的,哪怕有人盜取也無所謂),傳送者的ID標識,傳送者的PU。然後兩方互動的時候使用權威機構的PU進行解密,因此安全性也很強。
Advantages
最大的優點就是可以通過使用權威機構的公鑰來進行驗證判斷訊息是否valid
X.509 Certificate
Version
Serial number
Signature algorithm identifier
Issuer name
Period of validity
Subject name
Subject’s public- key information
Issuer unique identifier
Subject unique identifier
Extensions
Signature
The standard notation for a certificate of:
CA<< A >> = CA {V, SN, AI, CA, UCA, A, UA, Ap, TA}.
• with the meaning CA signs the certificate for user A with its private key.
Week 9- ElGamal Signature
理解一下概念:素根
取一個數n,對於n來說所有跟他相對互質的數有一個集合S。假設存在一個數a,如果ax mod n(0<x<=q-1)可以等於所有集合S內的數,則稱a為素根
An essential idea
• Idea:If x’= (x1+ x2) mod (q-1), (ax1) and (ax2) are given by a user, without revealing x1 and x2,
• then this can be verified by checking the following equation
• ax’ = (ax1) (ax2) mod (q)
• Note that , only the person who knows x1 and x2 could have
constructed this sequence: x’ , (ax1) and (ax2).
• Next, we give the ElGamal Signature idea.
ElGamal
注意本章主要內容是使用私鑰進行加密,公鑰進行解密,因為是簽名。這一部應該是告知B,A收到了吧,不然B怎麼會有m?
計算過程
- 根據題目選擇q, α, m(m = H(M)),並隨機選擇1 < XA < q-1
- 計算YA = aXA mod q
- 公佈public part {q, a, YA},private part為XA
- B方隨機選擇一個K,這個K需要relative prime to q-1,並且計算K-1K mod q-1 = 1
- 計算S1 = aK mod q, S2 = K-1(m - XAS1) mod q-1,現在就有了簽名訊息{S1, S2}
- Verification: V1 = am mod q
- V2 = (YA)S1 * (S1)S2 mod q
- V1=V1 valid
B傳輸資訊給A:
Week 11- User Authentication
知識點
- Remote User-Authentication principles
- Means of Authentication
- Mutual Authentication Protocols
- Replay Attacks. – Protocols Remote User Authentication
- Needham-Schroeder (NS) Protocol
- Denning’s modification
- Neuman’s modifications
1. Remote User-Authentication principles
Authentication is a fundamental building block of a networkbased computer systems. And there are 2 important steps.
1.1 Identification step: Presenting an identifier to the security system.
(Identifiers should be assigned carefully, because authenticated
identities are the basis for other security services, such as access
control service.)
1.2 Verification step: Presenting or generating authentication
information that corroborates the binding between the entity and the
identifier.
• Note that user authentication is different from message authentication.
Example: user ID and password;
4 Means of Authentication
- Something the individual knows: Examples:a password, a personal
identification number (PIN), or answers to a prearranged set of questions.
知道什麼,如口令,PIN - Something the individual possesses: Examples: cryptographic keys,
electronic keycards, smart cards, and physical keys. This type of
authenticator is referred to as a token. 擁有什麼:如私鑰,電子密碼卡 - Something the individual is (static biometrics): Examples: Recognition
by fingerprint, retina, and face. 靜態生物特徵:如指紋,視網膜,臉 - Something the individual does (dynamic biometrics): Examples:
recognition by voice pattern, handwriting characteristics, and typing
rhythm. 動態生物特徵:如聲音,手寫特徵
2 types protocols: One-way/ Mutual
Main problem that these protocols solve is to address the two important issues:
- Confidentiality: the exchanged session keys are protected.
- Timeliness(合時): Ensure that the exchange is current and prevent replay attacks.
Mutual Authentication
Timeliness
- Important because of the threat of message replays
- Such replays could allow an opponent to:
- compromise a session key
- successfully impersonate another party
- disrupt operations by presenting parties with messages that appear genuine but are not
Confidentiality
- Essential identification and session-key information must be communicated in encrypted form
- This requires the prior existence of secret or public keys that can be used for this purpose
Replay Attack
- copies a message and replays it later
- An opponent can replay a timestamped message within the valid time
window - An opponent can replay a timestamped message within the valid time
window, but in addition, the opponent suppresses the original
message; thus, the repetition cannot be detected - Another attack involves a backward replay without modification and
is possible if symmetric encryption is used and the sender cannot easily recognize the difference between messages sent and messages received on the basis of content
Countermeasure
-
Attach a sequence number to each message used in an authentication
exchange
– A new message is accepted only if its sequence number is in the proper order
– Difficulty with this approach is that it requires each party to keep track of the last sequence number for each claimant it has dealt with
– Generally not used for authentication and key exchange because of overhead -
Timestamps
– Requires that clocks among the various participants be synchronized
– Party A accepts a message as fresh only if the message contains a timestamp that, in A’s
judgment, is close enough to A’s knowledge of current time -
Challenge/response
– Party A, expecting a fresh message from B, first sends B a nonce (challenge) and
requires that the subsequent message (response) received from B contain the correct
nonce value
One-way
- Email application also uses encryption.
- Email: Sender and Receiver need not be online at the same time.
– The envelope or header must be in clear for the protocol to work over public networks.
– Uses SMTP or X.400. Encryption should ensure that main handling systems cannot obtain decryption keys.
– Recipient requires an authentication of the message source.
簡單的複習- Needham-Schroeder(NS) Protocol of Key Distribution
NS改進的方法
金鑰Ka, Kb分別是 A、B與KDC所共享的主金鑰,協議的目的是安全地將會話金鑰K分發給A和B。步驟(2) A安全地收到會話金鑰,步驟(3)的訊息只能由B解密,步驟(4)反映了 B的收到的Ks,步驟(5)使B明確了自己與A擁有相同的會話金鑰,且臨時互動號N2保證B得到的訊息是最新的。回顧第14章,步驟(4)和步驟(5)的目的是阻止特定型別的重放攻擊。需要指出
的是敵手捕獲步驟(3)的訊息並重放它,將會在某些方式上打亂B的操作。
儘管有步驟(4)和步驟(5),該協議還是很容易受到一種形式的重放攻擊。假設對手X已知之前的會話金鑰,雖然這比對手簡單地觀察和記錄步驟(3)更難發生,但這是一個安全隱患。除非B無限期地記得所有之前和A會話使用過的會話金鑰,否則B就不能確定這是一個重放攻擊。如果X能截獲步驟(4)的握手訊息,他就能偽造步驟(5) A的回覆並將其傳送給B, 而B卻認為該訊息來A於A且用已認證的會話金鑰的加密。
Denning NS
這種策略的最大的問題就是時間同步問題。如果時間不同步的情況下, A比B快一點,那麼attacker擷取了再發給B,剛好也滿足時效性,這樣的情況下的攻擊就被稱為抑制重放攻擊(Suppress Replay Attack)
一種解決策略是強制A, B和KDC時鐘同步,但是有的時候會難以做到,那麼第二種方法就是Neuman 93 Modification
Neuman 93 Modification
SSL
- Secure Socket layer protocol uses Transport Later features of Modern Internet.
- The main idea is to create a transport session between two nodes and then exchange a session key using a protocol similar to the Hybrid protocol.
- Session key is used in the symmetric key encryption.
- So, a Transport Layer Security (TLS) used two important concepts:
- Connection between a client and a server
- Session associated with the connection.
- They use OSI layering model protocols for realizing the above concepts.
相關文章
- 密碼學期末複習密碼學
- 密碼學基礎概念 — 密碼學複習(一)密碼學
- 分組密碼(一) — 密碼學複習(四)密碼學
- 【筆記】【THM】Introduction to Cryptography(密碼學簡介)筆記密碼學
- 古典密碼的演化 (一)— 密碼學複習(二)密碼學
- 古典密碼的演化 (二)— 密碼學複習(三)密碼學
- 分組密碼(四)AES演算法① — 密碼學複習(七)演算法密碼學
- RSA Lib Chapter 2 Cryptography (RSA實驗室 第二章,密碼學)APT密碼學
- 1.1 Cryptography and Modern Cryptography
- 密碼危機:深度學習正在加速密碼破解!密碼深度學習
- mysql學習之-密碼管理(預設密碼,修改密碼,解決忘記密碼)MySql密碼
- 置換密碼理論學習密碼
- 商密學習-分組密碼加密模式筆記密碼加密模式筆記
- 密碼的複雜化密碼
- [譯] 學習 Spring Security(六):密碼編碼Spring密碼
- 密碼學密碼學
- 應用密碼學——古典密碼密碼學
- 《密碼學系列》|| 密碼學中的流密碼是怎麼回事?密碼學
- MySQL 5.7 初始密碼和密碼複雜度問題MySql密碼複雜度
- 複雜密碼生成工具apg密碼
- RODC的密碼複製策略密碼
- 使用 Python 學習和破解古典密碼Python密碼
- 青少年CTF平臺練習密碼學密碼學
- 應用密碼學 - 公鑰密碼密碼學
- 應用密碼學——分組密碼密碼學
- Python學習——Caesar Cipher密碼破解(加密)方法Python密碼加密
- 現代密碼學-課後習題【李子臣】密碼學
- 初步學習密碼系統的安全性密碼
- ruby指令碼,隨機生成複雜密碼指令碼隨機密碼
- Linux 生成複雜密碼並且檢查密碼強度Linux密碼
- oracle 開啟複雜密碼驗證Oracle密碼
- 密碼複雜度設定函式密碼複雜度函式
- 密碼學入門密碼學
- killBase系列 -- 密碼學密碼學
- 密碼學筆記密碼學筆記
- 古典密碼學 (一)密碼學
- 密碼學簡述密碼學
- 《HTTPS權威指南》- SSL、TLS和密碼學學習筆記HTTPTLS密碼學筆記