⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgpentropy.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
字号:
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.

	pgpEntropy.c - interfaces the PGP Utility Driver to the SDK-derived 
	               hashing and entropy code
	

	$Id: pgpEntropy.c,v 1.4 2002/08/06 20:11:19 dallen Exp $
____________________________________________________________________________*/

#include "pgpUDx.h"
#include "PGPsdkDriver.h"
#include "pgpEntropy.h"
#include "pgpMisc.h"

// prototypes
	ULONG
PGPWin32DriverRandomPoolMouseMoved(
	ULONG		bForceAdd,
	ULONG 		timerval_lo);

	ULONG
PGPWin32DriverRandomPoolAddKeystroke(
	ULONG		bForceAdd,
	ULONG 		timerval_lo, 
	ULONG		keyscan);

	VOID
PGPWin32DriverRandomPoolGetBytesEntropy(
	PUCHAR		buf,
	ULONG		len,
	ULONG		bitsRequested,
	PULONG		bitsProvided);

	ULONG
PGPWin32DriverRandomPoolGetEntropy(VOID);

	ULONG
pgpInitGlobalRandomPool(VOID);


//	______________________________________________________
//
//	Add a keystroke event to the random pool.

VOID
pgpEntropyAddKeystrokeEvent (
    IN ULONG	ulForceAdd,
    IN ULONG	ulEvent)
{
	ULONG		ulLo;

	pgpDriverGetHiResTime (&ulLo);

	PGPWin32DriverRandomPoolAddKeystroke (ulForceAdd, ulLo, ulEvent);
}


//	______________________________________________________
//
//	Add a mouse event to the random pool.

VOID
pgpEntropyAddMouseEvent (
    IN ULONG	ulForceAdd)
{
	ULONG		ulLo;

	pgpDriverGetHiResTime (&ulLo);

	PGPWin32DriverRandomPoolMouseMoved (ulForceAdd, ulLo);
}


//	______________________________________________________
//
//	Initialize the entropy pool 

VOID
pgpEntropyInit (VOID)
{
	pgpInitGlobalRandomPool ();

	pgpEntropyAddKeystrokeEvent (1, 0);
	pgpEntropyAddKeystrokeEvent (1, 0);
	pgpEntropyAddKeystrokeEvent (1, 0);
	pgpEntropyAddKeystrokeEvent (1, 0);
}


//	______________________________________________________
//
//	This is the function that processes the DeviceIoControl
//	call which is coming down from the Win32 application.

VOID
pgpEntropyProcessOperation (
	IN PPGPENTROPYSTRUCT	ppes,
	IN PVOID				pCriticalSection)
{
	switch (ppes->ulOperation) {

	case kPGPUDOperation_QueryEntropy :
		pgpDriverEnterCriticalSection (pCriticalSection, MUTEX);
		ppes->ulEntropyBits = PGPWin32DriverRandomPoolGetEntropy ();
		pgpDriverLeaveCriticalSection (pCriticalSection, MUTEX);
		ppes->ulError = kPGPUDError_NoErr;
		break;

	case kPGPUDOperation_GetEntropy :
		pgpDriverEnterCriticalSection (pCriticalSection, MUTEX);
		PGPWin32DriverRandomPoolGetBytesEntropy (
					ppes->ucEntropyBuffer, 
					ppes->ulBufferLength, 
					8*ppes->ulBufferLength, 
					&ppes->ulEntropyBits);
		pgpDriverLeaveCriticalSection (pCriticalSection, MUTEX);

		ppes->ulError = kPGPUDError_NoErr;
		break;

///	case kPGPUDOperation_PutEntropy :
///		break;

	default :
		ppes->ulError = kPGPUDError_UndefinedOperation;
		break;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -