Current location - Training Enrollment Network - Mathematics courses - MD5 four-wheel 16 cycle function (mathematical principle)
MD5 four-wheel 16 cycle function (mathematical principle)
Well, it's complicated. This is a hash function of the computer. It is the principle of mathematical hashing algorithm.

The simple description of MD5 algorithm is that MD5 processes the input information in 5 12 bit packets, and each packet is divided into 16 32-bit packets. After a series of processing, the output of the algorithm consists of four 32-bit packets, and concatenating these four 32-bit packets will generate a hash value of 128 bits. The MD5 algorithm needs to be filled with information first, so that the result of 5 12 bits is equal to 448. Therefore, the bit length of information will be extended to N*5 12+448, where n is a non-negative integer and can be zero. The method of filling is as follows: fill a 1 and countless zeros after the information, and don't stop filling the information with zeros until the above conditions are met. Then, the length of the pre-filled information expressed in 64-bit binary is appended to the result. After these two steps, the bit length of the current information is = n * 5 12+448+64 = (n+1) * 512, that is, the length is exactly an integer multiple of 512. The reason for this is to meet the requirements of information length in post-processing. There are four 32-bit integer parameters called Chaining variables in MD5, namely: A=0x6745230 1, b = 0xefdab89, C=0x98badcfe, D=0x 10325476. When these four link variables are set, the algorithm begins to enter four rounds of loop operation. Cyclic number is the number of 5 12 bit packets in the information. Copy the above four linked variables to the other four variables: A to A, B to B, C to C, D to D. There are four main loops (only three in MD4), and each loop is very similar. The first round of 16 operation. Do a nonlinear function operation on three of A, B, C and D, each time, and then add the fourth variable, a subgroup of the text and a constant to the result. Then move the result to the left ring by an uncertain number and add one of A, B, C or D. Finally, replace one of A, B, C or D with the result. Let's look at the four nonlinear functions used in each operation (one for each round). F(X,Y,Z)=(X & amp; y)|((~ X)& amp; Z) G(X,Y,Z)=(X & amp; z)|(Y & amp; (~Z)) H(X,y,z)=x^y^z i(x,y,z)=y^(x|(~z))(& amp; Interpretation of these four functions: If the corresponding bits of X, Y and Z are independent and consistent, then each bit of the result should also be independent and consistent. F is a function of bit operation. That is, if x, y, otherwise z. The function h is a bitwise parity operator. Suppose Mj represents the j-th subpacket of the message (from 0 to 15), the constant ti is the integer part of 4294967296*abs(sin(i)), and the value range of I is 1 to 64, and the unit is radian. (4294967296 is equal to the 32nd power of 2) FF(a, B, C, D, Mj, S, ti) means A = B+((A+F (B, C, D)+MJ+Ti).