On the MD5 algorithm, four auxiliary funcions are defined by Rivest. Can someone tell me where do they come frome?
Taken from the MD5's RFC (http://www.ietf.org/rfc/rfc1321.txt):
We first define four auxiliary functions that each take as input
three 32-b开发者_JS百科it words and produce as output one 32-bit word. F(X,Y,Z) = XY v not(X) Z G(X,Y,Z) = XZ v Y not(Z) H(X,Y,Z) = X xor Y xor Z I(X,Y,Z) = Y xor (X v not(Z))
Thanks in advance.
They are not "functions" per se. If you are a beginner, I can understand why it's confusing. Basically, simplest way I can tell you is, in MD5, there are steps where it shifts or rotates bits around. Such "modifiers" are usually implemented as macros, not functions. For the RFC they are defined as follows
/* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
Notice the description (copy-pasted by you) and the code:
XY v not(X) Z -> (((x) & (y)) | ((~x) & (z)))
If it looks "strange", it's just (x & y) | (~x & z): a regular bit and, another end where the first parameter is negated and a bit or between the 2 results.
If you are REALLY curious about what it all does, start a project in debug mode and MD5 a string and watch the magic in the autos and locals windows (for MSVS).
Keep in mind, NOTHING stops you from using inlined functions instead if you so desire.
精彩评论