Commits

Snake Doctor committed 936eb5b

Fixed Rol64 function

  • Participants
  • Parent commits 3d45523

Comments (0)

Files changed (1)

     Result := (x mod 5) + 5*(y mod 5);
 end;
 
-function ROL64(a: UInt64; offset: Byte): UInt64; inline;
+function ROL32(a: UInt32; offset: Byte): UInt32; inline;
 begin
 	Result := a;
 	if offset <> 0 then
     begin
-		Result := (a SHL offset) XOR (a SHR (64-offset));
+		Result := (a SHL offset) XOR (a SHR (32-offset));
     end;
 end;
 
+function ROL64(a: UInt64; offset: Byte): UInt64; //inline;
+type
+   TDynUInt64 = record
+   		case Byte of
+        	0: (Val: UInt64);
+            1: (Arr: array[0..1] of UInt32);
+   end;
+var
+	inA, outA: TDynUInt64;
+begin
+	inA.Val := a;
+    outA.Val := 0;
+
+    outA.Arr[0] := inA.Arr[0] SHL offset;
+    outA.Arr[1] := inA.Arr[1] SHL offset;
+    outA.Arr[0] := outA.Arr[0] XOR (inA.Arr[1] SHR (32-offset));
+    outA.Arr[1] := outA.Arr[1] XOR (inA.Arr[0] SHR (32-offset));
+
+    Result := outA.Val;
+end;
+
 
 {$REGION 'Sponge Functions'}
 function InitSponge;