4

I read a question a while ago (File containing its own checksum) and I have a follow-up question.

The question was something like:
Would it be possible to add a MD5-hash as the last 128 bits of a file and have that hash be the MD5-hash of the file itself?

The answer was that it was, in theory, possible using brute force.

My question is now:
Can this be done symbolically? Call the 128 added bits [a_0, ..., a_127] and perform the last iteration of the hashing algorithm symbolically. Then the hash [h_0, ..., h_127] would depend on the a:s. Then let a_0 = h_0, a_1 = h_1 etc. If there is no solution, add some padding and try at another position.

I know that the point of a check sum is to verify a file. This is just theoretical reasoning.

Community
  • 1
  • 1
bpnilsson
  • 41
  • 2
  • Those answers are about simple hashing algo's like crc32. – PeeHaa Jul 26 '14 at 14:15
  • I don't believe that there is an efficient way to do this. But I believe at for many complex file formats (e.g. pdf) it is possible to display the md5 hash of the file. – CodesInChaos Jul 26 '14 at 14:39
  • Fun fact: the file [`stackexchange_files.xml`](https://archive.org/download/stackexchange/stackexchange_files.xml) used in the export/opendata/archive dumb of the SE network, contains a md5 for "itself". If you however calculate the md5sum of said file it will not be the same as the md5sum value inside of it. Also the hash is written in its hex representation and not as the last part of the file, making a brute-forcing more challanging. It would be nice to know why SE did create a file that "suggests to" contain it own md5sum? – humanityANDpeace Aug 26 '19 at 14:03

0 Answers0