Collision-Resistance

如果我連接兩個具有相同前綴和後綴的衝突 SHA-256 消息,生成的雜湊輸出是否仍會相互衝突?

  • March 15, 2020

假設有兩條消息, $ x_1 $ 和 $ x_2 $ ,它散列到相同的輸出。換句話說,這兩條消息相互衝突:

$$ \operatorname{SHA256}(x_1)=\operatorname{SHA256}(x_2) $$

問題:

  1. 現在,假設我將相同的前綴和/或後綴附加到兩者 $ x_1 $ 和 $ x_2 $ :

$$ \operatorname{SHA256}(p\mathbin|x_1\mathbin|s)\text{ and }\operatorname{SHA256}(p\mathbin|x_2\mathbin|s) $$

現在,將 $ \operatorname{SHA256}(p\mathbin|x_1\mathbin|s)=\operatorname{SHA256} (p\mathbin|x_2\mathbin|s) $ 也? 2. 在這裡考慮另一種稍微不同的情況 - 部分碰撞而不是完全碰撞。

比方說 $ \operatorname{SHA256}(x_1) $ 與 $ \operatorname{SHA256}(x_2) $ 在前 80 位。

現在,如果我添加相同的前綴和後綴 $ x_1 $ 和 $ x_2 $ :

$$ \operatorname{SHA256}(p\mathbin|x_1\mathbin|s)\text{ and }\operatorname{SHA256}(p\mathbin|x_2\mathbin|s) $$

將要 $ \operatorname{SHA256}(p\mathbin|x_1\mathbin|s) $ 仍然與 $ \operatorname{SHA256}(p\mathbin|x_2\mathbin|s) $ 在前 80 位中也是如此?

通用碰撞攻擊

尋找與 SHA256 的通用碰撞攻擊的碰撞需要 $ 2^{128} $ 成功機率為 %50 的計算。這個界限是由生日攻擊給出的。沒有比通用碰撞攻擊更實用的 SHA256 攻擊了。假設您幸運地找到了一個;$$ \operatorname{SHA256}(x_1) = \operatorname{SHA256}(x_2) $$

SHA256 填充

讓我們記住使用 512 塊大小的 SHA256 填充,消息長度以 64 位添加到末尾。NIST 180-4 第 13 頁

假設消息的長度, $ M $ , 是 $ \ell $ 位。附加位 $ 1 $ 到消息的末尾,然後是 $ k $ 零位,其中 $ k $ 是方程的最小非負解$$ \ell - 1 - k \equiv 448 \pmod{512}. $$ 然後追加等於數字的64位塊 $ \ell $ 用二進製表示。

回到你的問題;

  1. 現在,將 $ \operatorname{SHA256} (p\mathbin|x_1\mathbin|s)=\operatorname{SHA256} (p\mathbin|x_2\mathbin|s) $ 也?

如果 $ len(p) $ 是 512 的倍數,然後是 $ \operatorname{SHA256} (p\mathbin|x_1) = \operatorname{SHA256} (p\mathbin|x_2) $ 會是一樣的,這就像一個擴展攻擊 $ p $ . 否則你有 $ 1/2^{256} $ 一次嘗試碰撞的機率。

後綴呢 $ s $ . 這不像長度擴展攻擊,因為我們必須考慮 $ x_1 $ 和 $ x_2 $ 在 $ \operatorname{SHA256}(x_1) $ 和 $ \operatorname{SHA256}(x_2) $ , 分別。如果一個選擇 $ s $ 的開始作為填充 $ x_1 $ 和 $ x_2 $ 那麼它可以是擴展攻擊,只要 $ len(x_1) = len(x_2) $ . 否則,碰撞為隨機碰撞。

因此; 組合 $ (p\mathbin|x_i\mathbin|s) $ 需要這麼多的條件 $ p,x_1,x_2,s $ 發生碰撞 $ 1/2^{256} $ 一次嘗試碰撞的機率。

簡而言之,不。

  1. 將要 $ \operatorname{SHA256} (p\mathbin|x_1\mathbin|s) $ 仍然與 $ \operatorname{SHA256} (p\mathbin|x_2\mathbin|s) $ 在前 80 位中也是如此?

,即使你有碰撞,價值也會不同。

引用自:https://crypto.stackexchange.com/questions/78222