/************************************************* * Module Factory Source File * * (C) 1999-2006 The Botan Project * *************************************************/ #include #include #if defined(BOTAN_EXT_MUTEX_PTHREAD) #include #elif defined(BOTAN_EXT_MUTEX_WIN32) #include #elif defined(BOTAN_EXT_MUTEX_QT) #include #endif #if defined(BOTAN_EXT_ALLOC_MMAP) #include #endif #if defined(BOTAN_EXT_TIMER_HARDWARE) #include #elif defined(BOTAN_EXT_TIMER_POSIX) #include #elif defined(BOTAN_EXT_TIMER_UNIX) #include #elif defined(BOTAN_EXT_TIMER_WIN32) #include #endif #if defined(BOTAN_EXT_ENGINE_AEP) #include #endif #if defined(BOTAN_EXT_ENGINE_GNU_MP) #include #endif #if defined(BOTAN_EXT_ENGINE_OPENSSL) #include #endif #if defined(BOTAN_EXT_ENTROPY_SRC_AEP) #include #endif #if defined(BOTAN_EXT_ENTROPY_SRC_EGD) #include #endif #if defined(BOTAN_EXT_ENTROPY_SRC_UNIX) #include #endif #if defined(BOTAN_EXT_ENTROPY_SRC_BEOS) #include #endif #if defined(BOTAN_EXT_ENTROPY_SRC_CAPI) #include #endif #if defined(BOTAN_EXT_ENTROPY_SRC_WIN32) #include #endif #if defined(BOTAN_EXT_ENTROPY_SRC_FTW) #include #endif namespace Botan { namespace Modules { /************************************************* * Register a mutex type, if possible * *************************************************/ Mutex_Factory* get_mutex_factory() { #if defined(BOTAN_EXT_MUTEX_PTHREAD) return new Pthread_Mutex_Factory; #elif defined(BOTAN_EXT_MUTEX_WIN32) return new Win32_Mutex_Factory; #elif defined(BOTAN_EXT_MUTEX_QT) return new Qt_Mutex_Factory; #endif return 0; } /************************************************* * Find a high resolution timer, if possible * *************************************************/ Timer* get_timer() { #if defined(BOTAN_EXT_TIMER_HARDWARE) return new Hardware_Timer; #elif defined(BOTAN_EXT_TIMER_POSIX) return new POSIX_Timer; #elif defined(BOTAN_EXT_TIMER_UNIX) return new Unix_Timer; #elif defined(BOTAN_EXT_TIMER_WIN32) return new Win32_Timer; #endif return 0; } /************************************************* * Find any usable allocators * *************************************************/ std::map get_allocators() { std::map allocators; #if defined(BOTAN_EXT_ALLOC_MMAP) allocators["mmap"] = new MemoryMapping_Allocator; #endif return allocators; } /************************************************* * Register any usable entropy sources * *************************************************/ std::vector get_entropy_sources() { std::vector sources; sources.push_back(new File_EntropySource); #if defined(BOTAN_EXT_ENTROPY_SRC_AEP) sources.push_back(new AEP_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_EGD) sources.push_back(new EGD_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_CAPI) sources.push_back(new Win32_CAPI_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_WIN32) sources.push_back(new Win32_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_UNIX) sources.push_back(new Unix_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_BEOS) sources.push_back(new BeOS_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_FTW) sources.push_back(new FTW_EntropySource); #endif return sources; } /************************************************* * Find any usable engines * *************************************************/ std::vector get_engines() { std::vector engines; #if defined(BOTAN_EXT_ENGINE_AEP) engines.push_back(new AEP_Engine); #endif #if defined(BOTAN_EXT_ENGINE_GNU_MP) engines.push_back(new GMP_Engine); #endif #if defined(BOTAN_EXT_ENGINE_OPENSSL) engines.push_back(new OpenSSL_Engine); #endif return engines; } } }