Score:-1

Padding and the MD5 algorithm

cn flag

In MD5, if M=100, how can we perform padding on it and how many blocks are needed in each round?

These are general questions for understanding padding and rounds.

Maarten Bodewes avatar
in flag
Please describe what you have tried solving this question yourself. There are generic descriptions of MD5 everywhere. Just copying stuff from these descriptions is not useful.
Maarten Bodewes avatar
in flag
Note that blocks and rounds are not the same thing. You seem to ask about blocks, while you seem to be seeking information on rounds.
cn flag
actually i searched alot but didn't find any useful answer, its a past quiz question and i am trying to find answer..
cn flag
i am trying to understand whole process of MD5 rounds and blocks created on message (like, how many blocks will be created if message length is 100 bit, or 200 bit..
cn flag
also how rounds works on these blocks
Patriot avatar
cn flag
@Adam Smith One approach is to go into detail about what you understand and then describe what you have trouble understanding. After that, try to specify your question. As the moderator said, please describe what you have done to answer the question. You will surely receive a good response.
Score:2
fr flag

Most cryptographic hash functions process data in blocks of multiple bytes, since this is more efficient. For algorithms using 32-bit words, like MD5 and SHA-256, they are often 64 bytes in size; for algorithms using 64-bit words, like SHA-512 or BLAKE2b, it's usually 128-byte blocks; and SHA-3 is different still.

Each of these hash functions contains a compression function, which takes the previous hash state (or the initial state at the beginning) and a block of data and combines them into the new state. This compression function contains a certain number of rounds; the same number of rounds is done on each block. Then, after the final block has been processed, the hash value is extracted from the state, which in many cases is just a copy of all or part of the state data.

In Merkle-Dåmgard functions, like MD5, SHA-256, and SHA-512, the padding is done with two pieces. First, the length of the data in bits is computed. In 32-bit functions like MD5 and SHA-256, this is usually a 64-bit (8-byte) value; in 64-bit functions, it's usually 128-bit (16-byte) value. The data is padded such that a single 1 bit is added, and then as many 0 bits as are needed to leave exactly the space for the length. So for MD5 or SHA-256, a 55-byte message will have one 1 bit, seven 0-bits, and then the length. However, a 56-byte message will have one 1 bit, sixty-three 0 bits to pad out the block, then another four hundred forty-eight 0 bits to pad the next block, and then the length, since there isn't space for both the 1 bit and the length in the current block. Different hash algorithms pad differently; SHA-3 and BLAKE2b both use different techniques than this.

As for rounds, there are three different types of rounds we usually talk about when processing a block in a compression function. There are rounds, such as in MD5 and BLAKE2b, where we process each message word once per round; MD5 has four such rounds, and BLAKE2b has 12. There are also algorithms, like SHA-256 and SHA-512, where the message words in the block are expanded into a sequence of many words (64 and 80, respectively) and each round handles one of these expanded words. In SHA-3, we operate on the entire state with the data already XORed in, and each round operates on the entire state.

As a practical matter, almost nobody uses messages that are not an integral number of bytes because they tend to be inconvenient to work with on real hardware. But for MD5 or SHA-256, a 100-bit message would be padded with a 1 bit, three hundred forty-seven 0 bits (to make 448 bits) and then the 64-bit length would be appended to fill the final block (512 bits, or 64 bytes).

While you asked about MD5 in particular, I've also covered several other algorithms here because algorithms differ in many important ways and MD5 should no longer be used, so the way more secure algorithms work will differ.

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.