编程介的小学生 2017-11-04 11:08 采纳率: 20.5%
浏览 875
已采纳

Matrix operation

Problem Description
  M_0 is interested in cryptography. Recently he learned the Advanced Encryption Standard (AES). AES operates on a 4×4 column-major order matrix of bytes and he found it that there is a step called the MixColumns step in the AES.
  In the MixColumns step, there is a state matrix, the four bytes of each column of the state are combined using an invertible linear transformation. The MixColumns function takes four bytes as input and outputs four bytes, where each input byte affects all four output bytes. Together with ShiftRows, MixColumns provides diffusion in the cipher.
  During this operation, each column is multiplied by the known matrix that for the 128 bit key is:

  The addition operation is defined as: xor.
  The multiplication operation is defined as:
  multiplication by 1 means no change
  multiplication by 2 means shifting to the left
  multiplication by 3 means shifting to the left and then performing xor with the initial unshifted value.
  Notice:After each shifting, a conditional xor with 0x1B should be performed if the shifted value is larger than 0xFF.

Input
There are several cases.
The first line is an integer T (T <= 20000), indicating the test cases.
Then is the state matrix, each case followed by four lines, each line contains four bytes, separated by spaces.

Output
For each case, output the new matrix of the state matrix after the MixColumns step. The output data for two different test cases should be separated by an empty line.

Sample Input
1
00 01 02 03
04 05 06 07
08 09 0A 0B
0C 0D 0E 0F

Sample Output
08 09 0A 0B
1C 1D 1E 1F
00 01 02 03
14 15 16 17

  • 写回答

1条回答

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?