我无法真正理解Advanced Encryption Standard中的MixColumns,有人可以帮助我该怎么做吗?

我在互联网上找到了一些关于MixColumns的主题,但是我仍然有很多问题要问。

例如。

$$
\开始{bmatrix}
\ mathtt {d4} \\
\ mathtt {bf} \ \
\ mathtt {5d} \\
\ mathtt {30} \\
\ end {bmatrix}
\ cdot
\ begin {bmatrix}
\ mathtt {02}和\ mathtt {03}和\ mathtt {01}和\ mathtt {01} \\
\ mathtt {01}和\ mathtt {02}&\ mathtt {03}和\ mathtt {01} \\
\ mathtt {01}和\ mathtt {01}&\ mathtt {02}和\ mathtt {03} \\
\ mathtt {03}和\ mathtt {01}& \ mathtt {01}和\ mathtt {02} \\
\ end {bmatrix}
=
\ begin {bmatrix}
\ mathtt {04} \\
\ mathtt {66} \\
\ mathtt {81} \\
\ mathtt {e5} \\
\ end {bmatrix}
$$

这里,第一个元素的计算公式为

$$(\ mathtt {d4} \ cdot \ mathtt {02})+(\ mathtt {bf} \ cdot \ mathtt {03}) +(\ mathtt {5d} \ cdot \ mathtt {01})+(\ mathtt {30} \ cdot \ mathtt {01})= \ mat htt {04} $$

首先,我们将尝试解决$ \ mathtt {d4} \ cdot \ mathtt {02} $。

我们将转换$ \ mathtt { d4} $转换为二进制格式,其中$ \ mathtt {d4} _ {16} = \ mathtt {1101 \,0100} _2 $。

$$ \ begin {aligned}
\ mathtt {d4} \ cdot \ mathtt {02}
&= \ mathtt {1101 \,0100} \ ll 1&\ text {(} {\ ll} \ text {左移,1是数字的移位位数)} \\
&= \ mathtt {1010 \,1000} \ oplus \ mathtt {0001 \,1011}&\ text {(XOR是因为移位前最左位为1)} \\
&= \ mathtt {1011 \,0011}&\ text {(answer)}
\ end {aligned} $$

计算:

$$ \开始{aligned}
&\ mathtt {1010 \,1000} \\
&\ mathtt {0001 \,1011} \ \ oplus \\
=&\ mathtt { 1011 \,0011}
\ end {aligned} $$

$ \ mathtt {d4} $的二进制值将与$ \ mathtt {0001 \,1011} $异或如果$ \ mathtt {d4} $的二进制值的最左位等于1(在移位之前),则进行移位。

我的问题是,如果二进制值的最左位等于0,那我该如何对其进行异或呢?例如$ \ mathtt {01} _ {16} = \ mathtt {0000 \,0001} _2 $ ..?

评论

请不要交叉张贴约翰...

我是新来的,所以我不知道什么是交叉发布。

@JohnPaulParreño:交叉发布意味着将同一问题发布到多个新闻组/站点/等。特别是,将相同的问题发布到多个Stack Exchange网站上(例如与您在Stack Overflow上的问题一样)是不受欢迎的,因为它将受众分成几部分,每个部分都有不同的(可能是冲突的)答案。不过,欢迎使用密码学堆栈交换。

是的,忘了先说欢迎,对此表示抱歉:)

@JohnPaulParreño它不是同一站点(显然),但是由同一公司(Stack Exchange)运行,具有部分重叠的社区,并且使用相同的软件(进行了一些修改,例如,此处具有TeX格式)。通过单击左上方的Stack Exchange按钮,可以在Stack Exchange网络中找到更多站点。

#1 楼

好吧,听起来好像您已经接近了。

MixColumns操作中隐含的乘法是$ GF(2 ^ 8)$乘法操作,使用的字段表示形式与sbox。

但是,由于它们要乘以固定常量$ \ mathtt {1} $,$ \ mathtt {2} $和$ \ mathtt {3} $,因此它比实现起来容易一般$ GF(2 ^ 8)$乘法。

与$ \ mathtt {1} $相乘很容易;这正是您所期望的。

乘以$ \ mathtt {2} $是您所要解决的问题:这相当于将数字左移一位,然后求和或除如果高位为1,则值为0x1B(如果您想知道,其中0x1B来自字段表示)。因此,这就是您所提出问题的答案;如果高位是零,那么您就不需要排他或其他任何内容(或等效地,您排他或以0x00常数表示)。

,下一个问题可能是“用$ \ mathtt {3} $“乘以?好吧,您可以通过乘以$ \ mathtt {2} $(见上文),然后将其与原始值进行异或运算,因为$ \ mathtt {3} = \ mathtt {2} \ oplus \ mathtt {1} $。或者换句话说:

$$ \ mathtt 3 \ times x =(\ mathtt {2} \ oplus \ mathtt {1})\ times x =(\ mathtt 2 \ timesx)\ oplus x $$

因此,一旦我们解决了乘以2的乘法运算,就也解决了乘以3的乘法。

一旦将所有向量元素,则需要添加它们。现在,您可能会想将它们以256为模添加,但这是错误的。该“加”运算实际上是“异或”。他们将其写为$ + $,因为在$ GF(2 ^ n)$字段中,exclusive-or被视为加法运算;它的作用就像加法运算和乘法运算一样。

因此,如果我们看一下计算:

$$(\ mathtt {d4} \ times \ mathtt {02})+(\ mathtt {bf} \ times \ mathtt {03})+(\ mathtt {5d} \ times \ mathtt {01})+(\ mathtt {30} \ times \ mathtt {01})$$


$ \ mathtt {d4} \ times \ mathtt {02} $是$ \ mathtt {d4} << 1 $ ,与$ \ mathtt {1b} $异或(因为设置了$ \ mathtt {d4} $的高位),得到$ \ mathtt {b3} $;
$ \ mathtt {bf} \ times \ mathtt {03} $是$ \ mathtt {bf} << 1 $与$ \ mathtt {1b} $异或(因为设置了$ \ mathtt {bf} $的高位)和$ \ mathtt {bf } $(因为我们要乘以$ \ mathtt {3} $),因此我们得到$ \ mathtt {da} $;
$ \ mathtt {5d} \ times \ mathtt {01} $是$ \ mathtt {5d} $和$ \ mathtt {30} \ times \ mathtt {01} $是$ \ mathtt {30} $。 {b3} $,$ \ mathtt {da} $,$ \ mathtt {5d} $和$ \ mathtt {30} $在一起,得出的是$ \ mathtt {04} $。

评论


$ \ begingroup $
谢谢雨披,如果我还有其他问题,可以问一下吗?
$ \ endgroup $
– goldroger
2012年4月20日在7:23

$ \ begingroup $
@John:如果您的其他问题可以视为该问题的一部分,则可以编辑原始问题。否则最好在网站上发布一个新问题,这样每个人(包括雨披)都有机会回答(并从答案中学习)。如有必要,请从此处链接到该问题。
$ \ endgroup $
–PaŭloEbermann
2012年4月20日在7:38

$ \ begingroup $
如何对最后的4个值进行XOR?您是否对第一对输入,然后对结果与第三输入进行异或,然后对第四输入进行异或?还是一次性完成所有操作(即,如果在所有4个输入中实际上只有一个“ 1”,则输出“ 1”)?
$ \ endgroup $
– Loic Verrall
17-10-22在11:16

$ \ begingroup $
@LoicVerrall:xor既具有关联性又具有可交换性,因此您可以使用任何方便的顺序。但是,如果您决定一次将所有4个异或运算,则不会“如果所有4个输入中都有1个,则输出'1'”,而是“如果奇数个中有1个,则输出1 ”
$ \ endgroup $
–雨披
17-10-22在12:40

$ \ begingroup $
@ShantanuShinde:计算$ 4 \ times X $的最明显方法是$ 4 \ times X = 2 \ times(2 \ times X)$,也就是说,您两次应用了上述双倍步骤。或者,我错过了什么。
$ \ endgroup $
–雨披
20-3-30在3:31