1. Snake Doctor
  2. Crypto-Keccak

Commits

Snake Doctor  committed 6552e11

Cleaned-up uses list - removed all unnecessary files like Classes and SysUtils.
Added more granularity to checking cases in _ROL64_b

  • Participants
  • Parent commits 2f0e450
  • Branches master

Comments (0)

Files changed (2)

File CryptoKeccak.dpr

View file
  • Ignore whitespace
 
 uses
   Windows,
-  SysUtils,
   unitKeccak in 'unitKeccak.pas';
 
 const
 
 
 var
-  vals: array[0..4] of AnsiString = (
+{  vals: array[0..4] of AnsiString = (
   	   #$C6#$F5#$0B#$B7#$4E#$29,
   	   #$C1#$EC#$FD#$FC,
   	   #$41#$FB,
        #$CC,
        ''
+    );}
+  vals: array[0..0] of AnsiString = (
+		#$1F#$87#$7C
     );
-{  vals: array[0..3] of AnsiString = (
-       #$FF,
-       #$FF#$FE#$FD#$FC#$FB#$FA#$F9#$F8#$F7#$F6#$F5#$F4#$F3#$F2#$F1#$F0#$EF#$EE#$ED#$EC#$EB#$EA#$E9#$E8#$E7#$E6#$E5#$E4#$E3#$E2#$E1#$E0,
-       #$FF#$FE#$FD#$FC#$FB#$FA#$F9#$F8#$F7#$F6#$F5#$F4#$F3#$F2#$F1#$F0#$EF#$EE#$ED#$EC#$EB#$EA#$E9#$E8#$E7#$E6#$E5#$E4#$E3#$E2#$E1#$E0#$DF#$DE#$DD#$DC#$DB#$DA#$D9#$D8#$D7#$D6#$D5#$D4#$D3#$D2#$D1#$D0#$CF#$CE#$CD#$CC#$CB#$CA#$C9#$C8#$C7#$C6#$C5#$C4#$C3#$C2#$C1#$C0,
-       ''
-    );
-//}
 
 
-//  fncs: array[0..1] of procedure( val: AnsiString ) = ( HashString_256A, HashString_256B{, HashString_512} );
-  fncs: array[0..3] of procedure( val: AnsiString ) = ( HashString_224A, HashString_256A, HashString_384A, HashString_512A );
+  fncs: array[0..0] of procedure( val: AnsiString ) = ( HashString_256A{, HashString_256B, HashString_512} );
+//  fncs: array[0..3] of procedure( val: AnsiString ) = ( HashString_224A, HashString_256A, HashString_384A, HashString_512A );
 
 var
   i, j: UInt32;

File unitKeccak.pas

View file
  • Ignore whitespace
 unit unitKeccak;
 interface
 uses
-  windows, SysUtils, Classes;
+  windows;
 
 { $DEFINE KECCAK_EXPOSE_INTERNAL_FUNCTIONS}
+{ $DEFINE INLINE_HELPERS}
 
 {$REGION 'Generic Types'}
 type
 {$ENDREGION}
 
 {$REGION 'Keccak Helper Functions'}
-{$DEFINE INLINE_HELPERS}
-
 function index(x, y: UInt32): UInt32; {$IFDEF INLINE_HELPERS}inline;{$ENDIF}
 begin
     Result := (x mod 5) + 5*(y mod 5);
 begin
 	inA.Val := a;
 
-    if offset >= 64 then
-    begin
-    	outA.Val := 0;
-    end else if offset = 0 then
+    if offset = 0 then
     begin
     	outA.Val := inA.Val;
     end else if offset = 32 then
     begin
     	outA.Arr[0] := 0;
     	outA.Arr[1] := inA.Arr[0];
-    end else if offset < 32 then
+    end else if offset >= 64 then
+    begin
+    	outA.Val := 0;
+    end else if (offset > 0) AND (offset < 32) then
     begin
         outA.Arr[0] := inA.Arr[0] SHL offset;
         outA.Arr[1] := (inA.Arr[1] SHL offset) XOR (inA.Arr[0] SHR (32-offset));
-    end else if offset > 32 then
+    end else if (offset > 32) AND (offset < 64) then
     begin
 		outA.Arr[0] := 0;
         outA.Arr[1] := inA.Arr[0] SHL (offset - 32)