Score:0

MD5 , inputs larger than 512 bits

vi flag

So I get how it works for inputs shorter than $512$, but as for larger inputs "In the case where the remaining input data is exactly $448$ bits long, an entire extra block would need to be added for the padding." what do they mean by the 'remaining' input data is exactly $448$ bits long? if input was like, lets say $500$ bits, $1024-64=960$, $960 - 500= 460$, so $500 + 1 + 459$ zero's, followed by the $64$-bit message length. Is this correct?

fgrieu avatar
ng flag
We have [many questions and answers around MD5 padding](https://crypto.stackexchange.com/search?tab=relevance&q=%5bmd5%5d%20padding), I'm not sure we need another. If the input data is $b$-bit long, then there are $\lfloor(b+64)/512\rfloor+1=\lceil(b+65)/512\rceil$ block(s). Yes for a 500-bit message, there are 1+459+64 bits after the data bits. If the input is 447, or 959, or 1471-bit, there are 1+64 (the min). If the input is 448, or 960, or 1472-bit, there are 1+447+64 (the max). Beware that MD5 is little-endian everywhere except for bits in a byte.
tiredpotato avatar
vi flag
sorry it's my first time on this site T_T and thank u for answering. So, if the input is 448 bits, I'll be needing 2 blocks? so, 448 + 1 + 63 zeros and the 2nd block 448 zeros + 64? did I get it right?
fgrieu avatar
ng flag
Yes, that's exactly it. Again, beware of endianness: the first 32-bit word of the last 64 bits of the second block are the __low__-order 32 bits of the length in bits, but the first bit of the first 32-bit word after the 56 bytes (14 words) of data is the __high__-order bit of the low-order byte of that word, thus that word has value 128 (0x00000080, that is 0x80 0x00 0x00 0x00).
Maarten Bodewes avatar
in flag
The stupid thing is that the padding should be the same regardless of the endianness as the order of bits **in a byte** is always highest to lowest, i.e. big endian. I've seen `0x01` used instead of `0x80` which is ridiculous. That's one reason why little endian is so confusing; in hexadecimals it reverses order every byte.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.