Aes

如何在 MixColumns 轉換中獲得 AES 的 MDS 矩陣的二進制形式?

  • September 30, 2020

我需要編寫一個程序來計算 MixColumns 的運算結果,格式如下:

$ M*X^T, $

在哪裡 $ M $ 是一個 128x128 的二進制矩陣, $ X $ 是一個 128 位向量(狀態)。

我的問題是如何建立這樣的 $ M $ 矩陣。

非常感謝幫助。謝謝!

編輯:

據我了解,MixColumns 轉換可以表示為

$ \begin{pmatrix}MDS & 0 & 0 & 0\0 & MDS & 0 & 0\0 & 0 & MDS & 0\0 & 0 & 0 & MDS\end{pmatrix} * \begin{pmatrix}s_0\s_1\\vdots\s_{15}\end{pmatrix}, $

在哪裡 $ MDS = \begin{pmatrix}02 & 03 & 01 & 01\01 & 02 & 03 & 01\01 & 01 & 02 & 03\03 & 01 & 01 & 02\end{pmatrix} - $ 有元素的矩陣 $ GF(2^8) $ 和

$ s_0, \dots, s_{15} \in \overline{0, 255} - $ 國家的要素。

我需要一個提示如何轉換 $ MDS $ 矩陣轉換為 8x8 二進制矩陣 $ GF(2) $ . 例如,我猜想元素 $ 01 $ 將被轉換為 8x8 單位矩陣。

那是對的嗎?

這是一個創建 MDS 矩陣的 Sage 程式碼 $ F_2 $ .

mds = matrix(GF(2), [
   [0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
   [0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0],
   [0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0],
   [1,0,0,0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0],
   [1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0],
   [0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0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