From 67905957cb7f433c153ca53146a5910dbdacff22 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 28 Apr 2022 23:07:54 +0200 Subject: [PATCH] fcl-hash: fixed HexStrToBytes --- packages/fcl-hash/src/fphashutils.pp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/fcl-hash/src/fphashutils.pp b/packages/fcl-hash/src/fphashutils.pp index 06a85ca75c..91b8fff2ec 100644 --- a/packages/fcl-hash/src/fphashutils.pp +++ b/packages/fcl-hash/src/fphashutils.pp @@ -123,7 +123,7 @@ Var begin Len:=Length(aHexStr); aBytes:=[]; - SetLength(aBytes, Len div 2); + SetLength(aBytes, (Len+1) div 2); if Len=0 then Exit; P := PAnsiChar(aHexStr); PResult := PByte(aBytes); @@ -160,9 +160,9 @@ var begin aHexStr:=''; - SetLength(aHexStr,aSize*2); if aSize=0 then exit; + SetLength(aHexStr,aSize*2); PB:=aBytes; PC:=PChar(aHexStr); for I:=0 to aSize-1 do @@ -385,9 +385,7 @@ begin Result := rs1 xor rs2 xor result; end; - function CryptoGetRandomBytes(Buffer: PByte; const Count: Integer): Boolean; - var I, Remainder, Rounds: Integer; Lecuyer: TLecuyer; @@ -402,8 +400,8 @@ begin if Remainder > 0 then begin R := Lecuyer.Next; - Move(R, PByteArray(Buffer)[Rounds*SizeOf(UInt32)], Remainder); - R:=R+R;// Silence compiler warning + Move(R, Buffer[Rounds*SizeOf(UInt32)], Remainder); + R:=R-R;// Silence compiler warning end; end;