For Merkle-Damgård hashing, MD-compliant padding is defined as any padding scheme satisfying:
- $M$ is a prefix of $\text{Pad}(M)$
- $|M_1|=|M_2|\Rightarrow |\text{Pad}(M_1)|=|\text{Pad}(M_2)|$
- $|M_1|\neq |M_2|\Rightarrow $ last blocks of $\text{Pad}(M_1)$ and $\text{Pad}(M_2)$ differ
Some of these are more obviously necessary than others. I can see how different length messages having the last padding block could lead to collisions, for example. However, I'm struggling to see why all three of these are needed specifically though, so am looking for a quick example of an attack possible for each of the three cases where one of these is missing.
I know also that attacks are possible when any padded message is a suffix of another. Which of the three conditions prevents this, and why not include this as a condition directly?