From 216c848075589f86f1051eca2d6b35b0e99a33b0 Mon Sep 17 00:00:00 2001 From: mattias <nc-gaertnma@netcologne.de> Date: Fri, 29 Apr 2022 02:18:42 +0200 Subject: [PATCH] fcl-hash: use randomize --- packages/fcl-hash/src/fpasn.pp | 1 + packages/fcl-hash/src/fphashutils.pp | 25 +------------------------ 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/packages/fcl-hash/src/fpasn.pp b/packages/fcl-hash/src/fpasn.pp index add2671322..70b586b271 100644 --- a/packages/fcl-hash/src/fpasn.pp +++ b/packages/fcl-hash/src/fpasn.pp @@ -2,6 +2,7 @@ unit fpasn; {$mode ObjFPC}{$H+} {$modeswitch advancedrecords} + interface uses diff --git a/packages/fcl-hash/src/fphashutils.pp b/packages/fcl-hash/src/fphashutils.pp index 768ffe2ee1..a8ab066ed2 100644 --- a/packages/fcl-hash/src/fphashutils.pp +++ b/packages/fcl-hash/src/fphashutils.pp @@ -19,10 +19,6 @@ unit fphashutils; {$mode ObjFPC}{$H+} {$modeswitch advancedrecords} -{$IF defined(CPUi386) or defined(CPUx86_64) } - {$define HasRDTSCP} -{$ENDIF} - interface uses @@ -436,39 +432,20 @@ begin Result:=Copy(aSource,P1,P2-P1); end; -{$IFDEF HasRDTSCP} -function RDTSCP: Int64; assembler; nostackframe; -asm - RDTSCP -end; -{$ENDIF} - function IntGetRandomNumber(aBytes : PByte; aCount: Integer): Boolean; Var i: Integer; P : PByte; - {$IFDEF HasRDTSCP} - {%H-}i64: int64; - j: integer; - {$ENDIF} begin + Randomize; P:=aBytes; i:=0; while i<aCount do begin - {$IFDEF HasRDTSCP} - i64:=RDTSCP; - j:=aCount-i; - if j>8 then j:=8; - system.move(i64,P^,j); - inc(p,j); - inc(i,j); - {$ELSE} P^:=Random(256); Inc(P); inc(i); - {$ENDIF} end; Result:=True; end;