The element size is one byte in the plaintext block). (Rijndael encryption method supports larger blocks, and the number of rows in the matrix can be increased appropriately. ) encryption,
Each round of AES encryption cycle (except the last round) contains four steps:
Each byte in the matrix is converted by an 8-bit S-box. This step provides the nonlinear transformation ability of the encryption method. S-box is related to the inverse element of multiplication on GF(28) and is known to have good nonlinear characteristics. In order to avoid the attack of simple algebraic properties, the S-box is constructed by combining the multiplicative inverse element and the reversible affine transformation matrix. In addition, when constructing the S-box, the fixed point and the anti-fixed point are deliberately avoided, that is, the result of replacing bytes with the S-box will be equivalent to the result of dislocation. The s-box in AES algorithm is shown in figure 2.2.
For example, a byte is 0x 19. After S-box transformation, n( 1, 9) = 0xd4, so it is replaced by 0xd4.
ShiftRows describes the row operation of a matrix. In this step, each line is cyclically moved to the left by an offset. In AES (block size is 128 bits), the first line remains unchanged, and each byte in the second line is cyclically shifted to the left by one space. Similarly, the offsets of the third and fourth lines on the left are 2 and 3, respectively. After ShiftRows, each vertical column in the matrix consists of elements of each different column in the input matrix.
In the MixColumns step, four bytes of each column are combined with each other by linear transformation. The four elements in each column are taken as coefficients respectively, and merged into a polynomial in GF(28), and then this polynomial is multiplied by a fixed polynomial under the modulus. This step can also be regarded as matrix multiplication over Rijndael finite field. The MixColumns function accepts four bytes of input and outputs four bytes, and each input byte will affect the output of four bytes. Therefore, the two steps of shifting rows and mixing columns provide diffusibility for the cryptosystem.
AES algorithm uses the external input key K (the number of words in the key string is Nk), and obtains the extended key of * * * 4(Nr+ 1) words through the key extension program. It includes the following three modules:
(1) ROT word-put is a 4-byte sequence. X here is (02), such as rcon [1] = [01000000]; rcon[2]=[02000000]; Rcon[3]=[04000000]……
Generation of extended key: the first Nk words of extended key are external key K; The word W[[i]] at the back is equal to the exclusive OR of the word W[[i- 1]] before it and the word w [[I-Nk]] before it, that is, w [[I]] = w [[I- 1]] w [But if I is a multiple of Nk, w]