Length extension attack SHA-1 message division with padding problem? I'm was reading this example for length extension attack given here 
link

When working out, how the extended block length be divisible by 512 (SHA block size).

I'm assuming following:-


In SHA, the size of the blocks is 512 bit.  
The last block must contain:the rest of data in message (mod 512).
some filling (padding)
the last 64 bits as length


In example given in link shared above, this is what extended msg looks like 

http://example.com/downloadfile=report.pdf%80%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%A8/../../../../../../../etc/passwd&amp;mac=ee40aa8ec0cfafb7e2ec4de20943b673968857a5

Example 1
Calculating     

A more precise of asking is that,
message =10 bytes = 80 bits
secret key = 11 bytes= 88 bits
168 mod 512= 160 bits= 21 bytes
64 - 21= 43 
padding +message length= 464+552 =1016 bits
adding /../../../../../../../etc/passwd 32 x 8= 256 bits
Adding it to A8/=  424

How I make sense If I add the missing padding which is 256 mod 512 =256=32 bytes 

64-32  = 32 x8= 256 bits


Example 2

count=10&amp;lat=37.351&amp;user_id=1&amp;long=-119.827&amp;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&amp;waffle=liege

Going on by logic


message =55 bytes = 440 bits
secret key = 14 bytes= 112 bits
length encoding = 552
552 mod 512= 40 bits= 5 bytes
64 - 5= 59 bytes
If you check the padding its 58 bytes not 59 . Can you tell why?
padding +message length= 472+552 =1024 bits
adding extra &amp;waffle=liege 13 x 8= 104 
adding to existing message length(552) + 104= 656
How I make sense If I add the missing padding which is 656 mod 512 =144 
= 18 bytes
64 - 18= 46 x 8 = 368 bits
104 + 368 (message length and padding)
OK, lets go through this step by step:


the message size of http://example.com/downloadfile=report.pdf is 10 bytes, as only the filename (report.pdf) is hashed according to the article;
the key size is usually known and was explicitly set in the article to 11 bytes, not 15 (11 bytes is a bit short for a key size, by the way);
so the length of the message is 10 + 11 = 21 bytes, or 168 bits and A8 is indeed 168;
to the padding + length encoding needs to be 64 - 21 = 43 bytes, lets check that:
%80%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%A8
yep, that seems to be correct.


Note that 64 bytes is 512 bits for the block size and that e.g. %80 is the encoding of a single byte with value 80h, so you need to count the characters and then divide by 3.

So I'm not sure how you got your input values for the message size and key size, but they are way off. So you would not end up with the right values, regardless of the correctness of your formulas.