Botan: Botan::Global_State_Management Namespace Reference

Botan 1.10.16

Functions
Botan::Global_State_Management Namespace Reference

## Functions
Library_State & | global_state ()
bool | global_state_exists ()
void | set_global_state (Library_State *new_state)
bool | set_global_state_unless_set (Library_State *new_state)
Library_State * | swap_global_state (Library_State *new_state)

## Detailed Description

Namespace for management of the global state

## Function Documentation

## ◆ global_state()

BOTAN_DLL Library_State & Botan::Global_State_Management::global_state | ( |  | ) |

Access the global library state

Returns
  reference to the global library state

Definition at line 32 of file global_state.cpp.

References Botan::Library_State::initialize().

Referenced by Botan::OIDS::add_oid(), Botan::block_size_of(), Botan::DH_KA_Operation::DH_KA_Operation(), Botan::DL_Group::DL_Group(), Botan::EC_Group::EC_Group(), Botan::ElGamal_Decryption_Operation::ElGamal_Decryption_Operation(), Botan::Allocator::get(), Botan::get_block_cipher(), Botan::get_cipher(), Botan::get_eme(), Botan::get_emsa(), Botan::get_hash(), Botan::get_kdf(), Botan::get_mac(), Botan::get_pbe(), Botan::get_pbkdf(), Botan::get_stream_cipher(), Botan::Hash_Filter::Hash_Filter(), Botan::have_algorithm(), Botan::have_block_cipher(), Botan::have_hash(), Botan::have_mac(), Botan::OIDS::have_oid(), Botan::have_stream_cipher(), Botan::LibraryInitializer::initialize(), Botan::keylength_multiple_of(), Botan::OIDS::lookup(), Botan::MAC_Filter::MAC_Filter(), Botan::max_keylength_of(), Botan::min_keylength_of(), Botan::output_length_of(), Botan::PK_Decryptor_EME::PK_Decryptor_EME(), Botan::PK_Encryptor_EME::PK_Encryptor_EME(), Botan::PK_Key_Agreement::PK_Key_Agreement(), Botan::PK_Signer::PK_Signer(), Botan::PK_Verifier::PK_Verifier(), Botan::retrieve_block_cipher(), Botan::retrieve_hash(), Botan::retrieve_mac(), Botan::retrieve_stream_cipher(), Botan::RSA_Private_Operation::RSA_Private_Operation(), Botan::SCAN_Name::SCAN_Name(), Botan::Record_Writer::set_keys(), Botan::Record_Reader::set_keys(), and Botan::StreamCipher_Filter::StreamCipher_Filter().

33 {
34 /* Lazy initialization. Botan still needs to be deinitialized later
35 on or memory might leak.
36 */
37 if(!global_lib_state)
38 {
39 global_lib_state = new Library_State;
40 global_lib_state->initialize(true);
41 }
42
43 return (*global_lib_state);
44 }

## ◆ global_state_exists()

BOTAN_DLL bool Botan::Global_State_Management::global_state_exists | ( |  | ) |

Query if the library is currently initialized

Returns
  true iff the library is initialized

Definition at line 84 of file global_state.cpp.

85 {
86 return (global_lib_state != 0);
87 }

## ◆ set_global_state()

BOTAN_DLL void Botan::Global_State_Management::set_global_state | ( | Library_State * | state | ) |

Set the global state object

Parameters

  state | the new global state to use

Definition at line 49 of file global_state.cpp.

References swap_global_state().

Referenced by Botan::LibraryInitializer::deinitialize(), and Botan::LibraryInitializer::initialize().

50 {
51 delete swap_global_state(new_state);
52 }
Botan::Global_State_Management::swap_global_state
Library_State * swap_global_state(Library_State *new_state)
Definition: global_state.cpp:74

## ◆ set_global_state_unless_set()

BOTAN_DLL bool Botan::Global_State_Management::set_global_state_unless_set | ( | Library_State * | state | ) |

Set the global state object unless it is already set

Parameters

  state | the new global state to use

Returns
  true if the state parameter is now being used as the global state, or false if one was already set, in which case the parameter was deleted immediately

Definition at line 57 of file global_state.cpp.

References swap_global_state().

58 {
59 if(global_lib_state)
60 {
61 delete new_state;
62 return false;
63 }
64 else
65 {
66 delete swap_global_state(new_state);
67 return true;
68 }
69 }
Botan::Global_State_Management::swap_global_state
Library_State * swap_global_state(Library_State *new_state)
Definition: global_state.cpp:74

## ◆ swap_global_state()

BOTAN_DLL Library_State * Botan::Global_State_Management::swap_global_state | ( | Library_State * | new_state | ) |

Swap the current state for another

Parameters

  new_state | the new state object to use

Returns
  previous state (or NULL if none)

Definition at line 74 of file global_state.cpp.

Referenced by set_global_state(), and set_global_state_unless_set().

75 {
76 Library_State* old_state = global_lib_state;
77 global_lib_state = new_state;
78 return old_state;
79 }