In the Length extension attack of Wikipedia
The following information summarizes the relevant information provided on the page at the time of posting this question.
The provided parameters are
- secret length: 14
- message: count=10&lat=37.351&user_id=1&long=-119.827&waffle=eggo
- the original signature is 6d5f807e23db210bc254a28be2d6759a0f5f5d99
- the page does not explicitly state it, but we can infer that the hash algorithm used in the example is SHA-1 (using SHA-1 yields the new signature provided in the example, 0e41270260895979317fff3898ab85668953aaa2)
The extended message (referred to on the page as "New data", reformatted here to remove the line breaks and spaces) is listed as: count=10&lat=37.351&user_id=1&long=-119.827&waffle=eggo\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x28&waffle=liege
The padding should yield a message length in bits (excluding the extension) that is a multiple of 512.
Counting the bits in "New data" (excluding the extension):
- message length in bits = 55 * 8 = 440
- secret length in bits = 14 * 8 = 112
- padding in bits: 58 * 8 = 464
- total length in bits (excluding the extension) = 1016
Based on the above calculation, there are 8 bits missing, so "New data" should include another \x00. Is my calculation/reasoning/understanding wrong?