Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::Data_Store Class Reference

`#include <datastor.h>`

## Public Member Functions
void | add (const std::multimap< std::string, std::string > &)
void | add (const std::string &, const std::string &)
void | add (const std::string &, uint32_t)
void | add (const std::string &, const secure_vector< uint8_t > &)
void | add (const std::string &, const std::vector< uint8_t > &)
std::vector< std::string > | get (const std::string &) const
std::string | get1 (const std::string &key) const
std::string | get1 (const std::string &key, const std::string &default_value) const
std::vector< uint8_t > | get1_memvec (const std::string &) const
uint32_t | get1_uint32 (const std::string &, uint32_t=0) const
bool | has_value (const std::string &) const
bool | operator== (const Data_Store &) const
std::multimap< std::string, std::string > | search_for (std::function< bool(std::string, std::string)> predicate) const

## Detailed Description

Data Store

This class is used internally by the library, and exposed for ABI reasons. There is no reason for applications to use this type directly. It will be removed in a future major release.

Definition at line 27 of file datastor.h.

## Member Function Documentation

void Botan::Data_Store::add | ( | const std::multimap< std::string, std::string > & | in | ) |

Definition at line 154 of file datastor.cpp.

Referenced by add(), Botan::Extensions::contents_to(), and Botan::X509_CRL::X509_CRL().

155 {
156 std::multimap<std::string, std::string>::const_iterator i = in.begin();
157 while(i != in.end())
158 {
159 m_contents.insert(*i);
160 ++i;
161 }
162 }

void Botan::Data_Store::add | ( | const std::string & | key,
|  | const std::string & | val
| ) |  |

Definition at line 125 of file datastor.cpp.

References Botan::multimap_insert().

126 {
127 multimap_insert(m_contents, key, val);
128 }
Botan::multimap_insert
void multimap_insert(std::multimap< K, V > &multimap, const K &key, const V &value)
Definition: stl_util.h:76

void Botan::Data_Store::add | ( | const std::string & | key,
|  | uint32_t | val
| ) |  |

Definition at line 133 of file datastor.cpp.

References add(), and Botan::ASN1::to_string().

134 {
135 add(key, std::to_string(val));
136 }
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:47
Botan::Data_Store::add
void add(const std::multimap< std::string, std::string > &)
Definition: datastor.cpp:154

void Botan::Data_Store::add | ( | const std::string & | key,
|  | const secure_vector< uint8_t > & | val
| ) |  |

Definition at line 141 of file datastor.cpp.

References add(), and Botan::hex_encode().

142 {
143 add(key, hex_encode(val.data(), val.size()));
144 }
Botan::hex_encode
void hex_encode(char output[], const uint8_t input[], size_t input_length, bool uppercase)
Definition: hex.cpp:14
Botan::Data_Store::add
void add(const std::multimap< std::string, std::string > &)
Definition: datastor.cpp:154

void Botan::Data_Store::add | ( | const std::string & | key,
|  | const std::vector< uint8_t > & | val
| ) |  |

Definition at line 146 of file datastor.cpp.

References add(), and Botan::hex_encode().

147 {
148 add(key, hex_encode(val.data(), val.size()));
149 }
Botan::hex_encode
void hex_encode(char output[], const uint8_t input[], size_t input_length, bool uppercase)
Definition: hex.cpp:14
Botan::Data_Store::add
void add(const std::multimap< std::string, std::string > &)
Definition: datastor.cpp:154

std::vector< std::string > Botan::Data_Store::get | ( | const std::string & | looking_for | ) | const

Definition at line 50 of file datastor.cpp.

Referenced by Botan::X509_Certificate::ex_constraints(), Botan::X509_Certificate::issuer_info(), Botan::X509_Certificate::name_constraints(), Botan::X509_Certificate::policies(), and Botan::X509_Certificate::subject_info().

51 {
52 std::vector<std::string> out;
53 auto range = m_contents.equal_range(looking_for);
54 for(auto i = range.first; i != range.second; ++i)
55 out.push_back(i->second);
56 return out;
57 }

std::string Botan::Data_Store::get1 | ( | const std::string & | key | ) | const

Definition at line 62 of file datastor.cpp.

Referenced by Botan::PKCS10_Request::challenge_password(), Botan::X509_Certificate::crl_distribution_point(), Botan::X509_Certificate::end_time(), Botan::X509_CRL::next_update(), Botan::X509_Certificate::ocsp_responder(), Botan::PKCS10_Request::raw_public_key(), Botan::X509_Certificate::start_time(), Botan::PKCS10_Request::subject_public_key(), Botan::X509_Certificate::subject_public_key_bits(), and Botan::X509_CRL::this_update().

63 {
64 std::vector<std::string> vals = get(key);
65
66 if(vals.empty())
67 throw Invalid_State("Data_Store::get1: No values set for " + key);
68 if(vals.size() > 1)
69 throw Invalid_State("Data_Store::get1: More than one value for " + key);
70
71 return vals[0];
72 }

std::string Botan::Data_Store::get1 | ( | const std::string & | key,
|  | const std::string & | default_value
| ) |  | const

Definition at line 74 of file datastor.cpp.

76 {
77 std::vector<std::string> vals = get(key);
78
79 if(vals.size() > 1)
80 throw Invalid_State("Data_Store::get1: More than one value for " + key);
81
82 if(vals.empty())
83 return default_value;
84
85 return vals[0];
86 }

std::vector< uint8_t > Botan::Data_Store::get1_memvec | ( | const std::string & | key | ) | const

Definition at line 92 of file datastor.cpp.

References Botan::hex_decode().

Referenced by Botan::X509_CRL::authority_key_id(), Botan::X509_Certificate::authority_key_id(), Botan::X509_Certificate::raw_issuer_dn(), Botan::X509_Certificate::raw_subject_dn(), Botan::X509_Certificate::serial_number(), and Botan::X509_Certificate::subject_key_id().

93 {
94 std::vector<std::string> vals = get(key);
95
96 if(vals.empty())
97 return std::vector<uint8_t>();
98
99 if(vals.size() > 1)
100 throw Invalid_State("Data_Store::get1_memvec: Multiple values for " +
101 key);
102
103 return hex_decode(vals[0]);
104 }
Botan::hex_decode
size_t hex_decode(uint8_t output[], const char input[], size_t input_length, size_t &input_consumed, bool ignore_ws)
Definition: hex.cpp:49

uint32_t Botan::Data_Store::get1_uint32 | ( | const std::string & | key,
|  | uint32_t | default_val = `0`
| ) |  | const

Definition at line 109 of file datastor.cpp.

References Botan::to_u32bit().

Referenced by Botan::X509_Certificate::constraints(), Botan::X509_CRL::crl_number(), Botan::CRL_Entry::decode_from(), Botan::X509_Certificate::is_CA_cert(), Botan::X509_Certificate::is_critical(), Botan::X509_Certificate::path_limit(), and Botan::X509_Certificate::x509_version().

111 {
112 std::vector<std::string> vals = get(key);
113
114 if(vals.empty())
115 return default_val;
116 else if(vals.size() > 1)
117 throw Invalid_State("Data_Store::get1_uint32: Multiple values for " + key);
118
119 return to_u32bit(vals[0]);
120 }
Botan::to_u32bit
uint32_t to_u32bit(const std::string &str)
Definition: parsing.cpp:18

bool Botan::Data_Store::has_value | ( | const std::string & | key | ) | const

Definition at line 27 of file datastor.cpp.

28 {
29 return (m_contents.lower_bound(key) != m_contents.end());
30 }

bool Botan::Data_Store::operator== | ( | const Data_Store & | other | ) | const

A search function

Definition at line 19 of file datastor.cpp.

20 {
21 return (m_contents == other.m_contents);
22 }

std::multimap< std::string, std::string > Botan::Data_Store::search_for | ( | std::function< bool(std::string, std::string)> | predicate | ) | const

Definition at line 35 of file datastor.cpp.

Referenced by Botan::create_alt_name(), and Botan::create_dn().

37 {
38 std::multimap<std::string, std::string> out;
39
40 for(auto i = m_contents.begin(); i != m_contents.end(); ++i)
41 if(predicate(i->first, i->second))
42 out.insert(std::make_pair(i->first, i->second));
43
44 return out;
45 }

The documentation for this class was generated from the following files:

- src/lib/x509/datastor.h
- src/lib/x509/datastor.cpp