| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
for the implementation in Library_State. Instead explicitly call deref_alias
on global_state() wherever the old freestanding version was used. This serves
to make (more) uses of the global state explicit rather than implicit.
|
|
|
|
|
|
|
|
| |
In reality, Config was a singleton, with the only owner being the
Library_State object. Theoretically one could create and use another Config
instance, but in practice it was never done. Reflect the reality and inline
the members and public functions of Config in Library_State, removing Config
entirely.
|
| |
|
| |
|
| |
|
|
|
|
| |
to use) explicit arguments to the constructor instead of being hardcoded.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|\
| |
| |
| |
| |
| | |
bcae6a19d8d96ebde33c832c76a130ea02bc923a)
to branch 'net.randombit.botan.remove-libstate' (head f640991b6e433a264f5d22a08338cfc9c24c82da)
|
| |\
| | |
| | |
| | |
| | |
| | | |
6afe2db1f710f75bc27e189bb8bdb23613ce1ca3)
to branch 'net.randombit.botan.remove-libstate' (head e40f0dbdfd847024c30fa0092c2acefc19a550b8)
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | | |
fruit for removal.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
(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.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
updated dates on files that have actually changed this year. This makes
the diff across versions readable again.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Library_State::initialize: now the LibraryInitializer is just a simple
wrapper to create/destroy the state with no other operations.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
| |
|
|
|
|
|
| |
global state pointer was set. Presumably I put that there for debugging
at some point and let it escape.
|
| |
|
|
|
|
|
| |
as I can tell) the last of the global data, with the exception of the single
global_lib_state pointer in libstate.cpp
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
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()
|
|
|
|
| |
Use for_each + the delete wrappers in libstate.cpp
|
|
|
|
| |
like iconv may be useful there...)
|
|
|
|
|
| |
of stand-alone functions. Store the configuration in a distinct
object, rather than just a map inside the library state.
|
| |
|
|
|
|
| |
not completely happy with it.
|
|
|
|
|
|
| |
Alter the AEP engine to use one in favor of a static Mutex pointer.
Fix a stupid typo in an exception message.
|
| |
|
|
|
|
| |
of initialization in the constructor.
|
|
|
|
| |
around as ancillary strings.
|
| |
|
|
|
|
|
|
| |
Initialize the X.509 global state object lazily, on first access
Alter the order that global objects are deleted.
|
|
|
|
|
| |
the return value of swap_global_state rather than manipulate the
state object directly.
|
|
|
|
|
| |
Initialize the X509_GlobalState pointer during Library_State
construction.
|
|
|
|
| |
Initial implementation of a factory for extension objects
|
|
|
|
| |
simultaneous library states.
|