/************************************************* * Module Factory Source File * * (C) 1999-2006 The Botan Project * *************************************************/ #include #include #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 { /************************************************* * Return a mutex factory, if available * *************************************************/ Mutex_Factory* Builtin_Modules::mutex_factory() const { #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; #else return 0; #endif } /************************************************* * Find a high resolution timer, if possible * *************************************************/ Timer* Builtin_Modules::timer() const { #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; #else return new Timer; #endif } /************************************************* * Find any usable allocators * *************************************************/ std::vector Builtin_Modules::allocators() const { std::vector allocators; #if defined(BOTAN_EXT_ALLOC_MMAP) allocators.push_back(new MemoryMapping_Allocator); #endif allocators.push_back(new Locking_Allocator); allocators.push_back(new Malloc_Allocator); return allocators; } /************************************************* * Return the default allocator * *************************************************/ std::string Builtin_Modules::default_allocator() const { if(should_lock) { #if defined(BOTAN_EXT_ALLOC_MMAP) return "mmap"; #else return "locking"; #endif } else return "malloc"; } /************************************************* * Register any usable entropy sources * *************************************************/ std::vector Builtin_Modules::entropy_sources() const { 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 Builtin_Modules::engines() const { 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 engines.push_back(new Default_Engine); return engines; } }