Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Do MD5 checksums contain a checkbit?

I have to copy some MD5 checksums by hand (there's no other way) and was wondering whether there is any code out there that can validate a checksum as being valid in the same way one can validate a credit card number.

Just to be clear, I'm not asking how to generate an MD5 sum from a file so that I can compare it with the sum I've been given, I'm asking if it's possible (and I doubt it is) to validate that an MD5 sum is a genuine MD5 sum without actually making any reference back to the bytes that have been used to generate the sum.

I want to identify a possible typo.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Basically, it does not have any checksum bit. To identify a typo, you might try sharing an a checksum (for example, MD5) of your MD5 sum over the same channel and check it.

share|improve this answer

Its actually a consequence of the design criteria of a cryptographic hash (which MD5 aimed to be) that there not be such a thing.

When you feed a file into an ideal 128-bit cryptographic hash, you can not predict any of the 128 bits of output (or their relation to each other) other than by running the hash. If you can, you're not actually getting a 128-bit hash. E.g., if the hash had a parity bit (a bit such that the total number of 1s is always odd [odd parity] or always even [even parity]), then you actually have a 127-bit hash.

And in order to make sure that you don't accidentally generate a valid hash by typo, you'll want a better than 50/50 chance of detecting it. So you'd lose more bits.

The problem is that you wanted a 128-bit hash for a reason: an extra bit generally doubles the work required to attack the hash.

If the redundancy is part of the hash's intended design, then it'd be called a 124-bit hash, with 4 bits of CRC (etc.). If the was not intended, then its actually a partial cryptanalysis (breaking) of the hash.

Practical Solution

Since you want to catch typos, just add any checksum or check digit and write it down alongside. You could use something like perl's Algorithm::Verhoeff to add a check digit.

share|improve this answer

The MD5 checksum itself is a checksum. It would be odd to have the checksum have it's own checksum/checkbit.

Any random sum matching the only criteria it's 16 bytes can be an MD5 checksum. These 16 bytes can be represented as 32 hexadecimal digits, 128 bits or whatever you like.

share|improve this answer
    
I'm not sure you see the point of my question. I was asking whether there was an algorithm that says that the 32 hexadecimal digits make a valid MD5 hash. –  Rich Dec 12 '12 at 12:26
2  
@Rich I think I do. Did you miss the line "Any random sum matching the only criteria it's 16 bytes can be an MD5 checksum."? This long for "no". ;) –  gertvdijk Dec 12 '12 at 16:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.