--- truecrypt/common/random.h 2018/04/24 16:39:59 1.1.1.3 +++ truecrypt/common/random.h 2018/04/24 16:46:35 1.1.1.9 @@ -1,23 +1,43 @@ -/* The source code contained in this file has been derived from the source code - of Encryption for the Masses 2.02a by Paul Le Roux. Modifications and - additions to that source code contained in this file are Copyright (c) 2004 - TrueCrypt Team and Copyright (c) 2004 TrueCrypt Foundation. Unmodified - parts are Copyright (c) 1998-99 Paul Le Roux. This is a TrueCrypt Foundation - release. Please see the file license.txt for full license details. */ +/* + Legal Notice: The source code contained in this file has been derived from + the source code of Encryption for the Masses 2.02a, which is Copyright (c) + Paul Le Roux and which is covered by the 'License Agreement for Encryption + for the Masses'. Modifications and additions to that source code contained + in this file are Copyright (c) TrueCrypt Foundation and are covered by the + TrueCrypt License 2.2 the full text of which is contained in the file + License.txt included in TrueCrypt binary and source code distribution + packages. */ -/* Everything below this line is automatically updated by the -mkproto-tool- */ -_inline void _RandaddLong ( unsigned long x ); +#include "Crypto.h" + +/* RNG defines & pool pointers */ +#define RNG_POOL_SIZE 320 // Must be divisible by the size of the output of each of the implemented hash functions. (in bytes) +#if RNG_POOL_SIZE % SHA1_DIGESTSIZE || RNG_POOL_SIZE % WHIRLPOOL_DIGESTSIZE || RNG_POOL_SIZE % RIPEMD160_DIGESTSIZE +#error RNG_POOL_SIZE must be divisible by the size of the output of each of the implemented hash functions. +#endif + +#define RANDOMPOOL_ALLOCSIZE RNG_POOL_SIZE + +void RandAddInt ( unsigned __int32 x ); int Randinit ( void ); void Randfree ( void ); -void RandSetHashFunction ( int hash ); -void Randmix ( void ); +void RandSetHashFunction ( int hash_algo_id ); +int RandGetHashFunction (void); +BOOL Randmix ( void ); void RandaddBuf ( void *buf , int len ); -void RandpeekBytes ( char *buf , int len ); -void RandgetBytes ( char *buf , int len, BOOL forceSlowPoll ); +BOOL FastPoll ( void ); +BOOL SlowPoll ( void ); +BOOL RandpeekBytes ( unsigned char *buf , int len ); +BOOL RandgetBytes ( unsigned char *buf , int len, BOOL forceSlowPoll ); + +#ifdef _WIN32 + +extern BOOL volatile bFastPollEnabled; +extern BOOL volatile bRandmixEnabled; + LRESULT CALLBACK MouseProc ( int nCode , WPARAM wParam , LPARAM lParam ); LRESULT CALLBACK KeyboardProc ( int nCode , WPARAM wParam , LPARAM lParam ); void ThreadSafeThreadFunction ( void *dummy ); -void SlowPollWinNT ( void ); -void SlowPollWin9x ( void ); -void FastPoll ( void ); + +#endif