Make SHA really work
authorunc0rr
Fri, 26 Jan 2007 18:39:40 +0000
changeset 368 fe71e55d2d7b
parent 367 bc3c3edc5ce1
child 369 2aed85310727
Make SHA really work
hedgewars/CMakeLists.txt
hedgewars/uLand.pas
hedgewars/uSHA.pas
--- a/hedgewars/CMakeLists.txt	Fri Jan 26 18:11:03 2007 +0000
+++ b/hedgewars/CMakeLists.txt	Fri Jan 26 18:39:40 2007 +0000
@@ -28,6 +28,7 @@
 	uLocale.pas
 	uMisc.pas
 	uRandom.pas
+	uSHA.pas
 	uSound.pas
 	uStore.pas
 	uTeams.pas
--- a/hedgewars/uLand.pas	Fri Jan 26 18:11:03 2007 +0000
+++ b/hedgewars/uLand.pas	Fri Jan 26 18:39:40 2007 +0000
@@ -59,6 +59,9 @@
 procedure CheckLandDigest(s: shortstring);
 const digest: shortstring = '';
 begin
+{$IFDEF DEBUGFILE}
+AddFileLog('CheckLandDigest: ' + s);
+{$ENDIF}
 if digest = '' then
    digest:= s
 else
--- a/hedgewars/uSHA.pas	Fri Jan 26 18:11:03 2007 +0000
+++ b/hedgewars/uSHA.pas	Fri Jan 26 18:39:40 2007 +0000
@@ -25,7 +25,7 @@
                     Length, CurrLength: Int64;
                     Buf: array[0..63] of byte;
                     end;
-     TSHA1Digest =  array[0.. 4] of LongWord;
+     TSHA1Digest =  array[0..4] of LongWord;
 
 procedure SHA1Init(var Context: TSHA1Context);
 procedure SHA1Update(var Context: TSHA1Context; Buf: PByteArray; Length: LongWord);
@@ -101,11 +101,11 @@
 end;
 
 procedure SHA1Update(var Context: TSHA1Context; Buf: PByteArray; Length: LongWord);
-var i: integer;
+var i: Longword;
 begin
 for i:= 0 to Pred(Length) do
     begin
-    Context.Buf[Context.CurrLength]:= PByteArray(Buf)^[i];
+    Context.Buf[Context.CurrLength]:= Buf^[i];
     inc(Context.CurrLength);
     if Context.CurrLength = 64 then
        begin
@@ -118,7 +118,6 @@
 
 function  SHA1Final(Context: TSHA1Context): TSHA1Digest;
 var i: LongWord;
-    Result: TSHA1Digest;
 begin
 Context.Length:= Context.Length + Context.CurrLength shl 3;
 Context.Buf[Context.CurrLength]:= $80;
@@ -137,9 +136,8 @@
 for i:= 56 to 63 do
     Context.Buf[i] := (Context.Length shr ((63 - i) * 8)) and $FF;
 SHA1Hash(Context);
-move(Context.H, Result, sizeof(TSHA1Digest));
-FillChar(Context, sizeof(Context), 0);
-SHA1Final:= Result
+for i:= 0 to 4 do SHA1Final[i]:= Context.H[i];
+FillChar(Context, sizeof(Context), 0)
 end;
 
 end.