{************************************************************************}
{ }
{ Borland Delphi Runtime Library }
{ PGPsdk/pgpRandomPool interface unit }
{ }
{ Portions created by PGP/NAI are }
{ Copyright (C) 1997 Network Associates Inc. and affiliated companies. }
{ All Rights Reserved. }
{ }
{ The original file is: pgpRandomPool.h, released 13 Apr 1999. }
{ The original Pascal code is: pgpRandomPool.pas, released 10 Apr 2000. }
{ The initial developer of the Pascal code is Steven R. Heller }
{ <srheller@oz.net> }
{ }
{ Portions created by Steven R. Heller are }
{ Copyright (C) 2000 Steven R. Heller }
{ }
{ Contributors: }
{ The ASM technique for accessing open arrays is based on the }
{ original work of Graham Grieve in Kestral Computing's }
{ PGPAPI.PAS file: <http://www.kestral.com.au/devtools/pgp> }
{ }
{ You may retrieve the latest version of this file here: }
{ <http://www.oz.net/~srheller/pgpsdk> }
{ }
{ Please see }
{ <http://www.oz.net/~srheller/pgpsdk/index.html#randompool> for }
{ information on using this unit. }
{ }
{ The contents of this file are used with permission, subject to }
{ the Mozilla Public License Version 1.1 (the "License"); you may }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at }
{ <http://www.mozilla.org/MPL/MPL-1.1.html> }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
{ implied. See the License for the specific language governing }
{ rights and limitations under the License. }
{ }
{************************************************************************}
unit pgpRandomPool;
interface
uses
pgpBase, pgpPubTypes;
var PGPGlobalRandomPoolAddKeystroke: function (Event: PGPInt32): PGPUInt32; cdecl;
{PGP65+}
var PGPGlobalRandomPoolMouseMoved: function: PGPUInt32; cdecl;
{PGP65+}
var PGPGlobalRandomPoolAddSystemState: function: PGPError; cdecl;
// 'deprecated' since 6.5
var PGPGlobalRandomPoolAddMouse: function (X: PGPUInt32; Y: PGPUInt32): PGPUInt32; cdecl;
// Extra functions for entropy estimation
var PGPGlobalRandomPoolGetEntropy: function: PGPUInt32; cdecl;
var PGPGlobalRandomPoolGetSize: function: PGPUInt32; cdecl;
var PGPGlobalRandomPoolGetMinimumEntropy: function: PGPUInt32; cdecl;
var PGPGlobalRandomPoolHasMinimumEntropy: function: PGPBoolean; cdecl;
{did this unit load the DLL successfully?}
//var pgpRandomPoolLoaded: boolean = false;
function LoadpgpRandomPool: Boolean; //returns True if API successfully loaded
procedure UnLoadpgpRandomPool;
function pgpRandomPoolLoaded: Boolean; //returns if the API is loaded
implementation
uses
Windows;
var
PGPsdkLib : HModule;
function pgpRandomPoolLoaded: boolean;
begin
result := PGPsdkLib >= 32;
end;
function LoadPGPRandomPool: boolean;
begin
result := pgpRandomPoolLoaded;
// try to load PGP 6 version first, then PGP 5.5 version
PGPsdkLib := LoadLibrary('pgp_sdk.dll');
if not pgpRandomPoolLoaded then
PGPsdkLib := LoadLibrary('pgpsdk.dll');
if pgpRandomPoolLoaded then
begin
result := true;
@PGPGlobalRandomPoolAddKeystroke := GetProcAddress(PGPsdkLib,'PGPGlobalRandomPoolAddKeystroke');
@PGPGlobalRandomPoolMouseMoved := GetProcAddress(PGPsdkLib,'PGPGlobalRandomPoolMouseMoved');
@PGPGlobalRandomPoolAddSystemState := GetProcAddress(PGPsdkLib,'PGPGlobalRandomPoolAddSystemState');
@PGPGlobalRandomPoolAddMouse := GetProcAddress(PGPsdkLib,'PGPGlobalRandomPoolAddMouse');
@PGPGlobalRandomPoolGetEntropy := GetProcAddress(PGPsdkLib,'PGPGlobalRandomPoolGetEntropy');
@PGPGlobalRandomPoolGetSize := GetProcAddress(PGPsdkLib,'PGPGlobalRandomPoolGetSize');
@PGPGlobalRandomPoolGetMinimumEntropy := GetProcAddress(PGPsdkLib,'PGPGlobalRandomPoolGetMinimumEntropy');
@PGPGlobalRandomPoolHasMinimumEntropy := GetProcAddress(PGPsdkLib,'PGPGlobalRandomPoolHasMinimumEntropy');
end;
end;
procedure UnLoadpgpRandomPool;
begin
if pgpRandomPoolLoaded then
begin
if PGPsdkLib <> 0 then
FreeLibrary(PGPsdkLib);
PGPsdkLib := 0;
end;
end;
initialization
LoadPGPRandomPool;
finalization
if pgpRandomPoolLoaded then
UnloadpgpRandomPool;
end.