----------------------------------------------------------------------------- }\r
\r
unit lcorernd;\r
-\r
+{$ifdef fpc}\r
+ {$mode delphi}\r
+{$endif}\r
interface\r
\r
{$include lcoreconfig.inc}\r
{$endif}\r
{$endif}\r
fastmd5,sysutils;\r
+{$endif}\r
+\r
+const\r
+ wordsizeshift=2;\r
+ wordsize=1 shl wordsizeshift;\r
+\r
+{$ifndef nolcorernd}\r
\r
{$ifdef unix}{$include unixstuff.inc}{$endif}\r
\r
hashtype=tmd5;\r
\r
const\r
- wordsizeshift=2;\r
- wordsize=1 shl wordsizeshift;\r
//wordsize check commented out for d3 compatibility\r
//{ $if (wordsize <> sizeof(wordtype))}'wordsizeshift must be setcorrectly'{ $ifend}\r
hashsize=sizeof(hashtype);\r
halfhashsize=hashsize div 2;\r
hashdwords=hashsize div wordsize;\r
pooldwords=3*hashdwords;\r
- seeddwords=32;\r
+ seeddwords=40;\r
hashpasssize=48; {this number has to be small enough that hashing this size uses only one block transform}\r
\r
var\r
- {the seed part of this buffer must be at least as big as the OS seed (windows: 104 bytes, unix: 36 bytes)}\r
+ //the seed part of this buffer must be at least as big as the OS seed (windows: 120 bytes for 32 bits, 160 bytes for 64 bits, unix: 36 bytes)\r
pool:array[0..(pooldwords+seeddwords-1)] of wordtype;\r
reseedcountdown:integer;\r
\r
{$ifdef mswindows}\r
+var\r
+ systemfunction036:function(var v; c:cardinal): boolean; stdcall;\r
+ rtlgenrandominited:boolean;\r
+\r
+procedure initrtlgenrandom;\r
+var\r
+ h:thandle;\r
+begin\r
+ rtlgenrandominited := true;\r
+ systemfunction036 := nil; \r
+ h := loadlibrary('advapi32.dll');\r
+ if (h <> 0) then begin\r
+ systemfunction036 := GetProcAddress(h,'SystemFunction036');\r
+ end;\r
+end;\r
+\r
function collect_seeding(var output;const bufsize:integer):integer;\r
var\r
l:packed record\r
+ rtlgenrandom:array[0..3] of longint;\r
guid:array[0..3] of longint;\r
qpcbuf:array[0..1] of longint;\r
rdtscbuf:array[0..1] of longint;\r
getcursorpos(l.cursor);\r
\r
l.hs := getheapstatus;\r
+\r
+ {rtlgenrandom}\r
+ if not rtlgenrandominited then initrtlgenrandom;\r
+ if assigned(@systemfunction036) then systemfunction036(l.rtlgenrandom,sizeof(l.rtlgenrandom));\r
end;\r
{$endif}\r
\r