aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make the two parameters of Randpool (which underlying block cipher and MAClloyd2008-05-251-1/+2
| | | | to use) explicit arguments to the constructor instead of being hardcoded.
* Remove both default arguments to the constructor of ANSI_X931_RNG.lloyd2008-05-241-1/+2
| | | | | | | | | | | | | | | | | | If the second argument was NULL, it would default to a new Randpool. But this introduces an annoying dependency: really it is the caller who is relying on Randpool. Make this explicit by passing a new Randpool pointer to the constructor in Library_State. This will break all callers using ANSI_X931_RNG's constructors with default arguments. To regain the previous behavior, change: ANSI_X931_RNG rng; ANSI_X931_RNG rng("/*cipher name*/"); to ANSI_X931_RNG rng(/*cipher name, default was AES-256 */, new Randpool); You are free to pass another PRNG object if you like. This make require inclusion of <botan/randpool.h>
* propagate from branch 'net.randombit.botan' (head ↵lloyd2008-04-121-94/+10
|\ | | | | | | | | | | bcae6a19d8d96ebde33c832c76a130ea02bc923a) to branch 'net.randombit.botan.remove-libstate' (head f640991b6e433a264f5d22a08338cfc9c24c82da)
| * propagate from branch 'net.randombit.botan' (head ↵lloyd2008-04-101-94/+10
| |\ | | | | | | | | | | | | | | | 6afe2db1f710f75bc27e189bb8bdb23613ce1ca3) to branch 'net.randombit.botan.remove-libstate' (head e40f0dbdfd847024c30fa0092c2acefc19a550b8)
| | * Remove the Global_RNG namespace, along with rng.h and rng.cpp. This waslloyd2008-04-071-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | essentially a facade for the RNG object living in the global library state. Rewrite all callers to directly invoke the global state object: this makes it more clear what functions are actually accessing mutable state outside of the normal reference graph (and thus, which functions will have to be altered in order to remove this dependency). Other facades remain in place for the configuration object and the memory allocator factory.
| | * Remove X509_GlobalState in favor of static function Extensions::get_extensionlloyd2008-04-071-24/+0
| | |
| | * Remove Charset_Transcoder; hardwire UTF-8/Latin-1 conversions into charset.cpplloyd2008-04-071-27/+0
| | |
| | * In Botan, the Timer base class provides access to a high-resolutionlloyd2008-04-071-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | timer with an unspecified update rate and epoch. It is only used inside the entropy sources to provide some timing-dependent randomness. However, it is easier and basically 'as good' to treat the timers as entropy sources in their own right and feed their output directly into an entropy pool. This commit removes Library_State::system_clock and all calls to that function.
| | * Library_State::set_timer is never called from within Botan, low hanginglloyd2008-04-071-9/+0
| | | | | | | | | | | | fruit for removal.
| | * The intent of this branch is to remove the global library state objectlloyd2008-04-071-22/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Library_State, in libstate.{h,cpp}). It causes numerous 'interesting' problems with threads, etc, and the best solution here is to move to more or less an object-capability model, where the only objects that a piece of code can access are those which can be referenced through its arguments. First things first, remove the UI 'pulse' code. It is neither necessary nor sufficient for writing proper GUI/event driven code using Botan, has likely never been used in real code, and, given that, causes a distressing amount of overhead in terms of function calls made.
* | | Rename fips140.h to selftest.h, since it doesn't really have much to dolloyd2008-04-101-3/+3
|/ / | | | | | | | | | | | | | | | | | | | | with FIPS-140 aside from being a startup self test. Remove the test of X9.19 MAC at startup because it's not that important, and loading it in the startup means a prototypical object will be created and exist in memory for the entire process runtime. This actually raises an interesting idea, that periodically the cache of objects could be cleared and, if one is needed again, it can be created again as if it was the first time.
* / Change the copyrights in all files in the Botan tree to directly reflectlloyd2008-04-101-1/+1
|/ | | | | | the actual copyright holders. For rationale, see my post to botan-devel on April 9, subject 'Changing license to directly reflect contributors' (http://www.randombit.net/pipermail/botan-devel/2008-April/000527.html)
* Remove the Named_Mutex_Holder and associated code. Convert all uses tolloyd2008-04-021-33/+17
| | | | | | | | | | | | | | instead allocate a reference to a mutex locally and use the more typical Mutex_Holder RAII object. Named_Mutex_Holder (and in particular the string->mutex mappings contained in the global state) have been found to be pretty expensive in at least some situations (see post by Jack Cummings to monotone-devel 2008-03-12), and doesn't really buy us that much in terms of ease of use. Also, it relies on the global state object, which has shown itself to be a rich source of race conditions and locking bugs. The intent is to incrementally remove all of the shared / global state and require applications to maintain that state where necessary.
* Mostly revert 2f4fd18182d5a75c40cd831e7ee3c314be5c57d6, only keep thelloyd2008-03-101-1/+1
| | | | | updated dates on files that have actually changed this year. This makes the diff across versions readable again.
* Mass update of the copyright date. Honestly I don't know why I bother,lloyd2008-02-141-1/+1
| | | | | | | but might as well keep it up to date. And it's easier to do it once with a 'perl -pi' command than to update each file over time. Apologies to anyone looking at diffs.
* Remove the ability to load an external configuration file. Applicationslloyd2007-11-141-3/+0
| | | | | | | | | | | needing this functionality probably already have a preexisting configuration system that they would rather use. Also remove the documentation about this feature, and the example configuration (which was pretty out of date, anyway). RFC on this change sent to the mailing list on 11-13-2007, no responses after 24 hours. It seems quite likely this code is not in use anywhere.
* Move the self tests from LibraryInitializer::initialize tolloyd2007-10-151-0/+7
| | | | | Library_State::initialize: now the LibraryInitializer is just a simple wrapper to create/destroy the state with no other operations.
* The last checkin did not work; the Library_State constructor called code1.7.2lloyd2007-10-131-8/+28
| | | | | | | | that called global_state(), which cased an infinite recursion. Make creating a Library_State a two-phase operation, first an empty constructor (just sets all pointers to NULL), then an initializer that sets up everything needed to start up the library.
* Move most of the initializer code directly into the Library_State constructorlloyd2007-10-131-31/+43
|
* If we attempt to access the global state, and it is null, calllloyd2007-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LibraryInitializer::initialize(), which will set it for us (or fail by throwing an exception, which will be propogated to the caller). So any instances of creating a LibraryInitializer where no option arguments are passed can be removed; instead that initialization will run when or if you execute an operation where Botan requires the services provided in the state. Because no options are passed, the library will be using the default (debug and not thread safe) mutex type: so hopefully you'll quickly get an exception when the debug mutex realizes it is being used in a threaded application, but there is risk of operations silently failing before that happens. You can call LibraryInitializer::deinitialize() at the end of your main function (or whenever you think you won't need Botan anymore), to free the global state; if not a number of cleanup destructors will not run (including the final scrub of memory). You can even shut down Botan speculatively; if it turns out you need it again, it just means you'll have to take the cost of another initialization. However in applications that use Botan only in small bursts, or in rarely taken codepaths, you can remove the state entirely and suffer zero memory overhead. This probably only makes sense in memory constrained systems, but it's reasonable to do now. Speculatively deallocating the state is probably not thread safe without extra work. One thread calling deinitialize() would invalidate pointers that would have been visible to other threads. One (untested) idea: have an atomic integer with the number of current threads using Botan. If any thread decrements and hits zero, it could deinitialize Botan safely. This might cause too many repeated startup/shutdowns, which would depend on the app use pattern. In addition, since you can't pass arguments to the new Library_State, you can't specify the use of real mutexes (or anything else): so for right now, this only works in applications that are fine with the standard options. I want to find a way to get that working, though, since it's very inelegant. Currently a Default_Mutex (not at all thread safe but somewhat error checking) will be used. And self test will always be run (more on that below). I wrote a program that just initializes and shuts down in a tight loop. Running on my Gentoo box (Core2 E6400, gcc 4.1.2): thread_safe? selftest? time (ms) ------------ --------- --------- no yes 6.1 no no 3.8 yes yes 6.7 yes no 3.8 If you're actually worried that the library might start up OK but then start failing basic self tests, what you actually want to do is have a thread that runs diagnostics on your entire process state (including calling Botan's self test code) every N seconds. The question is how to get arguments from the outside world to the constructor of the Library_State that is created inside of global_state(): avoiding many self tests to save a bit of time (many applications won't care about the extra cost but sometimes 2 or 3 ms is important), and thread safety (beacuse you can't specify to use a real mutex).
* Use prefix rather than postfix increment in places where it can be used.lloyd2007-03-031-2/+2
|
* Remove a call to abort() in global_state() which was triggered if nolloyd2007-02-281-3/+0
| | | | | global state pointer was set. Presumably I put that there for debugging at some point and let it escape.
* Bump copyright year to 2007lloyd2007-01-201-1/+1
|
* Move the UI pulse functions into the global library state. That is (as bestlloyd2006-12-141-0/+20
| | | | | as I can tell) the last of the global data, with the exception of the single global_lib_state pointer in libstate.cpp
* The public add_engine API now always places the new engine at the frontlloyd2006-09-201-9/+8
| | | | | of the list. The only time when the other behavior was desired was inside the load() function, which now simply appends to the engines vector itself.
* Correctly deal with allocators added post-initialization. In particular,lloyd2006-09-111-16/+22
| | | | | | | | | | handle the case where an allocator is added that has the same name as one already registered. Flush the cached allocator pointer when the default is changed. Mark comparison operations in Pooling_Allocator::Memory_Block as inline; this seems to help the STL sort and binary search algorithms tremendously.
* Remove memory leak - the configuration object was not being deleted.lloyd2006-08-091-0/+1
|
* Make it possible to insert Engines into the front of the queue;lloyd2006-08-051-3/+7
| | | | | | otherwise any Engines added after startup (eg, application-specific ones) would only be used for new algorithm - it wouldn't be possible for them to override existing implementations.
* Remove a line that should have been deleted in the last commit.lloyd2006-07-071-1/+0
|
* Have Library_State's constructor thrown an exception if thelloyd2006-07-071-1/+2
| | | | | | | | mutex_factory argument is NULL. Have Init::initialize() pass either a new Mutex_Factory (the default no-op version), or the result of modules.mutex_factory(), depending on the value of args.thread_safe()
* Add del_fun and delete2nd functions for running deleteslloyd2006-07-021-8/+7
| | | | Use for_each + the delete wrappers in libstate.cpp
* Let modules override the transcoder object (since system libslloyd2006-07-011-0/+1
| | | | like iconv may be useful there...)
* Access the global configuration through an object reference insteadlloyd2006-07-011-51/+25
| | | | | of stand-alone functions. Store the configuration in a distinct object, rather than just a map inside the library state.
* Clean up initialization a little bit morelloyd2006-07-011-0/+23
|
* Various changes to how library initialization occurs, though I'm stilllloyd2006-06-261-1/+5
| | | | not completely happy with it.
* Support named mutexes outside of the global library state.lloyd2006-06-251-43/+29
| | | | | | Alter the AEP engine to use one in favor of a static Mutex pointer. Fix a stupid typo in an exception message.
* Guard set_timer with a check so it does not set the timer to NULLlloyd2006-06-251-2/+5
|
* Add a set_timer method to Library_State, and rearrange the orderlloyd2006-06-251-7/+14
| | | | of initialization in the constructor.
* Have allocator objects 'know' their own names, rather than keeping themlloyd2006-06-251-2/+4
| | | | around as ancillary strings.
* Make Library_State::x509_state() non-const to support lazy initialiation.lloyd2006-06-251-1/+1
|
* Have system_clock return 0, rather than crash, if no timer is setlloyd2006-06-251-7/+7
| | | | | | Initialize the X.509 global state object lazily, on first access Alter the order that global objects are deleted.
* Make set_global_state a little more elegant, by having it deletelloyd2006-06-251-2/+1
| | | | | the return value of swap_global_state rather than manipulate the state object directly.
* Add error checking to x509_state()lloyd2006-06-241-1/+5
| | | | | Initialize the X509_GlobalState pointer during Library_State construction.
* Add an X509_GlobalState pointer to the library state.lloyd2006-06-241-3/+21
| | | | Initial implementation of a factory for extension objects
* Add a swap_global_state, to allow the use of multiplelloyd2006-06-241-0/+8
| | | | simultaneous library states.
* Add some initial support for centralized/user-pluggable characterlloyd2006-06-131-0/+26
| | | | set conversions, to replace the current hardcoded stuff.
* Syntax changes to the BER and DER APIs to improve readability of codelloyd2006-05-191-0/+4
| | | | | that uses them. These changes are not backwards compatible, this commit updates all uses of the APIs within the library.
* Initial checkin1.5.6lloyd2006-05-181-0/+314