Browse Source

sync "hashlib4pascal" library with parent repo.

Ugochukwu Mmaduekwe 6 years ago
parent
commit
af88783501

+ 7 - 7
src/libraries/hashlib4pascal/HashLib.inc

@@ -72,6 +72,13 @@
 // Disable Duplicate Constructor Warnings
 {$WARN DUPLICATE_CTOR_DTOR OFF}
 
+ // XE3 and Above
+{$IF CompilerVersion >= 24.0}
+{$DEFINE DELPHIXE3_UP}
+{$LEGACYIFEND ON}
+{$ZEROBASEDSTRINGS OFF}
+{$IFEND}
+
  // 2010 only
 {$IF CompilerVersion = 21.0}
 {$DEFINE DELPHI2010}
@@ -96,13 +103,6 @@
 // XE3 and Below
 {$IF CompilerVersion <= 24.0}
 {$DEFINE DELPHIXE3_DOWN}
-{$IFEND}
-
- // XE3 and Above
-{$IF CompilerVersion >= 24.0}
-{$DEFINE DELPHIXE3_UP}
-{$LEGACYIFEND ON}
-{$ZEROBASEDSTRINGS OFF}
 {$IFEND}
 
   // XE7 and Above

+ 12 - 4
src/libraries/hashlib4pascal/HlpBlake2B.pas

@@ -1660,7 +1660,8 @@ begin
 end;
 
 procedure TBlake2B.Finish;
-
+var
+  count: Int32;
 begin
 
   // Last compression
@@ -1669,8 +1670,12 @@ begin
 
   F_finalizationFlag0 := System.High(UInt64);
 
-  System.FillChar(F_buf[F_bufferFilled],
-    (System.Length(F_buf) - F_bufferFilled), Byte(0));
+  count := System.Length(F_buf) - F_bufferFilled;
+
+  if count > 0 then
+  begin
+    System.FillChar(F_buf[F_bufferFilled], count, Byte(0));
+  end;
 
   Compress(PByte(F_buf), 0);
 
@@ -1739,7 +1744,10 @@ begin
   if ((F_bufferFilled > 0) and (a_data_length > bufferRemaining)) then
   begin
 
-    System.Move(a_data[offset], F_buf[F_bufferFilled], bufferRemaining);
+    if bufferRemaining > 0 then
+    begin
+      System.Move(a_data[offset], F_buf[F_bufferFilled], bufferRemaining);
+    end;
     F_counter0 := F_counter0 + BlockSizeInBytes;
     if (F_counter0 = 0) then
     begin

+ 12 - 4
src/libraries/hashlib4pascal/HlpBlake2S.pas

@@ -1441,7 +1441,8 @@ begin
 end;
 
 procedure TBlake2S.Finish;
-
+var
+  count: Int32;
 begin
 
   // Last compression
@@ -1450,8 +1451,12 @@ begin
 
   F_finalizationFlag0 := System.High(UInt32);
 
-  System.FillChar(F_buf[F_bufferFilled],
-    (System.Length(F_buf) - F_bufferFilled), Byte(0));
+  count := System.Length(F_buf) - F_bufferFilled;
+
+  if count > 0 then
+  begin
+    System.FillChar(F_buf[F_bufferFilled], count, Byte(0));
+  end;
 
   Compress(PByte(F_buf), 0);
 
@@ -1520,7 +1525,10 @@ begin
   if ((F_bufferFilled > 0) and (a_data_length > bufferRemaining)) then
   begin
 
-    System.Move(a_data[offset], F_buf[F_bufferFilled], bufferRemaining);
+    if bufferRemaining > 0 then
+    begin
+      System.Move(a_data[offset], F_buf[F_bufferFilled], bufferRemaining);
+    end;
     F_counter0 := F_counter0 + UInt32(BlockSizeInBytes);
     if (F_counter0 = 0) then
     begin

+ 13 - 9
src/libraries/hashlib4pascal/HlpConverters.pas

@@ -72,17 +72,17 @@ type
     class function ReadUInt64AsBytesLE(a_in: UInt64): THashLibByteArray;
       overload; static; inline;
 
-    class procedure ReadUInt32AsBytesLE(a_in: UInt32; const a_out: THashLibByteArray;
-      a_index: Int32); overload; static; inline;
+    class procedure ReadUInt32AsBytesLE(a_in: UInt32;
+      const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
 
-    class procedure ReadUInt32AsBytesBE(a_in: UInt32; const a_out: THashLibByteArray;
-      a_index: Int32); overload; static; inline;
+    class procedure ReadUInt32AsBytesBE(a_in: UInt32;
+      const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
 
-    class procedure ReadUInt64AsBytesLE(a_in: UInt64; const a_out: THashLibByteArray;
-      a_index: Int32); overload; static; inline;
+    class procedure ReadUInt64AsBytesLE(a_in: UInt64;
+      const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
 
-    class procedure ReadUInt64AsBytesBE(a_in: UInt64; const a_out: THashLibByteArray;
-      a_index: Int32); overload; static; inline;
+    class procedure ReadUInt64AsBytesBE(a_in: UInt64;
+      const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
 
     class function ConvertStringToBytes(const a_in: String;
       const a_encoding: TEncoding): THashLibByteArray; overload; static;
@@ -403,8 +403,12 @@ begin
   System.Assert(System.length(l_in) and 1 = 0);
 {$ENDIF DEBUG}
   System.SetLength(result, System.length(l_in) shr 1);
-  HexToBin(PChar(l_in), @result[0], System.length(result));
 
+{$IFNDEF NEXTGEN}
+  HexToBin(PChar(l_in), @result[0], System.length(result));
+{$ELSE}
+  HexToBin(PChar(l_in), 0, result, 0, System.length(l_in));
+{$ENDIF !NEXTGEN}
 end;
 
 class function TConverters.ConvertStringToBytes(const a_in: String;

+ 1 - 1
src/libraries/hashlib4pascal/HlpFNV1a64.pas

@@ -65,7 +65,7 @@ begin
   i := a_index;
   while a_length > 0 do
   begin
-    Fm_hash := (Fm_hash xor a_data[i]) * 1099511628211;
+    Fm_hash := (Fm_hash xor a_data[i]) * UInt64(1099511628211);
     System.Inc(i);
     System.Dec(a_length);
   end;

+ 1 - 1
src/libraries/hashlib4pascal/HlpFNV64.pas

@@ -65,7 +65,7 @@ begin
   i := a_index;
   while a_length > 0 do
   begin
-    Fm_hash := (Fm_hash * 1099511628211) xor a_data[i];
+    Fm_hash := UInt64(Fm_hash * 1099511628211) xor a_data[i];
     System.Inc(i);
     System.Dec(a_length);
   end;

+ 2 - 2
src/libraries/hashlib4pascal/HlpGrindahl256.pas

@@ -178,8 +178,8 @@ begin
 
   System.SetLength(result, 8 * System.SizeOf(UInt32));
 
-  TConverters.be32_copy(PCardinal(Fm_state) + 5, 0, PByte(result), 0,
-    System.Length(result));
+  TConverters.be32_copy(PCardinal(Fm_state), 5 * System.SizeOf(UInt32),
+    PByte(result), 0, System.Length(result));
 
 end;
 

+ 2 - 2
src/libraries/hashlib4pascal/HlpGrindahl512.pas

@@ -263,8 +263,8 @@ begin
 
   System.SetLength(result, 8 * System.SizeOf(UInt64));
 
-  TConverters.be64_copy(PUInt64(Fm_state) + 5, 0, PByte(result), 0,
-    System.Length(result));
+  TConverters.be64_copy(PUInt64(Fm_state), 5 * System.SizeOf(UInt64),
+    PByte(result), 0, System.Length(result));
 
 end;
 

+ 25 - 5
src/libraries/hashlib4pascal/HlpHMACNotBuildInAdapter.pas

@@ -39,7 +39,8 @@ type
 
   public
 
-    constructor Create(const a_underlyingHash: IHash);
+    constructor Create(const a_underlyingHash: IHash;
+      const a_hmacKey: THashLibByteArray = Nil);
     procedure Initialize(); override;
     function TransformFinal(): IHashResult; override;
     procedure TransformBytes(const a_data: THashLibByteArray;
@@ -49,6 +50,9 @@ type
     property Name: String read GetName;
     property KeyLength: TNullableInteger read GetKeyLength;
 
+    class function CreateHMAC(const a_hash: IHash;
+      const a_hmacKey: THashLibByteArray): IHMAC; static;
+
   end;
 
 implementation
@@ -59,21 +63,21 @@ function THMACNotBuildInAdapter.Clone(): IHash;
 var
   HmacInstance: THMACNotBuildInAdapter;
 begin
-  HmacInstance := THMACNotBuildInAdapter.Create(Fm_hash.Clone());
+  HmacInstance := THMACNotBuildInAdapter.Create(Fm_hash.Clone(), Fm_key);
   HmacInstance.Fm_opad := System.Copy(Fm_opad);
   HmacInstance.Fm_ipad := System.Copy(Fm_ipad);
-  HmacInstance.Fm_key := System.Copy(Fm_key);
   HmacInstance.Fm_blocksize := Fm_blocksize;
   result := HmacInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
-constructor THMACNotBuildInAdapter.Create(const a_underlyingHash: IHash);
+constructor THMACNotBuildInAdapter.Create(const a_underlyingHash: IHash;
+  const a_hmacKey: THashLibByteArray);
 begin
   Inherited Create(a_underlyingHash.HashSize, a_underlyingHash.BlockSize);
   Fm_hash := a_underlyingHash;
   Fm_blocksize := Fm_hash.BlockSize;
-  System.SetLength(Fm_key, 0);
+  SetKey(a_hmacKey);
   System.SetLength(Fm_ipad, Fm_blocksize);
   System.SetLength(Fm_opad, Fm_blocksize);
 end;
@@ -160,6 +164,22 @@ end;
 function THMACNotBuildInAdapter.GetName: String;
 begin
   result := Format('%s(%s)', ['THMAC', Fm_hash.Name]);
+end;
+
+class function THMACNotBuildInAdapter.CreateHMAC(const a_hash: IHash;
+  const a_hmacKey: THashLibByteArray): IHMAC;
+begin
+
+  if Supports(a_hash, IHMAC) then
+  begin
+    result := (a_hash) as IHMAC;
+    Exit;
+  end
+  else
+  begin
+    result := THMACNotBuildInAdapter.Create(a_hash, a_hmacKey);
+    Exit;
+  end;
 
 end;
 

+ 2 - 19
src/libraries/hashlib4pascal/HlpHash.pas

@@ -20,8 +20,6 @@ uses
 resourcestring
   SIndexOutOfRange = 'Current Index Is Out Of Range';
   SInvalidBufferSize = '"BufferSize" Must Be Greater Than Zero';
-  // SInvalidBlockSize = '"BlockSize" Must Be Greater Than Zero';
-  // SInvalidHashSize = '"HashSize" Must Be Greater Than Zero';
   SUnAssignedStream = 'Input Stream Is Unassigned';
   SFileNotExist = 'Specified File Not Found';
   SCloneNotYetImplemented = 'Clone Not Yet Implemented For "%s"';
@@ -128,14 +126,7 @@ end;
 
 procedure THash.SetBlockSize(value: Int32);
 begin
-  // if value > 0 then
-  // begin
   Fm_block_size := value;
-  // end
-  // else
-  // begin
-  // raise EArgumentHashLibException.CreateRes(@SInvalidBlockSize);
-  // end;
 end;
 
 function THash.GetHashSize: Int32;
@@ -145,14 +136,7 @@ end;
 
 procedure THash.SetHashSize(value: Int32);
 begin
-  // if value > 0 then
-  // begin
   Fm_hash_size := value;
-  // end
-  // else
-  // begin
-  // raise EArgumentHashLibException.CreateRes(@SInvalidHashSize);
-  // end;
 end;
 
 function THash.ComputeString(const a_data: String; a_encoding: TEncoding)
@@ -330,9 +314,8 @@ begin
       else
       begin
         TransformBytes(data, 0, readed);
-        total := total + readed;
       end;
-    end
+    end;
 
   end
   else
@@ -352,7 +335,7 @@ begin
         TransformBytes(data, 0, readed);
         total := total + readed;
       end;
-    end
+    end;
 
   end;
 

+ 7 - 3
src/libraries/hashlib4pascal/HlpHashBuffer.pas

@@ -12,6 +12,9 @@ uses
 {$ENDIF HAS_UNITSCOPE}
   HlpHashLibTypes;
 
+resourcestring
+  SHashBufferMessage = 'HashBuffer, Length: %d, Pos: %d, IsEmpty: %s';
+
 type
   THashBuffer = record
 
@@ -179,13 +182,14 @@ end;
 procedure THashBuffer.Initialize;
 begin
   Fm_pos := 0;
-  System.FillChar(Fm_data[0], System.Length(Fm_data) * System.SizeOf(Byte), Byte(0));
+  System.FillChar(Fm_data[0], System.Length(Fm_data) *
+    System.SizeOf(Byte), Byte(0));
 end;
 
 function THashBuffer.ToString: String;
 begin
-  result := Format('HashBuffer, Length: %d, Pos: %d, IsEmpty: %s',
-    [Self.Length, Self.Pos, BoolToStr(Self.IsEmpty, True)]);
+  result := Format(SHashBufferMessage, [Self.Length, Self.Pos,
+    BoolToStr(Self.IsEmpty, True)]);
 end;
 
 end.

+ 0 - 4
src/libraries/hashlib4pascal/HlpHashCryptoNotBuildIn.pas

@@ -45,16 +45,13 @@ begin
   begin
     a_buffer_size := a_block_size;
   end;
-
   Fm_buffer := THashBuffer.Create(a_buffer_size);
-
 end;
 
 procedure TBlockHash.Initialize;
 begin
   Fm_buffer.Initialize();
   Fm_processed_bytes := 0;
-
 end;
 
 procedure TBlockHash.TransformBuffer;
@@ -90,7 +87,6 @@ begin
   begin
     Fm_processed_bytes := Fm_processed_bytes + UInt64(Fm_buffer.Length);
     TransformBlock(ptr_a_data, Fm_buffer.Length, a_index);
-    // TransformBlock(ptr_a_data, a_length, a_index);
     a_index := a_index + (Fm_buffer.Length);
     a_length := a_length - (Fm_buffer.Length);
   end;

+ 20 - 19
src/libraries/hashlib4pascal/HlpHashFactory.pas

@@ -5,11 +5,6 @@ unit HlpHashFactory;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$ELSE}
-  SysUtils,
-{$ENDIF HAS_UNITSCOPE}
   HlpHashRounds,
   HlpHashSize,
   HlpIHash,
@@ -375,6 +370,9 @@ type
       class function CreateKeccak_384(): IHash; static;
       class function CreateKeccak_512(): IHash; static;
 
+      class function CreateShake_128(a_xof_size: THashSize): IHash; static;
+      class function CreateShake_256(a_xof_size: THashSize): IHash; static;
+
       class function CreateBlake2B(const config: IBlake2BConfig = Nil)
         : IHash; static;
 
@@ -400,7 +398,8 @@ type
 
     public
 
-      class function CreateHMAC(const a_hash: IHash): IHMAC; static;
+      class function CreateHMAC(const a_hash: IHash;
+        const a_hmacKey: THashLibByteArray = Nil): IHMAC; static;
 
     end;
 
@@ -932,6 +931,18 @@ begin
   Result := TSHA3_512.Create();
 end;
 
+class function THashFactory.TCrypto.CreateShake_128
+  (a_xof_size: THashSize): IHash;
+begin
+  Result := (TShake_128.Create() as IXOF).SetXOFOutputSize(a_xof_size);
+end;
+
+class function THashFactory.TCrypto.CreateShake_256
+  (a_xof_size: THashSize): IHash;
+begin
+  Result := (TShake_256.Create() as IXOF).SetXOFOutputSize(a_xof_size);
+end;
+
 class function THashFactory.TCrypto.CreateKeccak_224: IHash;
 begin
   Result := TKeccak_224.Create();
@@ -1169,20 +1180,10 @@ end;
 
 { THashFactory.THMAC }
 
-class function THashFactory.THMAC.CreateHMAC(const a_hash: IHash): IHMAC;
+class function THashFactory.THMAC.CreateHMAC(const a_hash: IHash;
+  const a_hmacKey: THashLibByteArray): IHMAC;
 begin
-
-  if Supports(a_hash, IHMAC) then
-  begin
-    Result := (a_hash) as IHMAC;
-    Exit;
-  end
-  else
-  begin
-    Result := THMACNotBuildInAdapter.Create(a_hash);
-    Exit;
-  end;
-
+  Result := THMACNotBuildInAdapter.CreateHMAC(a_hash, a_hmacKey);
 end;
 
 { TKDF.TPBKDF2_HMAC }

+ 9 - 0
src/libraries/hashlib4pascal/HlpIHashInfo.pas

@@ -8,6 +8,7 @@ uses
   HlpHashLibTypes,
   HlpIKDF,
   HlpIHash,
+  HlpHashSize,
   HlpNullable;
 
 type
@@ -83,6 +84,14 @@ type
     ['{D38AE885-651F-4F15-BF90-5B64A0F24E49}']
   end;
 
+  IXOF = Interface(IHash)
+    ['{944ED7F0-D033-4489-A5DD-9C83353F23F0}']
+    function GetXOFSize: THashSize;
+    procedure SetXOFSize(a_xof_size: THashSize);
+    property XOFSize: THashSize read GetXOFSize write SetXOFSize;
+    function SetXOFOutputSize(a_xof_size: THashSize): IXOF;
+  end;
+
 implementation
 
 end.

+ 12 - 8
src/libraries/hashlib4pascal/HlpMultipleTransformNonBlock.pas

@@ -26,8 +26,8 @@ type
   strict protected
     FBuffer: TMemoryStream;
 
-    function ComputeAggregatedBytes(const a_data: THashLibByteArray): IHashResult;
-      virtual; abstract;
+    function ComputeAggregatedBytes(const a_data: THashLibByteArray)
+      : IHashResult; virtual; abstract;
 
   public
     constructor Create(a_hash_size, a_block_size: Int32);
@@ -47,9 +47,13 @@ implementation
 
 function TMultipleTransformNonBlock.Aggregate: THashLibByteArray;
 begin
-  FBuffer.Position := 0;
-  System.SetLength(result, FBuffer.Size);
-  FBuffer.Read(result[0], FBuffer.Size);
+  Result := Nil;
+  if FBuffer.Size > 0 then
+  begin
+    FBuffer.Position := 0;
+    System.SetLength(Result, FBuffer.Size);
+    FBuffer.Read(Result[0], FBuffer.Size);
+  end;
 end;
 
 constructor TMultipleTransformNonBlock.Create(a_hash_size, a_block_size: Int32);
@@ -67,7 +71,7 @@ end;
 procedure TMultipleTransformNonBlock.Initialize;
 begin
   FBuffer.Clear;
-  FBuffer.SetSize(0);
+  FBuffer.SetSize(Int64(0));
 end;
 
 procedure TMultipleTransformNonBlock.TransformBytes(const a_data
@@ -83,7 +87,7 @@ end;
 
 function TMultipleTransformNonBlock.TransformFinal: IHashResult;
 begin
-  result := ComputeAggregatedBytes(Aggregate());
+  Result := ComputeAggregatedBytes(Aggregate());
   Initialize();
 end;
 
@@ -91,7 +95,7 @@ function TMultipleTransformNonBlock.ComputeBytes(const a_data
   : THashLibByteArray): IHashResult;
 begin
   Initialize();
-  result := ComputeAggregatedBytes(a_data);
+  Result := ComputeAggregatedBytes(a_data);
 end;
 
 end.

+ 11 - 5
src/libraries/hashlib4pascal/HlpNullDigest.pas

@@ -68,8 +68,11 @@ end;
 procedure TNullDigest.TransformBytes(const a_data: THashLibByteArray;
   a_index, a_length: Int32);
 begin
-  FbOut.Write(a_data[a_index], a_length);
-  HashSize := Int32(FbOut.Size);
+  if a_data <> Nil then
+  begin
+    FbOut.Write(a_data[a_index], a_length);
+    HashSize := Int32(FbOut.Size);
+  end;
 end;
 
 function TNullDigest.TransformFinal: IHashResult;
@@ -77,9 +80,12 @@ var
   res: THashLibByteArray;
 begin
   try
-    FbOut.Position := 0;
-    System.SetLength(res, FbOut.Size);
-    FbOut.Read(res[0], FbOut.Size);
+    if FbOut.Size > 0 then
+    begin
+      FbOut.Position := 0;
+      System.SetLength(res, FbOut.Size);
+      FbOut.Read(res[0], FbOut.Size);
+    end;
     result := THashResult.Create(res);
   finally
     Initialize();

+ 13 - 10
src/libraries/hashlib4pascal/HlpPBKDF2_HMACNotBuildInAdapter.pas

@@ -8,6 +8,7 @@ uses
   HlpIHash,
   HlpKDF,
   HlpIHashInfo,
+  HlpHMACNotBuildInAdapter,
   HlpBitConverter,
   HlpHashLibTypes;
 
@@ -64,9 +65,6 @@ type
 
 implementation
 
-uses
-  HlpHashFactory; // placed here because of circular dependency.
-
 { TPBKDF2_HMACNotBuildInAdapter }
 
 constructor TPBKDF2_HMACNotBuildInAdapter.Create(const a_underlyingHash: IHash;
@@ -129,7 +127,7 @@ end;
 function TPBKDF2_HMACNotBuildInAdapter.GetBytes(bc: Int32): THashLibByteArray;
 var
   LKey, LT_block: THashLibByteArray;
-  LOffset, LSize, LRemainder: Int32;
+  LOffset, LSize, LRemainder, LRemCount: Int32;
 begin
 
   if (bc <= 0) then
@@ -171,10 +169,16 @@ begin
     end
     else
     begin
-      System.Move(LT_block[0], LKey[LOffset], LRemainder);
-      System.Move(LT_block[LRemainder], Fbuffer[FstartIndex],
-        FBlockSize - LRemainder);
-      FendIndex := FendIndex + (FBlockSize - LRemainder);
+      if LRemainder > 0 then
+      begin
+        System.Move(LT_block[0], LKey[LOffset], LRemainder);
+      end;
+      LRemCount := FBlockSize - LRemainder;
+      if LRemCount > 0 then
+      begin
+        System.Move(LT_block[LRemainder], Fbuffer[FstartIndex], LRemCount);
+      end;
+      FendIndex := FendIndex + LRemCount;
       result := LKey;
       Exit;
     end;
@@ -189,9 +193,8 @@ begin
     System.FillChar(Fbuffer[0], System.Length(Fbuffer) *
       System.SizeOf(Byte), Byte(0));
 
-  FHMAC := THashFactory.THMAC.CreateHMAC(FHash);
+  FHMAC := THMACNotBuildInAdapter.CreateHMAC(FHash, FPassword);
 
-  FHMAC.Key := System.Copy(FPassword);
   FBlockSize := FHMAC.HashSize;
   System.SetLength(Fbuffer, FBlockSize);
   FBlock := 1;

+ 2 - 2
src/libraries/hashlib4pascal/HlpPanama.pas

@@ -169,8 +169,8 @@ begin
 
   System.SetLength(result, 8 * System.SizeOf(UInt32));
 
-  TConverters.le32_copy(PCardinal(Fm_state) + 9, 0, PByte(result), 0,
-    System.Length(result));
+  TConverters.le32_copy(PCardinal(Fm_state), 9 * System.SizeOf(UInt32),
+    PByte(result), 0, System.Length(result));
 
 end;
 

+ 2 - 2
src/libraries/hashlib4pascal/HlpSDBM.pas

@@ -64,8 +64,8 @@ begin
   i := a_index;
   while a_length > 0 do
   begin
-    Fm_hash := a_data[i] + Int64(Fm_hash shl 6) + Int64(Fm_hash shl 16)
-      - Fm_hash;
+    Fm_hash := UInt32(a_data[i] + Int64(Fm_hash shl 6) + Int64(Fm_hash shl 16)
+      - Fm_hash);
     System.Inc(i);
     System.Dec(a_length);
   end;

+ 80 - 80
src/libraries/hashlib4pascal/HlpSHA2_512Base.pas

@@ -536,7 +536,7 @@ begin
   // Step 2
 
   // R0
-  h := h + ($428A2F98D728AE22 + data[0] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($428A2F98D728AE22) + data[0] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -544,7 +544,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($7137449123EF65CD + data[1] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($7137449123EF65CD) + data[1] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -552,7 +552,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($B5C0FBCFEC4D3B2F + data[2] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($B5C0FBCFEC4D3B2F) + data[2] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -560,7 +560,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($E9B5DBA58189DBBC + data[3] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($E9B5DBA58189DBBC) + data[3] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -568,7 +568,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($3956C25BF348B538 + data[4] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($3956C25BF348B538) + data[4] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -576,7 +576,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($59F111F1B605D019 + data[5] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($59F111F1B605D019) + data[5] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -584,7 +584,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($923F82A4AF194F9B + data[6] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($923F82A4AF194F9B) + data[6] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -592,7 +592,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($AB1C5ED5DA6D8118 + data[7] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($AB1C5ED5DA6D8118) + data[7] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -601,7 +601,7 @@ begin
     xor (TBits.RotateLeft64(b, 25))) + ((b and c) xor (b and d) xor (c and d)));
 
   // R1
-  h := h + ($D807AA98A3030242 + data[8] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($D807AA98A3030242) + data[8] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -609,7 +609,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($12835B0145706FBE + data[9] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($12835B0145706FBE) + data[9] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -617,7 +617,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($243185BE4EE4B28C + data[10] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($243185BE4EE4B28C) + data[10] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -625,7 +625,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($550C7DC3D5FFB4E2 + data[11] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($550C7DC3D5FFB4E2) + data[11] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -633,7 +633,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($72BE5D74F27B896F + data[12] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($72BE5D74F27B896F) + data[12] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -641,7 +641,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($80DEB1FE3B1696B1 + data[13] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($80DEB1FE3B1696B1) + data[13] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -649,7 +649,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($9BDC06A725C71235 + data[14] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($9BDC06A725C71235) + data[14] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -657,7 +657,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($C19BF174CF692694 + data[15] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($C19BF174CF692694) + data[15] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -667,7 +667,7 @@ begin
 
   // R2
 
-  h := h + ($E49B69C19EF14AD2 + data[16] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($E49B69C19EF14AD2) + data[16] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -675,7 +675,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($EFBE4786384F25E3 + data[17] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($EFBE4786384F25E3) + data[17] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -683,7 +683,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($0FC19DC68B8CD5B5 + data[18] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($0FC19DC68B8CD5B5) + data[18] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -691,7 +691,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($240CA1CC77AC9C65 + data[19] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($240CA1CC77AC9C65) + data[19] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -699,7 +699,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($2DE92C6F592B0275 + data[20] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($2DE92C6F592B0275) + data[20] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -707,7 +707,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($4A7484AA6EA6E483 + data[21] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($4A7484AA6EA6E483) + data[21] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -715,7 +715,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($5CB0A9DCBD41FBD4 + data[22] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($5CB0A9DCBD41FBD4) + data[22] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -723,7 +723,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($76F988DA831153B5 + data[23] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($76F988DA831153B5) + data[23] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -733,7 +733,7 @@ begin
 
   // R3
 
-  h := h + ($983E5152EE66DFAB + data[24] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($983E5152EE66DFAB) + data[24] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -741,7 +741,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($A831C66D2DB43210 + data[25] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($A831C66D2DB43210) + data[25] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -749,7 +749,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($B00327C898FB213F + data[26] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($B00327C898FB213F) + data[26] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -757,7 +757,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($BF597FC7BEEF0EE4 + data[27] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($BF597FC7BEEF0EE4) + data[27] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -765,7 +765,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($C6E00BF33DA88FC2 + data[28] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($C6E00BF33DA88FC2) + data[28] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -773,7 +773,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($D5A79147930AA725 + data[29] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($D5A79147930AA725) + data[29] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -781,7 +781,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($06CA6351E003826F + data[30] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($06CA6351E003826F) + data[30] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -789,7 +789,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($142929670A0E6E70 + data[31] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($142929670A0E6E70) + data[31] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -799,7 +799,7 @@ begin
 
   // R4
 
-  h := h + ($27B70A8546D22FFC + data[32] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($27B70A8546D22FFC) + data[32] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -807,7 +807,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($2E1B21385C26C926 + data[33] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($2E1B21385C26C926) + data[33] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -815,7 +815,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($4D2C6DFC5AC42AED + data[34] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($4D2C6DFC5AC42AED) + data[34] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -823,7 +823,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($53380D139D95B3DF + data[35] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($53380D139D95B3DF) + data[35] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -831,7 +831,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($650A73548BAF63DE + data[36] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($650A73548BAF63DE) + data[36] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -839,7 +839,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($766A0ABB3C77B2A8 + data[37] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($766A0ABB3C77B2A8) + data[37] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -847,7 +847,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($81C2C92E47EDAEE6 + data[38] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($81C2C92E47EDAEE6) + data[38] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -855,7 +855,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($92722C851482353B + data[39] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($92722C851482353B) + data[39] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -865,7 +865,7 @@ begin
 
   // R5
 
-  h := h + ($A2BFE8A14CF10364 + data[40] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($A2BFE8A14CF10364) + data[40] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -873,7 +873,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($A81A664BBC423001 + data[41] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($A81A664BBC423001) + data[41] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -881,7 +881,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($C24B8B70D0F89791 + data[42] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($C24B8B70D0F89791) + data[42] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -889,7 +889,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($C76C51A30654BE30 + data[43] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($C76C51A30654BE30) + data[43] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -897,7 +897,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($D192E819D6EF5218 + data[44] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($D192E819D6EF5218) + data[44] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -905,7 +905,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($D69906245565A910 + data[45] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($D69906245565A910) + data[45] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -913,7 +913,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($F40E35855771202A + data[46] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($F40E35855771202A) + data[46] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -921,7 +921,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($106AA07032BBD1B8 + data[47] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($106AA07032BBD1B8) + data[47] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -931,7 +931,7 @@ begin
 
   // R6
 
-  h := h + ($19A4C116B8D2D0C8 + data[48] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($19A4C116B8D2D0C8) + data[48] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -939,7 +939,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($1E376C085141AB53 + data[49] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($1E376C085141AB53) + data[49] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -947,7 +947,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($2748774CDF8EEB99 + data[50] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($2748774CDF8EEB99) + data[50] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -955,7 +955,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($34B0BCB5E19B48A8 + data[51] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($34B0BCB5E19B48A8) + data[51] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -963,7 +963,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($391C0CB3C5C95A63 + data[52] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($391C0CB3C5C95A63) + data[52] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -971,7 +971,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($4ED8AA4AE3418ACB + data[53] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($4ED8AA4AE3418ACB) + data[53] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -979,7 +979,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($5B9CCA4F7763E373 + data[54] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($5B9CCA4F7763E373) + data[54] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -987,7 +987,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($682E6FF3D6B2B8A3 + data[55] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($682E6FF3D6B2B8A3) + data[55] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -997,7 +997,7 @@ begin
 
   // R7
 
-  h := h + ($748F82EE5DEFB2FC + data[56] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($748F82EE5DEFB2FC) + data[56] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -1005,7 +1005,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($78A5636F43172F60 + data[57] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($78A5636F43172F60) + data[57] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -1013,7 +1013,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($84C87814A1F0AB72 + data[58] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($84C87814A1F0AB72) + data[58] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -1021,7 +1021,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($8CC702081A6439EC + data[59] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($8CC702081A6439EC) + data[59] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -1029,7 +1029,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($90BEFFFA23631E28 + data[60] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($90BEFFFA23631E28) + data[60] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -1037,7 +1037,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($A4506CEBDE82BDE9 + data[61] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($A4506CEBDE82BDE9) + data[61] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -1045,7 +1045,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($BEF9A3F7B2C67915 + data[62] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($BEF9A3F7B2C67915) + data[62] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -1053,7 +1053,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($C67178F2E372532B + data[63] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($C67178F2E372532B) + data[63] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -1063,7 +1063,7 @@ begin
 
   // R8
 
-  h := h + ($CA273ECEEA26619C + data[64] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($CA273ECEEA26619C) + data[64] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -1071,7 +1071,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($D186B8C721C0C207 + data[65] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($D186B8C721C0C207) + data[65] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -1079,7 +1079,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($EADA7DD6CDE0EB1E + data[66] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($EADA7DD6CDE0EB1E) + data[66] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -1087,7 +1087,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($F57D4F7FEE6ED178 + data[67] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($F57D4F7FEE6ED178) + data[67] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -1095,7 +1095,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($06F067AA72176FBA + data[68] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($06F067AA72176FBA) + data[68] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -1103,7 +1103,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($0A637DC5A2C898A6 + data[69] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($0A637DC5A2C898A6) + data[69] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -1111,7 +1111,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($113F9804BEF90DAE + data[70] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($113F9804BEF90DAE) + data[70] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -1119,7 +1119,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($1B710B35131C471B + data[71] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($1B710B35131C471B) + data[71] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 
@@ -1129,7 +1129,7 @@ begin
 
   // R9
 
-  h := h + ($28DB77F523047D84 + data[72] + ((TBits.RotateLeft64(e, 50))
+  h := h + (UInt64($28DB77F523047D84) + data[72] + ((TBits.RotateLeft64(e, 50))
     xor (TBits.RotateLeft64(e, 46)) xor (TBits.RotateLeft64(e, 23))) +
     ((e and f) xor (not e and g)));
 
@@ -1137,7 +1137,7 @@ begin
   h := h + (((TBits.RotateLeft64(a, 36)) xor (TBits.RotateLeft64(a, 30))
     xor (TBits.RotateLeft64(a, 25))) + ((a and b) xor (a and c) xor (b and c)));
 
-  g := g + ($32CAAB7B40C72493 + data[73] + ((TBits.RotateLeft64(d, 50))
+  g := g + (UInt64($32CAAB7B40C72493) + data[73] + ((TBits.RotateLeft64(d, 50))
     xor (TBits.RotateLeft64(d, 46)) xor (TBits.RotateLeft64(d, 23))) +
     ((d and e) xor (not d and f)));
 
@@ -1145,7 +1145,7 @@ begin
   g := g + (((TBits.RotateLeft64(h, 36)) xor (TBits.RotateLeft64(h, 30))
     xor (TBits.RotateLeft64(h, 25))) + ((h and a) xor (h and b) xor (a and b)));
 
-  f := f + ($3C9EBE0A15C9BEBC + data[74] + ((TBits.RotateLeft64(c, 50))
+  f := f + (UInt64($3C9EBE0A15C9BEBC) + data[74] + ((TBits.RotateLeft64(c, 50))
     xor (TBits.RotateLeft64(c, 46)) xor (TBits.RotateLeft64(c, 23))) +
     ((c and d) xor (not c and e)));
 
@@ -1153,7 +1153,7 @@ begin
   f := f + (((TBits.RotateLeft64(g, 36)) xor (TBits.RotateLeft64(g, 30))
     xor (TBits.RotateLeft64(g, 25))) + ((g and h) xor (g and a) xor (h and a)));
 
-  e := e + ($431D67C49C100D4C + data[75] + ((TBits.RotateLeft64(b, 50))
+  e := e + (UInt64($431D67C49C100D4C) + data[75] + ((TBits.RotateLeft64(b, 50))
     xor (TBits.RotateLeft64(b, 46)) xor (TBits.RotateLeft64(b, 23))) +
     ((b and c) xor (not b and d)));
 
@@ -1161,7 +1161,7 @@ begin
   e := e + (((TBits.RotateLeft64(f, 36)) xor (TBits.RotateLeft64(f, 30))
     xor (TBits.RotateLeft64(f, 25))) + ((f and g) xor (f and h) xor (g and h)));
 
-  d := d + ($4CC5D4BECB3E42B6 + data[76] + ((TBits.RotateLeft64(a, 50))
+  d := d + (UInt64($4CC5D4BECB3E42B6) + data[76] + ((TBits.RotateLeft64(a, 50))
     xor (TBits.RotateLeft64(a, 46)) xor (TBits.RotateLeft64(a, 23))) +
     ((a and b) xor (not a and c)));
 
@@ -1169,7 +1169,7 @@ begin
   d := d + (((TBits.RotateLeft64(e, 36)) xor (TBits.RotateLeft64(e, 30))
     xor (TBits.RotateLeft64(e, 25))) + ((e and f) xor (e and g) xor (f and g)));
 
-  c := c + ($597F299CFC657E2A + data[77] + ((TBits.RotateLeft64(h, 50))
+  c := c + (UInt64($597F299CFC657E2A) + data[77] + ((TBits.RotateLeft64(h, 50))
     xor (TBits.RotateLeft64(h, 46)) xor (TBits.RotateLeft64(h, 23))) +
     ((h and a) xor (not h and b)));
 
@@ -1177,7 +1177,7 @@ begin
   c := c + (((TBits.RotateLeft64(d, 36)) xor (TBits.RotateLeft64(d, 30))
     xor (TBits.RotateLeft64(d, 25))) + ((d and e) xor (d and f) xor (e and f)));
 
-  b := b + ($5FCB6FAB3AD6FAEC + data[78] + ((TBits.RotateLeft64(g, 50))
+  b := b + (UInt64($5FCB6FAB3AD6FAEC) + data[78] + ((TBits.RotateLeft64(g, 50))
     xor (TBits.RotateLeft64(g, 46)) xor (TBits.RotateLeft64(g, 23))) +
     ((g and h) xor (not g and a)));
 
@@ -1185,7 +1185,7 @@ begin
   b := b + (((TBits.RotateLeft64(c, 36)) xor (TBits.RotateLeft64(c, 30))
     xor (TBits.RotateLeft64(c, 25))) + ((c and d) xor (c and e) xor (d and e)));
 
-  a := a + ($6C44198C4A475817 + data[79] + ((TBits.RotateLeft64(f, 50))
+  a := a + (UInt64($6C44198C4A475817) + data[79] + ((TBits.RotateLeft64(f, 50))
     xor (TBits.RotateLeft64(f, 46)) xor (TBits.RotateLeft64(f, 23))) +
     ((f and g) xor (not f and h)));
 

+ 159 - 6
src/libraries/hashlib4pascal/HlpSHA3.pas

@@ -18,6 +18,8 @@ uses
 {$ENDIF DELPHI}
   HlpIHashInfo,
   HlpIHash,
+  HlpHashResult,
+  HlpIHashResult,
   HlpHashCryptoNotBuildIn,
   HlpConverters,
   HlpHashSize,
@@ -25,13 +27,14 @@ uses
 
 resourcestring
   SInvalidHashMode = 'Only "[%s]" HashModes are Supported';
+  SInvalidXOFSize = 'XOFSize in Bits must be Divisible by 8.';
 
 type
   TSHA3 = class abstract(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   type
 {$SCOPEDENUMS ON}
-    THashMode = (hmKeccak = $1, hmSHA3 = $6);
+    THashMode = (hmKeccak = $1, hmSHA3 = $6, hmShake = $1F);
 {$SCOPEDENUMS OFF}
   strict protected
 
@@ -153,6 +156,41 @@ type
     function Clone(): IHash; override;
   end;
 
+type
+  TShake = class abstract(TSHA3, IXOF)
+  strict private
+  var
+    FXOFSize: THashSize;
+    function GetXOFSize: THashSize; inline;
+    procedure SetXOFSize(a_xof_size: THashSize); inline;
+  strict protected
+    constructor Create(a_hash_size: THashSize);
+    function SetXOFOutputSize(a_xof_size: THashSize): IXOF;
+    property XOFSize: THashSize read GetXOFSize write SetXOFSize;
+
+  public
+    function GetResult(): THashLibByteArray; override;
+    function TransformFinal(): IHashResult; override;
+  end;
+
+type
+  TShake_128 = class sealed(TShake)
+
+  public
+
+    constructor Create();
+    function Clone(): IHash; override;
+  end;
+
+type
+  TShake_256 = class sealed(TShake)
+
+  public
+
+    constructor Create();
+    function Clone(): IHash; override;
+  end;
+
 implementation
 
 { TSHA3 }
@@ -197,10 +235,13 @@ begin
       Result := Format('%s_%u', ['TKeccak', Self.HashSize * 8]);
     TSHA3.THashMode.hmSHA3:
       Result := Self.ClassName;
+    TSHA3.THashMode.hmShake:
+      Result := Format('%s_%s_%u', [Self.ClassName, 'XOFSizeInBits',
+        Int32((Self as IXOF).XOFSize) * 8]);
   else
     begin
       raise EArgumentInvalidHashLibException.CreateResFmt(@SInvalidHashMode,
-        ['hmKeccak, hmSHA3']);
+        ['hmKeccak, hmSHA3, hmShake']);
     end;
   end;
 end;
@@ -236,9 +277,9 @@ end;
 procedure TSHA3.TransformBlock(a_data: PByte; a_data_length: Int32;
   a_index: Int32);
 var
-  data: array [0 .. 17] of UInt64;
+  data: array [0 .. 20] of UInt64;
   Ca, Ce, Ci, Co, Cu, De, Di, &Do, Du, Da: UInt64;
-  j: Int32;
+  j, upcount: Int32;
 {$IFDEF USE_UNROLLED_VARIANT}
   Aba, Abe, Abi, Abo, Abu, Aga, Age, Agi, Ago, Agu, Aka, Ake, Aki, Ako, Aku,
     Ama, Ame, Ami, Amo, Amu, Asa, Ase, Asi, Aso, Asu, Bba, Bbe, Bbi, Bbo, Bbu,
@@ -253,8 +294,8 @@ begin
   TConverters.le64_copy(a_data, a_index, @(data[0]), 0, a_data_length);
 
   j := 0;
-
-  while j < (FBlockSize shr 3) do
+  upcount := FBlockSize shr 3;
+  while j < upcount do
   begin
     Fm_state[j] := Fm_state[j] xor data[j];
     System.Inc(j);
@@ -3098,4 +3139,116 @@ begin
   FHashMode := THashMode.hmKeccak;
 end;
 
+{ TShake }
+
+constructor TShake.Create(a_hash_size: THashSize);
+begin
+  Inherited Create(a_hash_size);
+  FHashMode := THashMode.hmShake;
+end;
+
+function TShake.GetResult: THashLibByteArray;
+var
+  buffer_pos, Idx, LXofSize: Int32;
+  block: THashLibByteArray;
+begin
+  buffer_pos := Fm_buffer.Pos;
+  block := Fm_buffer.GetBytesZeroPadded();
+
+  LXofSize := Int32(FXOFSize);
+  Idx := 0;
+
+  while Idx < LXofSize do
+  begin
+    if buffer_pos >= FBlockSize then
+    begin
+      TransformBlock(PByte(block), System.Length(block), 0);
+      buffer_pos := 0;
+    end;
+    System.Inc(Idx);
+  end;
+
+  System.SetLength(Result, LXofSize);
+
+  TConverters.le64_copy(PUInt64(Fm_state), 0, PByte(Result), 0,
+    System.Length(Result));
+
+end;
+
+function TShake.GetXOFSize: THashSize;
+begin
+  Result := FXOFSize;
+end;
+
+function TShake.TransformFinal: IHashResult;
+var
+  tempresult: THashLibByteArray;
+begin
+  Finish();
+{$IFDEF DEBUG}
+  System.Assert(Fm_buffer.IsEmpty);
+{$ENDIF DEBUG}
+  tempresult := GetResult();
+{$IFDEF DEBUG}
+  System.Assert(System.Length(tempresult) = Int32(XOFSize));
+{$ENDIF DEBUG}
+  Initialize();
+  Result := THashResult.Create(tempresult);
+end;
+
+function TShake.SetXOFOutputSize(a_xof_size: THashSize): IXOF;
+begin
+  If ((Int32(a_xof_size) * 8) and $7) <> 0 then
+  begin
+    raise EArgumentInvalidHashLibException.CreateRes(@SInvalidXOFSize);
+  end;
+  FXOFSize := a_xof_size;
+  Result := Self;
+end;
+
+procedure TShake.SetXOFSize(a_xof_size: THashSize);
+begin
+  SetXOFOutputSize(a_xof_size);
+end;
+
+{ TShake_128 }
+
+function TShake_128.Clone(): IHash;
+var
+  HashInstance: TShake_128;
+begin
+  HashInstance := (TShake_128.Create() as IXOF)
+    .SetXOFOutputSize((Self as IXOF).XOFSize) as TShake_128;
+  HashInstance.Fm_state := System.Copy(Fm_state);
+  HashInstance.Fm_buffer := Fm_buffer.Clone();
+  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
+  Result := HashInstance as IHash;
+  Result.BufferSize := BufferSize;
+end;
+
+constructor TShake_128.Create;
+begin
+  Inherited Create(THashSize.hsHashSize128);
+end;
+
+{ TShake_256 }
+
+function TShake_256.Clone(): IHash;
+var
+  HashInstance: TShake_256;
+begin
+  HashInstance := (TShake_256.Create() as IXOF)
+    .SetXOFOutputSize((Self as IXOF).XOFSize) as TShake_256;
+  HashInstance.Fm_state := System.Copy(Fm_state);
+  HashInstance.Fm_buffer := Fm_buffer.Clone();
+  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
+  Result := HashInstance as IHash;
+  Result.BufferSize := BufferSize;
+end;
+
+constructor TShake_256.Create;
+begin
+  Inherited Create(THashSize.hsHashSize256);
+end;
+
 end.

+ 3 - 4
src/libraries/hashlib4pascal/HlpXXHash32.pas

@@ -20,8 +20,7 @@ resourcestring
 
 type
 
-  TXXHash32 = class sealed(THash, IHash32, IHashWithKey,
-    ITransformBlock)
+  TXXHash32 = class sealed(THash, IHash32, IHashWithKey, ITransformBlock)
 
   strict private
 
@@ -75,7 +74,7 @@ implementation
 
 function TXXHash32.TXXH_State.Clone(): TXXH_State;
 begin
-  result := Default (TXXH_State);
+  result := Default(TXXH_State);
   result.Ftotal_len := Ftotal_len;
   result.Fmemsize := Fmemsize;
   result.Fv1 := Fv1;
@@ -155,7 +154,7 @@ begin
   System.Assert(a_length >= 0);
   System.Assert(a_index + a_length <= System.Length(a_data));
 {$ENDIF DEBUG}
-  ptrBuffer := @a_data[a_index];
+  ptrBuffer := PByte(a_data) + a_index;
   ptrMemory := PByte(F_state.Fmemory);
   F_state.Ftotal_len := F_state.Ftotal_len + UInt64(a_length);
 

+ 3 - 4
src/libraries/hashlib4pascal/HlpXXHash64.pas

@@ -20,8 +20,7 @@ resourcestring
 
 type
 
-  TXXHash64 = class sealed(THash, IHash64, IHashWithKey,
-    ITransformBlock)
+  TXXHash64 = class sealed(THash, IHash64, IHashWithKey, ITransformBlock)
 
   strict private
 
@@ -83,7 +82,7 @@ implementation
 
 function TXXHash64.TXXH_State.Clone(): TXXH_State;
 begin
-  result := Default (TXXH_State);
+  result := Default(TXXH_State);
   result.Ftotal_len := Ftotal_len;
   result.Fmemsize := Fmemsize;
   result.Fv1 := Fv1;
@@ -165,7 +164,7 @@ begin
   System.Assert(a_length >= 0);
   System.Assert(a_index + a_length <= System.Length(a_data));
 {$ENDIF DEBUG}
-  ptrBuffer := @a_data[a_index];
+  ptrBuffer := PByte(a_data) + a_index;
   ptrMemory := PByte(F_state.Fmemory);
   F_state.Ftotal_len := F_state.Ftotal_len + UInt64(a_length);