diff options
-rw-r--r-- | checks/dolook.cpp | 12 | ||||
-rwxr-xr-x | configure.pl | 42 | ||||
-rw-r--r-- | doc/building.tex | 4 | ||||
-rw-r--r-- | doc/examples/bzip.cpp | 4 | ||||
-rw-r--r-- | doc/examples/decrypt.cpp | 4 | ||||
-rw-r--r-- | doc/examples/encrypt.cpp | 4 | ||||
-rw-r--r-- | doc/examples/hash_fd.cpp | 2 | ||||
-rw-r--r-- | include/pipe.h | 2 | ||||
-rw-r--r-- | src/def_alg.cpp | 8 | ||||
-rw-r--r-- | src/modules.cpp | 26 | ||||
-rw-r--r-- | src/rng.cpp | 44 |
11 files changed, 93 insertions, 59 deletions
diff --git a/checks/dolook.cpp b/checks/dolook.cpp index 854c770b7..5757c6042 100644 --- a/checks/dolook.cpp +++ b/checks/dolook.cpp @@ -4,15 +4,15 @@ #include <botan/lookup.h> #include <botan/filters.h> -#ifdef BOTAN_EXT_COMPRESSOR_BZIP2 +#ifdef BOTAN_HAS_COMPRESSOR_BZIP2 #include <botan/bzip2.h> #endif -#ifdef BOTAN_EXT_COMPRESSOR_GZIP +#ifdef BOTAN_HAS_COMPRESSOR_GZIP #include <botan/gzip.h> #endif -#ifdef BOTAN_EXT_COMPRESSOR_ZLIB +#ifdef BOTAN_HAS_COMPRESSOR_ZLIB #include <botan/zlib.h> #endif @@ -104,21 +104,21 @@ Filter* lookup_encoder(const std::string& algname) if(algname == "Base64_Decode") return new Base64_Decoder; -#ifdef BOTAN_EXT_COMPRESSOR_BZIP2 +#ifdef BOTAN_HAS_COMPRESSOR_BZIP2 if(algname == "Bzip_Compression") return new Bzip_Compression(9); if(algname == "Bzip_Decompression") return new Bzip_Decompression; #endif -#ifdef BOTAN_EXT_COMPRESSOR_GZIP +#ifdef BOTAN_HAS_COMPRESSOR_GZIP if(algname == "Gzip_Compression") return new Gzip_Compression(9); if(algname == "Gzip_Decompression") return new Gzip_Decompression; #endif -#ifdef BOTAN_EXT_COMPRESSOR_ZLIB +#ifdef BOTAN_HAS_COMPRESSOR_ZLIB if(algname == "Zlib_Compression") return new Zlib_Compression(9); if(algname == "Zlib_Decompression") diff --git a/configure.pl b/configure.pl index a3d7181a6..b35349304 100755 --- a/configure.pl +++ b/configure.pl @@ -275,6 +275,8 @@ To change what modules to use: --modules= [$modules] + --disable-modules=module1[,module2[...]] + To add a set of modules: --module-set=[$sets] @@ -420,8 +422,17 @@ sub autoload_modules { my $realname = $modinfo{'realname'}; if(defined($$config{'modules'}{$mod})) { - autoconfig("$mod ($realname): loading by user request"); - next; + + my $n = $$config{'modules'}{$mod}; + + if($n < 0) { + autoconfig("$mod ($realname): disabled by user request"); + next; + } + else { + autoconfig("$mod ($realname): loading by user request"); + next; + } } my @arch_list = @{ $modinfo{'arch'} }; @@ -518,7 +529,17 @@ sub get_options { my ($config,$mods) = @_; foreach my $mod (split(/,/, $mods)) { - $$config{'modules'}{$mod} = 1; + # -1 means disabled by user, do not load + $$config{'modules'}{$mod} = 1 unless($$config{'modules'}{$mod} == -1); + } + } + + sub disable_modules { + my ($config,$mods) = @_; + + foreach my $mod (split(/,/, $mods)) { + # -1 means disabled by user, do not load + $$config{'modules'}{$mod} = -1; } } @@ -526,14 +547,14 @@ sub get_options { my ($config,$sets) = @_; foreach my $set (split(/,/, $sets)) { - for my $name (sort keys %MODULES) { - my %info = %{$MODULES{$name}}; + for my $mod (sort keys %MODULES) { + my %info = %{$MODULES{$mod}}; next unless (defined($info{'modset'})); for my $s (split(/,/, $info{'modset'})) { if($s eq $set) { - $$config{'modules'}{$name} = 1; + $$config{'modules'}{$mod} = 1 unless($$config{'modules'}{$mod} == -1); } } } @@ -569,6 +590,8 @@ sub get_options { 'module-set=s' => sub { add_module_sets($config, $_[1]); }, 'module-sets=s' => sub { add_module_sets($config, $_[1]); }, + 'disable-modules=s' => sub { disable_modules($config, $_[1]); }, + 'trace' => sub { $TRACING = 1; }, 'debug' => sub { &$save_option($_[0], 1); }, 'no-shared' => sub { $$config{'shared'} = 'no'; }, @@ -961,6 +984,9 @@ sub load_modules { my @mod_names; foreach my $mod (sort keys %{$$config{'modules'}}) { + + next unless($$config{'modules'}{$mod} > 0); + load_module($config, $mod); foreach my $req_mod (@{$MODULES{$mod}{'requires'}}) { @@ -1044,6 +1070,8 @@ sub load_modules { my @defarray; foreach my $mod (sort keys %{$$config{'modules'}}) { + next unless $$config{'modules'}{$mod} > 0; + my $defs = $MODULES{$mod}{'define'}; next unless $defs; @@ -1054,7 +1082,7 @@ sub load_modules { foreach (sort @defarray) { die unless(defined $_ and $_ ne ''); - $defines .= "#define BOTAN_EXT_$_\n"; + $defines .= "#define BOTAN_HAS_$_\n"; } chomp($defines); return $defines; diff --git a/doc/building.tex b/doc/building.tex index 2cb1d0723..3a378947e 100644 --- a/doc/building.tex +++ b/doc/building.tex @@ -190,8 +190,8 @@ overwritten every time the configure script is run (and does not exist until after you run the script for the first time). Also included in \filename{config.h} are macros which are defined if one or -more extensions are available. All of them begin with \verb|BOTAN_EXT_|. For -example, if \verb|BOTAN_EXT_COMPRESSOR_BZIP2| is defined, then an application +more extensions are available. All of them begin with \verb|BOTAN_HAS_|. For +example, if \verb|BOTAN_HAS_COMPRESSOR_BZIP2| is defined, then an application using Botan can include \filename{<botan/bzip2.h>} and use the Bzip2 filters. \macro{BOTAN\_MP\_WORD\_BITS}: This macro controls the size of the diff --git a/doc/examples/bzip.cpp b/doc/examples/bzip.cpp index a16d4f8fe..1abe4d309 100644 --- a/doc/examples/bzip.cpp +++ b/doc/examples/bzip.cpp @@ -12,7 +12,7 @@ This file is in the public domain #include <iostream> #include <botan/botan.h> -#if defined(BOTAN_EXT_COMPRESSOR_BZIP2) +#if defined(BOTAN_HAS_COMPRESSOR_BZIP2) #include <botan/bzip2.h> #endif @@ -51,7 +51,7 @@ int main(int argc, char* argv[]) try { Botan::Filter* bzip = 0; -#ifdef BOTAN_EXT_COMPRESSOR_BZIP2 +#ifdef BOTAN_HAS_COMPRESSOR_BZIP2 if(decompress) bzip = new Botan::Bzip_Decompression(small); else diff --git a/doc/examples/decrypt.cpp b/doc/examples/decrypt.cpp index e0c4a1f48..7018e5f49 100644 --- a/doc/examples/decrypt.cpp +++ b/doc/examples/decrypt.cpp @@ -18,7 +18,7 @@ This file is in the public domain #include <botan/botan.h> -#if defined(BOTAN_EXT_COMPRESSOR_ZLIB) +#if defined(BOTAN_HAS_COMPRESSOR_ZLIB) #include <botan/zlib.h> #endif @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) Pipe pipe(new Base64_Decoder, get_cipher(algo + "/CBC", bc_key, iv, DECRYPTION), -#ifdef BOTAN_EXT_COMPRESSOR_ZLIB +#ifdef BOTAN_HAS_COMPRESSOR_ZLIB new Zlib_Decompression, #endif new Fork( diff --git a/doc/examples/encrypt.cpp b/doc/examples/encrypt.cpp index 7c8649004..959461b63 100644 --- a/doc/examples/encrypt.cpp +++ b/doc/examples/encrypt.cpp @@ -26,7 +26,7 @@ This file is in the public domain #include <botan/botan.h> -#if defined(BOTAN_EXT_COMPRESSOR_ZLIB) +#if defined(BOTAN_HAS_COMPRESSOR_ZLIB) #include <botan/zlib.h> #endif @@ -140,7 +140,7 @@ int main(int argc, char* argv[]) new Base64_Encoder ), new Chain( -#ifdef BOTAN_EXT_COMPRESSOR_ZLIB +#ifdef BOTAN_HAS_COMPRESSOR_ZLIB new Zlib_Compression, #endif get_cipher(algo + "/CBC", bc_key, iv, ENCRYPTION), diff --git a/doc/examples/hash_fd.cpp b/doc/examples/hash_fd.cpp index d6487095a..1deed6988 100644 --- a/doc/examples/hash_fd.cpp +++ b/doc/examples/hash_fd.cpp @@ -18,7 +18,7 @@ I guess any POSIX.1 compliant OS (in theory). #include <iostream> #include <botan/botan.h> -#if !defined(BOTAN_EXT_PIPE_UNIXFD_IO) +#if !defined(BOTAN_HAS_PIPE_UNIXFD_IO) #error "You didn't compile the pipe_unixfd module into Botan" #endif diff --git a/include/pipe.h b/include/pipe.h index ee13ad640..3c41f6ebe 100644 --- a/include/pipe.h +++ b/include/pipe.h @@ -95,6 +95,6 @@ BOTAN_DLL std::istream& operator>>(std::istream&, Pipe&); #endif -#if defined(BOTAN_EXT_PIPE_UNIXFD_IO) +#if defined(BOTAN_HAS_PIPE_UNIXFD_IO) #include <botan/fd_unix.h> #endif diff --git a/src/def_alg.cpp b/src/def_alg.cpp index bba904b11..835aa03e2 100644 --- a/src/def_alg.cpp +++ b/src/def_alg.cpp @@ -37,7 +37,10 @@ #include <botan/turing.h> #include <botan/wid_wake.h> -#include <botan/adler32.h> +#ifdef BOTAN_HAS_ADLER32 + #include <botan/adler32.h> +#endif + #include <botan/crc24.h> #include <botan/crc32.h> #include <botan/fork256.h> @@ -193,7 +196,10 @@ Default_Engine::find_hash(const std::string& algo_spec) const return 0; const std::string algo_name = global_state().deref_alias(name[0]); +#ifdef BOTAN_HAS_ADLER32 HANDLE_TYPE_NO_ARGS("Adler32", Adler32); +#endif + HANDLE_TYPE_NO_ARGS("CRC24", CRC24); HANDLE_TYPE_NO_ARGS("CRC32", CRC32); HANDLE_TYPE_NO_ARGS("FORK-256", FORK_256); diff --git a/src/modules.cpp b/src/modules.cpp index a5016aa8c..d38a29c9a 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -9,23 +9,23 @@ #include <botan/timers.h> #include <botan/parsing.h> -#if defined(BOTAN_EXT_MUTEX_PTHREAD) +#if defined(BOTAN_HAS_MUTEX_PTHREAD) #include <botan/mux_pthr.h> -#elif defined(BOTAN_EXT_MUTEX_WIN32) +#elif defined(BOTAN_HAS_MUTEX_WIN32) #include <botan/mux_win32.h> -#elif defined(BOTAN_EXT_MUTEX_QT) +#elif defined(BOTAN_HAS_MUTEX_QT) #include <botan/mux_qt.h> #endif -#if defined(BOTAN_EXT_ALLOC_MMAP) +#if defined(BOTAN_HAS_ALLOC_MMAP) #include <botan/mmap_mem.h> #endif -#if defined(BOTAN_EXT_ENGINE_GNU_MP) +#if defined(BOTAN_HAS_ENGINE_GNU_MP) #include <botan/eng_gmp.h> #endif -#if defined(BOTAN_EXT_ENGINE_OPENSSL) +#if defined(BOTAN_HAS_ENGINE_OPENSSL) #include <botan/eng_ossl.h> #endif @@ -36,11 +36,11 @@ namespace Botan { *************************************************/ Mutex_Factory* Builtin_Modules::mutex_factory() const { -#if defined(BOTAN_EXT_MUTEX_PTHREAD) +#if defined(BOTAN_HAS_MUTEX_PTHREAD) return new Pthread_Mutex_Factory; -#elif defined(BOTAN_EXT_MUTEX_WIN32) +#elif defined(BOTAN_HAS_MUTEX_WIN32) return new Win32_Mutex_Factory; -#elif defined(BOTAN_EXT_MUTEX_QT) +#elif defined(BOTAN_HAS_MUTEX_QT) return new Qt_Mutex_Factory; #else return 0; @@ -54,7 +54,7 @@ std::vector<Allocator*> Builtin_Modules::allocators() const { std::vector<Allocator*> allocators; -#if defined(BOTAN_EXT_ALLOC_MMAP) +#if defined(BOTAN_HAS_ALLOC_MMAP) allocators.push_back(new MemoryMapping_Allocator); #endif @@ -71,7 +71,7 @@ std::string Builtin_Modules::default_allocator() const { if(should_lock) { -#if defined(BOTAN_EXT_ALLOC_MMAP) +#if defined(BOTAN_HAS_ALLOC_MMAP) return "mmap"; #else return "locking"; @@ -90,11 +90,11 @@ std::vector<Engine*> Builtin_Modules::engines() const if(use_engines) { -#if defined(BOTAN_EXT_ENGINE_GNU_MP) +#if defined(BOTAN_HAS_ENGINE_GNU_MP) engines.push_back(new GMP_Engine); #endif -#if defined(BOTAN_EXT_ENGINE_OPENSSL) +#if defined(BOTAN_HAS_ENGINE_OPENSSL) engines.push_back(new OpenSSL_Engine); #endif } diff --git a/src/rng.cpp b/src/rng.cpp index 55c1c6032..3d13533ab 100644 --- a/src/rng.cpp +++ b/src/rng.cpp @@ -10,41 +10,41 @@ #include <botan/parsing.h> #include <botan/timers.h> -#if defined(BOTAN_EXT_TIMER_HARDWARE) +#if defined(BOTAN_HAS_TIMER_HARDWARE) #include <botan/tm_hard.h> -#elif defined(BOTAN_EXT_TIMER_POSIX) +#elif defined(BOTAN_HAS_TIMER_POSIX) #include <botan/tm_posix.h> -#elif defined(BOTAN_EXT_TIMER_UNIX) +#elif defined(BOTAN_HAS_TIMER_UNIX) #include <botan/tm_unix.h> -#elif defined(BOTAN_EXT_TIMER_WIN32) +#elif defined(BOTAN_HAS_TIMER_WIN32) #include <botan/tm_win32.h> #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_DEVICE) +#if defined(BOTAN_HAS_ENTROPY_SRC_DEVICE) #include <botan/es_dev.h> #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_EGD) +#if defined(BOTAN_HAS_ENTROPY_SRC_EGD) #include <botan/es_egd.h> #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_UNIX) +#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX) #include <botan/es_unix.h> #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_BEOS) +#if defined(BOTAN_HAS_ENTROPY_SRC_BEOS) #include <botan/es_beos.h> #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_CAPI) +#if defined(BOTAN_HAS_ENTROPY_SRC_CAPI) #include <botan/es_capi.h> #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_WIN32) +#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32) #include <botan/es_win32.h> #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_FTW) +#if defined(BOTAN_HAS_ENTROPY_SRC_FTW) #include <botan/es_ftw.h> #endif @@ -77,19 +77,19 @@ RandomNumberGenerator* RandomNumberGenerator::make_rng() new ANSI_X931_RNG("AES-256", new Randpool("AES-256", "HMAC(SHA-256)")); -#if defined(BOTAN_EXT_TIMER_HARDWARE) +#if defined(BOTAN_HAS_TIMER_HARDWARE) rng->add_entropy_source(new Hardware_Timer); -#elif defined(BOTAN_EXT_TIMER_POSIX) +#elif defined(BOTAN_HAS_TIMER_POSIX) rng->add_entropy_source(new POSIX_Timer); -#elif defined(BOTAN_EXT_TIMER_UNIX) +#elif defined(BOTAN_HAS_TIMER_UNIX) rng->add_entropy_source(new Unix_Timer); -#elif defined(BOTAN_EXT_TIMER_WIN32) +#elif defined(BOTAN_HAS_TIMER_WIN32) rng->add_entropy_source(new Win32_Timer); #else rng->add_entropy_source(new Timer); #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_DEVICE) +#if defined(BOTAN_HAS_ENTROPY_SRC_DEVICE) rng->add_entropy_source( new Device_EntropySource( split_on("/dev/random:/dev/srandom:/dev/urandom", ':') @@ -97,31 +97,31 @@ RandomNumberGenerator* RandomNumberGenerator::make_rng() ); #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_EGD) +#if defined(BOTAN_HAS_ENTROPY_SRC_EGD) rng->add_entropy_source( new EGD_EntropySource(split_on("/var/run/egd-pool:/dev/egd-pool", ':')) ); #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_CAPI) +#if defined(BOTAN_HAS_ENTROPY_SRC_CAPI) rng->add_entropy_source(new Win32_CAPI_EntropySource); #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_WIN32) +#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32) rng->add_entropy_source(new Win32_EntropySource); #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_UNIX) +#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX) rng->add_entropy_source( new Unix_EntropySource(split_on("/bin:/sbin:/usr/bin:/usr/sbin", ':')) ); #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_BEOS) +#if defined(BOTAN_HAS_ENTROPY_SRC_BEOS) rng->add_entropy_source(new BeOS_EntropySource); #endif -#if defined(BOTAN_EXT_ENTROPY_SRC_FTW) +#if defined(BOTAN_HAS_ENTROPY_SRC_FTW) rng->add_entropy_source(new FTW_EntropySource("/proc")); #endif |