ikptr
ikrt_ssleay_add_all_digests (ikpcb * pcb)
{
#if ((defined HAVE_DECL_SSLEAY_ADD_ALL_DIGESTS) && HAVE_DECL_SSLEAY_ADD_ALL_DIGESTS)
  SSLeay_add_all_digests();
  return IK_VOID;
#else
  feature_failure(__func__);
#endif
}
예제 #2
0
// Setup OpenSSL
void __fastcall util_openssl_init()
{
	char* tbuf[64];
#ifdef WIN32
	HMODULE g_hAdvLib = NULL;
	BOOLEAN (APIENTRY *g_CryptGenRandomPtr)(void*, ULONG) = NULL;
#endif
#ifdef _POSIX
	int l;
#endif

/*
#ifdef _DEBUG
	CRYPTO_malloc_debug_init();
	//CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
	MemCheck_start();
	CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
#endif
*/

	SSLeay_add_all_algorithms();
	SSLeay_add_all_ciphers();
	SSLeay_add_all_digests();

	SSL_library_init(); // TWO LEAKS COMING FROM THIS LINE. Seems to be a well known OpenSSL problem.
	SSL_load_error_strings();
	ERR_load_crypto_strings(); // ONE LEAK IN LINUX

	// Add more random seeding in Windows (This is probably useful since OpenSSL in Windows has weaker seeding)
#ifdef WIN32
	//RAND_screen(); // On Windows, add more random seeding using a screen dump (this is very expensive).
	if ((g_hAdvLib = LoadLibrary(TEXT("ADVAPI32.DLL"))) != 0) g_CryptGenRandomPtr = (BOOLEAN (APIENTRY *)(void*,ULONG))GetProcAddress(g_hAdvLib,"SystemFunction036");
	if (g_CryptGenRandomPtr != 0 && g_CryptGenRandomPtr(tbuf, 64) != 0) RAND_add(tbuf, 64, 64); // Use this high quality random as added seeding
	if (g_hAdvLib != NULL) FreeLibrary(g_hAdvLib);
#endif

	// Add more random seeding in Linux (May be overkill since OpenSSL already uses /dev/urandom)
#ifdef _POSIX
	// Under Linux we use "/dev/urandom" if available. This is the best source of random on Linux & variants
	FILE *pFile = fopen("/dev/urandom","rb");
	if (pFile != NULL)
	{
		l = fread(tbuf, 1, 64, pFile);
		fclose(pFile);
		if (l > 0) RAND_add(tbuf, l, l);
	}
#endif
}