Commits

Snake Doctor  committed 3d45523

Fixed problem with using inversion instead of negation
Modified LFSR86540 to use PUInt8 instead of PUInt8Array
Modified .gitignore file

  • Participants
  • Parent commits 2d017e6

Comments (0)

Files changed (2)

 /*.dcu
 /*.identcache
 /*.exe
+/Resources/KeccakReferenceAndOptimized/*.user
+/Resources/KeccakReferenceAndOptimized/Debug/*.obj
+/Resources/KeccakReferenceAndOptimized/Debug/*.pdb

File unitKeccak.pas

     for y := 0 to 4 do
     begin
         for x := 0 to 4 do
-            C[x] := A[index(x, y)] xor ((NOT A[index(x+1, y)]) AND A[index(x+2, y)]);
+            C[x] := A[index(x, y)] xor (((NOT A[index(x+1, y)])+1) AND A[index(x+2, y)]);
 
         for x := 0 to 4 do
             A[index(x, y)] := C[x];
     end;
 end;
 
-function LFSR86540(LFSR: PDynUInt8): boolean;
+function LFSR86540(LFSR: PUInt8): boolean;
 begin
-    Result := (LFSR.Val AND 1) <> 0;
-    if ((LFSR.Val AND $80) <> 0) then
+    Result := (LFSR^ AND 1) <> 0;
+    if ((LFSR^ AND $80) <> 0) then
     begin
         // Primitive polynomial over GF(2): x^8+x^6+x^5+x^4+1
-        LFSR.Val := (LFSR.Val SHL 1) xor $71;
+        LFSR^ := (LFSR^ SHL 1) xor $71;
     end else
     begin
-        LFSR.Val := LFSR.Val SHL 1;
+        LFSR^ := LFSR^ SHL 1;
     end;
 end;
 
     for i := 0 to nrRounds-1 do
     begin
         KeccakRoundConstants[i] := 0;
-        for j := 0 to 7-1 do
+        for j := 0 to 6 do
 		begin
             bitPosition := (1 SHL j)-1; //2^j-1
             if LFSR86540(@LFSRstate) then