/* xtime is a macro that finds the product of {02} and the argument to xtime modulo {1b}*/#define xtime(x) ((x<<1) ^ (((x>>7) & 1) * 0x1b))/* MixColumns function mixes the columns of the state matrix*/void MixColumns(){ int i; unsigned char Tmp,Tm,t; for(i=0;i<4;i++) { t=state[0][i]; Tmp = state[0][i] ^ state[1][i] ^ state[2][i] ^ state[3][i] ; Tm = state[0][i] ^ state[1][i] ; Tm = xtime(Tm); state[0][i] ^= Tm ^ Tmp ; Tm = state[1][i] ^ state[2][i] ; Tm = xtime(Tm); state[1][i] ^= Tm ^ Tmp ; Tm = state[2][i] ^ state[3][i] ; Tm = xtime(Tm); state[2][i] ^= Tm ^ Tmp ; Tm = state[3][i] ^ t ; Tm = xtime(Tm); state[3][i] ^= Tm ^ Tmp ; }}这是我在网上找的,我最近也在学习AES,相互学习吧~~其实我也没有看懂学习一下吧。在MixColumns步骤,每一直行的四个字节通过线性变换互相结合。每一直行的四个元素分别当作1,x,x^2,x^3的系数,合并即为GF(2^8)中的一个多项式,接着将此多项式和一个固定的多项式c(x)=3x^3+x^2+x+2在modulo x^4+1下相乘。此步骤亦可视为 Rijndael有限域之下的矩阵乘法。MixColumns函数接受4个字节的输入,输出4个字节,每一个输入的字节都会对输出的四个字节造成影响。因此ShiftRows和MixColumns两步骤为这个密码系统提供了扩散性。参考:http://zh.wikipedia.org/wiki/%E9%AB%98%E7%BA%A7%E5%8A%A0%E5%AF%86%E6%A0%87%E5%87%86或者你可以看看酷壳里面的一个动画,也很清楚~~http://coolshell.cn/articles/3161.html
阅读全文 >
这篇博客深入解析了AES算法中的MixColumns函数,展示了如何通过线性变换和GF(2^8)中的多项式运算实现矩阵乘法,强调了ShiftRows和MixColumns在提供密码系统扩散性上的作用。参考链接提供了额外的学习资源。
2878

被折叠的 条评论
为什么被折叠?



