From 64005e4a670ae074eea1980c5eca131748884ec0 Mon Sep 17 00:00:00 2001 From: beware Date: Mon, 2 Mar 2015 07:19:22 +0000 Subject: [PATCH] use RtlGenRandom (SystemFunction036) in lcorernd if the system supports it git-svn-id: file:///svnroot/lcore/trunk@141 b1de8a11-f9be-4011-bde0-cc7ace90066a --- lcorernd.pas | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lcorernd.pas b/lcorernd.pas index 7dbd7f1..b76ab49 100644 --- a/lcorernd.pas +++ b/lcorernd.pas @@ -180,14 +180,31 @@ const hashpasssize=48; {this number has to be small enough that hashing this size uses only one block transform} var - {the seed part of this buffer must be at least as big as the OS seed (windows: 104 bytes, unix: 36 bytes)} + {the seed part of this buffer must be at least as big as the OS seed (windows: 120 bytes, unix: 36 bytes)} pool:array[0..(pooldwords+seeddwords-1)] of wordtype; reseedcountdown:integer; {$ifdef mswindows} +var + systemfunction036:function(var v; c:cardinal): boolean; stdcall; + rtlgenrandominited:boolean; + +procedure initrtlgenrandom; +var + h:thandle; +begin + rtlgenrandominited := true; + systemfunction036 := nil; + h := loadlibrary('advapi32.dll'); + if (h <> 0) then begin + systemfunction036 := GetProcAddress(h,'SystemFunction036'); + end; +end; + function collect_seeding(var output;const bufsize:integer):integer; var l:packed record + rtlgenrandom:array[0..3] of longint; guid:array[0..3] of longint; qpcbuf:array[0..1] of longint; rdtscbuf:array[0..1] of longint; @@ -221,6 +238,10 @@ begin getcursorpos(l.cursor); l.hs := getheapstatus; + + {rtlgenrandom} + if not rtlgenrandominited then initrtlgenrandom; + if assigned(@systemfunction036) then systemfunction036(l.rtlgenrandom,sizeof(l.rtlgenrandom)); end; {$endif} -- 2.30.2