Botan  1.11.10
libstate.cpp
Go to the documentation of this file.
1 /*
2 * Library Internal/Global State
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #include <botan/libstate.h>
9 #include <botan/charset.h>
10 #include <botan/engine.h>
11 #include <botan/cpuid.h>
12 #include <botan/oids.h>
13 #include <botan/internal/core_engine.h>
14 #include <botan/internal/stl_util.h>
15 #include <algorithm>
16 
17 #if defined(BOTAN_HAS_SELFTESTS)
18  #include <botan/selftest.h>
19 #endif
20 
21 #if defined(BOTAN_HAS_ENGINE_ASSEMBLER)
22  #include <botan/internal/asm_engine.h>
23 #endif
24 
25 #if defined(BOTAN_HAS_ENGINE_AES_ISA)
26  #include <botan/internal/aes_isa_engine.h>
27 #endif
28 
29 #if defined(BOTAN_HAS_ENGINE_SIMD)
30  #include <botan/internal/simd_engine.h>
31 #endif
32 
33 #if defined(BOTAN_HAS_ENGINE_GNU_MP)
34  #include <botan/internal/gnump_engine.h>
35 #endif
36 
37 #if defined(BOTAN_HAS_ENGINE_OPENSSL)
38  #include <botan/internal/openssl_engine.h>
39 #endif
40 
41 namespace Botan {
42 
43 /*
44 * Return a reference to the Algorithm_Factory
45 */
47  {
48  if(!m_algorithm_factory)
49  throw Invalid_State("Uninitialized in Library_State::algorithm_factory");
50  return *m_algorithm_factory;
51  }
52 
53 /*
54 * Return a reference to the global PRNG
55 */
57  {
58  return *m_global_prng;
59  }
60 
62  {
63  if(m_algorithm_factory.get())
64  throw Invalid_State("Library_State has already been initialized");
65 
67 
70 
71  m_algorithm_factory.reset(new Algorithm_Factory());
72 
73 #if defined(BOTAN_HAS_ENGINE_GNU_MP)
75 #endif
76 
77 #if defined(BOTAN_HAS_ENGINE_OPENSSL)
79 #endif
80 
81 #if defined(BOTAN_HAS_ENGINE_AES_ISA)
83 #endif
84 
85 #if defined(BOTAN_HAS_ENGINE_SIMD)
87 #endif
88 
89 #if defined(BOTAN_HAS_ENGINE_ASSEMBLER)
91 #endif
92 
94 
95  m_sources = entropy_sources();
96 
97  m_global_prng.reset(new Serialized_RNG());
98 
99 #if defined(BOTAN_HAS_SELFTESTS)
101 #endif
102  }
103 
104 }
RandomNumberGenerator & global_rng()
Definition: libstate.cpp:56
void confirm_startup_self_tests(Algorithm_Factory &af)
Definition: selftest.cpp:265
Algorithm_Factory & algorithm_factory() const
Definition: libstate.cpp:46
void set_defaults()
Definition: default.cpp:17
Definition: buf_comp.h:15
void add_engine(Engine *engine)
static void initialize()
Definition: cpuid.cpp:182
static void set_default_aliases()
Definition: scan_name.cpp:196