/************************************************* * Module Factory Source File * * (C) 1999-2006 The Botan Project * *************************************************/ #include #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 0; #endif } /************************************************* * Set any usable allocators * *************************************************/ void Builtin_Modules::set_allocators(Library_State& state, bool secure_mem) const { state.add_allocator(new Malloc_Allocator, !secure_mem); state.add_allocator(new Locking_Allocator, secure_mem); #if defined(BOTAN_EXT_ALLOC_MMAP) state.add_allocator(new MemoryMapping_Allocator, secure_mem); #endif } /************************************************* * Register any usable entropy sources * *************************************************/ void Builtin_Modules::set_entropy_sources(Library_State& state) const { state.add_entropy_source(new File_EntropySource); #if defined(BOTAN_EXT_ENTROPY_SRC_AEP) state.add_entropy_source(new AEP_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_EGD) state.add_entropy_source(new EGD_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_CAPI) state.add_entropy_source(new Win32_CAPI_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_WIN32) state.add_entropy_source(new Win32_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_UNIX) state.add_entropy_source(new Unix_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_BEOS) state.add_entropy_source(new BeOS_EntropySource); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_FTW) state.add_entropy_source(new FTW_EntropySource); #endif } /************************************************* * Find any usable engines * *************************************************/ void Builtin_Modules::set_engines(Library_State& state, bool use_engines) const { if(use_engines) { #if defined(BOTAN_EXT_ENGINE_AEP) state.add_engine(new AEP_Engine); #endif #if defined(BOTAN_EXT_ENGINE_GNU_MP) state.add_engine(new GMP_Engine); #endif #if defined(BOTAN_EXT_ENGINE_OPENSSL) state.add_engine(new OpenSSL_Engine); #endif } state.add_engine(new Default_Engine); } }