Browse Source

* patch from sergei to fix alignment

git-svn-id: trunk@10116 -
marco 17 years ago
parent
commit
7c6e0cda1a
1 changed files with 5 additions and 4 deletions
  1. 5 4
      packages/hash/src/md5.pp

+ 5 - 4
packages/hash/src/md5.pp

@@ -461,10 +461,11 @@ begin
         Length := 8 * (Context.Length + Context.BufCnt);
         Length := 8 * (Context.Length + Context.BufCnt);
 
 
         // 2. Append padding bits
         // 2. Append padding bits
-        Pads := (120 - Context.BufCnt) mod 64;
-        if Pads > 0 then
-          MDUpdate(Context, PADDING_MD45, Pads) else
-          MDUpdate(Context, PADDING_MD45, 56);
+        if Context.BufCnt >= 56 then
+          Pads := 120 - Context.BufCnt
+        else
+          Pads := 56 - Context.BufCnt;
+        MDUpdate(Context, PADDING_MD45, Pads);
 
 
         // 3. Append length of the stream
         // 3. Append length of the stream
         Invert(@Length, @Length, 8);
         Invert(@Length, @Length, 8);